]>
Commit | Line | Data |
---|---|---|
b9215da1 MT |
1 | From 750f19526ae71aac801c77a3f7ef5374890c09b7 Mon Sep 17 00:00:00 2001 |
2 | From: Florian Weimer <fweimer@redhat.com> | |
3 | Date: Fri, 8 Sep 2023 13:02:06 +0200 | |
a61a21ef | 4 | Subject: [PATCH 16/44] elf: Remove unused l_text_end field from struct |
b9215da1 MT |
5 | link_map |
6 | ||
7 | It is a left-over from commit 52a01100ad011293197637e42b5be1a479a2 | |
8 | ("elf: Remove ad-hoc restrictions on dlopen callers [BZ #22787]"). | |
9 | ||
10 | When backporting commmit 6985865bc3ad5b23147ee73466583dd7fdf65892 | |
11 | ("elf: Always call destructors in reverse constructor order | |
12 | (bug 30785)"), we can move the l_init_called_next field to this | |
13 | place, so that the internal GLIBC_PRIVATE ABI does not change. | |
14 | ||
15 | Reviewed-by: Carlos O'Donell <carlos@redhat.com> | |
16 | Tested-by: Carlos O'Donell <carlos@redhat.com> | |
17 | (cherry picked from commit 53df2ce6885da3d0e89e87dca7b095622296014f) | |
18 | --- | |
19 | elf/dl-load.c | 2 +- | |
20 | elf/dl-load.h | 7 ++----- | |
21 | elf/rtld.c | 6 ------ | |
22 | elf/setup-vdso.h | 4 ---- | |
23 | include/link.h | 2 -- | |
24 | 5 files changed, 3 insertions(+), 18 deletions(-) | |
25 | ||
26 | diff --git a/elf/dl-load.c b/elf/dl-load.c | |
27 | index 9a87fda9c9..2923b1141d 100644 | |
28 | --- a/elf/dl-load.c | |
29 | +++ b/elf/dl-load.c | |
30 | @@ -1253,7 +1253,7 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd, | |
31 | ||
32 | /* Now process the load commands and map segments into memory. | |
33 | This is responsible for filling in: | |
34 | - l_map_start, l_map_end, l_addr, l_contiguous, l_text_end, l_phdr | |
35 | + l_map_start, l_map_end, l_addr, l_contiguous, l_phdr | |
36 | */ | |
37 | errstring = _dl_map_segments (l, fd, header, type, loadcmds, nloadcmds, | |
38 | maplength, has_holes, loader); | |
39 | diff --git a/elf/dl-load.h b/elf/dl-load.h | |
40 | index ecf6910c68..1d5207694b 100644 | |
41 | --- a/elf/dl-load.h | |
42 | +++ b/elf/dl-load.h | |
43 | @@ -83,14 +83,11 @@ struct loadcmd | |
44 | ||
45 | /* This is a subroutine of _dl_map_segments. It should be called for each | |
46 | load command, some time after L->l_addr has been set correctly. It is | |
47 | - responsible for setting up the l_text_end and l_phdr fields. */ | |
48 | + responsible for setting the l_phdr fields */ | |
49 | static __always_inline void | |
50 | _dl_postprocess_loadcmd (struct link_map *l, const ElfW(Ehdr) *header, | |
51 | const struct loadcmd *c) | |
52 | { | |
53 | - if (c->prot & PROT_EXEC) | |
54 | - l->l_text_end = l->l_addr + c->mapend; | |
55 | - | |
56 | if (l->l_phdr == 0 | |
57 | && c->mapoff <= header->e_phoff | |
58 | && ((size_t) (c->mapend - c->mapstart + c->mapoff) | |
59 | @@ -103,7 +100,7 @@ _dl_postprocess_loadcmd (struct link_map *l, const ElfW(Ehdr) *header, | |
60 | ||
61 | /* This is a subroutine of _dl_map_object_from_fd. It is responsible | |
62 | for filling in several fields in *L: l_map_start, l_map_end, l_addr, | |
63 | - l_contiguous, l_text_end, l_phdr. On successful return, all the | |
64 | + l_contiguous, l_phdr. On successful return, all the | |
65 | segments are mapped (or copied, or whatever) from the file into their | |
66 | final places in the address space, with the correct page permissions, | |
67 | and any bss-like regions already zeroed. It returns a null pointer | |
68 | diff --git a/elf/rtld.c b/elf/rtld.c | |
69 | index a91e2a4471..5107d16fe3 100644 | |
70 | --- a/elf/rtld.c | |
71 | +++ b/elf/rtld.c | |
72 | @@ -477,7 +477,6 @@ _dl_start_final (void *arg, struct dl_start_final_info *info) | |
73 | GL(dl_rtld_map).l_real = &GL(dl_rtld_map); | |
74 | GL(dl_rtld_map).l_map_start = (ElfW(Addr)) &__ehdr_start; | |
75 | GL(dl_rtld_map).l_map_end = (ElfW(Addr)) _end; | |
76 | - GL(dl_rtld_map).l_text_end = (ElfW(Addr)) _etext; | |
77 | /* Copy the TLS related data if necessary. */ | |
78 | #ifndef DONT_USE_BOOTSTRAP_MAP | |
79 | # if NO_TLS_OFFSET != 0 | |
80 | @@ -1119,7 +1118,6 @@ rtld_setup_main_map (struct link_map *main_map) | |
81 | bool has_interp = false; | |
82 | ||
83 | main_map->l_map_end = 0; | |
84 | - main_map->l_text_end = 0; | |
85 | /* Perhaps the executable has no PT_LOAD header entries at all. */ | |
86 | main_map->l_map_start = ~0; | |
87 | /* And it was opened directly. */ | |
88 | @@ -1211,8 +1209,6 @@ rtld_setup_main_map (struct link_map *main_map) | |
89 | allocend = main_map->l_addr + ph->p_vaddr + ph->p_memsz; | |
90 | if (main_map->l_map_end < allocend) | |
91 | main_map->l_map_end = allocend; | |
92 | - if ((ph->p_flags & PF_X) && allocend > main_map->l_text_end) | |
93 | - main_map->l_text_end = allocend; | |
94 | ||
95 | /* The next expected address is the page following this load | |
96 | segment. */ | |
97 | @@ -1272,8 +1268,6 @@ rtld_setup_main_map (struct link_map *main_map) | |
98 | = (char *) main_map->l_tls_initimage + main_map->l_addr; | |
99 | if (! main_map->l_map_end) | |
100 | main_map->l_map_end = ~0; | |
101 | - if (! main_map->l_text_end) | |
102 | - main_map->l_text_end = ~0; | |
103 | if (! GL(dl_rtld_map).l_libname && GL(dl_rtld_map).l_name) | |
104 | { | |
105 | /* We were invoked directly, so the program might not have a | |
106 | diff --git a/elf/setup-vdso.h b/elf/setup-vdso.h | |
107 | index 0079842d1f..d92b12a7aa 100644 | |
108 | --- a/elf/setup-vdso.h | |
109 | +++ b/elf/setup-vdso.h | |
110 | @@ -51,9 +51,6 @@ setup_vdso (struct link_map *main_map __attribute__ ((unused)), | |
111 | l->l_addr = ph->p_vaddr; | |
112 | if (ph->p_vaddr + ph->p_memsz >= l->l_map_end) | |
113 | l->l_map_end = ph->p_vaddr + ph->p_memsz; | |
114 | - if ((ph->p_flags & PF_X) | |
115 | - && ph->p_vaddr + ph->p_memsz >= l->l_text_end) | |
116 | - l->l_text_end = ph->p_vaddr + ph->p_memsz; | |
117 | } | |
118 | else | |
119 | /* There must be no TLS segment. */ | |
120 | @@ -62,7 +59,6 @@ setup_vdso (struct link_map *main_map __attribute__ ((unused)), | |
121 | l->l_map_start = (ElfW(Addr)) GLRO(dl_sysinfo_dso); | |
122 | l->l_addr = l->l_map_start - l->l_addr; | |
123 | l->l_map_end += l->l_addr; | |
124 | - l->l_text_end += l->l_addr; | |
125 | l->l_ld = (void *) ((ElfW(Addr)) l->l_ld + l->l_addr); | |
126 | elf_get_dynamic_info (l, false, false); | |
127 | _dl_setup_hash (l); | |
128 | diff --git a/include/link.h b/include/link.h | |
129 | index 69bda3ed17..c6af095d87 100644 | |
130 | --- a/include/link.h | |
131 | +++ b/include/link.h | |
132 | @@ -253,8 +253,6 @@ struct link_map | |
133 | /* Start and finish of memory map for this object. l_map_start | |
134 | need not be the same as l_addr. */ | |
135 | ElfW(Addr) l_map_start, l_map_end; | |
136 | - /* End of the executable part of the mapping. */ | |
137 | - ElfW(Addr) l_text_end; | |
138 | ||
139 | /* Default array for 'l_scope'. */ | |
140 | struct r_scope_elem *l_scope_mem[4]; | |
141 | -- | |
142 | 2.39.2 | |
143 |