Gentoo Archives: gentoo-commits

From: "Roy Marples (uberlord)" <uberlord@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sys-freebsd/freebsd-libexec/files: freebsd-libexec-6.2-dl_iterate_phdr.patch digest-freebsd-libexec-6.2-r2
Date: Wed, 12 Sep 2007 00:31:48
Message-Id: E1IVFtT-00013y-6i@stork.gentoo.org
1 uberlord 07/09/12 00:15:47
2
3 Added: freebsd-libexec-6.2-dl_iterate_phdr.patch
4 digest-freebsd-libexec-6.2-r2
5 Log:
6 Backport dl_iterate_phdr from FreeBSD-7 so that future gcc's dont pull in libgcc_s.so.1
7 (Portage version: 2.1.3.7)
8
9 Revision Changes Path
10 1.1 sys-freebsd/freebsd-libexec/files/freebsd-libexec-6.2-dl_iterate_phdr.patch
11
12 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-freebsd/freebsd-libexec/files/freebsd-libexec-6.2-dl_iterate_phdr.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-freebsd/freebsd-libexec/files/freebsd-libexec-6.2-dl_iterate_phdr.patch?rev=1.1&content-type=text/plain
14
15 Index: freebsd-libexec-6.2-dl_iterate_phdr.patch
16 ===================================================================
17 --- libexec/rtld-elf/rtld.h 2005/12/18 04:52:34 1.36
18 +++ libexec/rtld-elf/rtld.h 2005/12/18 19:43:32 1.37
19 @@ -90,6 +90,11 @@ typedef struct Struct_Needed_Entry {
20 unsigned long name; /* Offset of name in string table */
21 } Needed_Entry;
22
23 +typedef struct Struct_Name_Entry {
24 + STAILQ_ENTRY(Struct_Name_Entry) link;
25 + char name[1];
26 +} Name_Entry;
27 +
28 /* Lock object */
29 typedef struct Struct_LockInfo {
30 void *context; /* Client context for creating locks */
31 @@ -173,6 +193,9 @@ typedef struct Struct_Obj_Entry {
32 const char *rpath; /* Search path specified in object */
33 Needed_Entry *needed; /* Shared objects needed by this one (%) */
34
35 + STAILQ_HEAD(, Struct_Name_Entry) names; /* List of names for this object we
36 + know about. */
37 +
38 Elf_Addr init; /* Initialization function to call */
39 Elf_Addr fini; /* Termination function to call */
40
41 diff -ur libexec/rtld-elf/map_object.c libexec/rtld-elf/map_object.c
42 --- libexec/rtld-elf/map_object.c 2005-02-27 12:55:40 +0000
43 +++ libexec/rtld-elf/map_object.c 2007-09-10 11:29:53 +0100
44 @@ -61,7 +61,6 @@
45 Elf_Phdr **segs;
46 int nsegs;
47 Elf_Phdr *phdyn;
48 - Elf_Phdr *phphdr;
49 Elf_Phdr *phinterp;
50 Elf_Phdr *phtls;
51 caddr_t mapbase;
52 @@ -79,7 +78,8 @@
53 Elf_Addr clear_vaddr;
54 caddr_t clear_addr;
55 caddr_t clear_page;
56 - size_t nclear;
57 + Elf_Addr phdr_vaddr;
58 + size_t nclear, phsize;
59 Elf_Addr bss_vaddr;
60 Elf_Addr bss_vlimit;
61 caddr_t bss_addr;
62 @@ -95,9 +95,11 @@
63 * in that order.
64 */
65 phdr = (Elf_Phdr *) ((char *)hdr + hdr->e_phoff);
66 + phsize = hdr->e_phnum * sizeof (phdr[0]);
67 phlimit = phdr + hdr->e_phnum;
68 nsegs = -1;
69 - phdyn = phphdr = phinterp = phtls = NULL;
70 + phdyn = phinterp = phtls = NULL;
71 + phdr_vaddr = 0;
72 segs = alloca(sizeof(segs[0]) * hdr->e_phnum);
73 while (phdr < phlimit) {
74 switch (phdr->p_type) {
75 @@ -108,7 +110,7 @@
76
77 case PT_LOAD:
78 segs[++nsegs] = phdr;
79 - if (segs[nsegs]->p_align < PAGE_SIZE) {
80 + if ((segs[nsegs]->p_align & (PAGE_SIZE - 1)) != 0) {
81 _rtld_error("%s: PT_LOAD segment %d not page-aligned",
82 path, nsegs);
83 return NULL;
84 @@ -116,7 +118,8 @@
85 break;
86
87 case PT_PHDR:
88 - phphdr = phdr;
89 + phdr_vaddr = phdr->p_vaddr;
90 + phsize = phdr->p_memsz;
91 break;
92
93 case PT_DYNAMIC:
94 @@ -211,6 +214,11 @@
95 return NULL;
96 }
97 }
98 + if (phdr_vaddr == 0 && data_offset <= hdr->e_phoff &&
99 + (data_vlimit - data_vaddr + data_offset) >=
100 + (hdr->e_phoff + hdr->e_phnum * sizeof (Elf_Phdr))) {
101 + phdr_vaddr = data_vaddr + hdr->e_phoff - data_offset;
102 + }
103 }
104
105 obj = obj_new();
106 @@ -227,10 +235,19 @@
107 obj->dynamic = (const Elf_Dyn *) (obj->relocbase + phdyn->p_vaddr);
108 if (hdr->e_entry != 0)
109 obj->entry = (caddr_t) (obj->relocbase + hdr->e_entry);
110 - if (phphdr != NULL) {
111 - obj->phdr = (const Elf_Phdr *) (obj->relocbase + phphdr->p_vaddr);
112 - obj->phsize = phphdr->p_memsz;
113 + if (phdr_vaddr != 0) {
114 + obj->phdr = (const Elf_Phdr *) (obj->relocbase + phdr_vaddr);
115 + } else {
116 + obj->phdr = malloc(phsize);
117 + if (obj->phdr == NULL) {
118 + obj_free(obj);
119 + _rtld_error("%s: cannot allocate program header", path);
120 + return NULL;
121 + }
122 + memcpy((char *)obj->phdr, (char *)hdr + hdr->e_phoff, phsize);
123 + obj->phdr_alloc = true;
124 }
125 + obj->phsize = phsize;
126 if (phinterp != NULL)
127 obj->interp = (const char *) (obj->relocbase + phinterp->p_vaddr);
128 if (phtls != NULL) {
129 @@ -308,7 +325,6 @@
130 if (obj->tls_done) {
131 free_tls_offset(obj);
132 }
133 - free(obj->path);
134 while (obj->needed != NULL) {
135 Needed_Entry *needed = obj->needed;
136 obj->needed = needed->next;
137 @@ -325,6 +341,7 @@
138 free(elm);
139 }
140 free(obj->origin_path);
141 + free(obj->path);
142 free(obj->priv);
143 free(obj);
144 }
145 diff -ur libexec/rtld-elf/rtld.c libexec/rtld-elf/rtld.c
146 --- libexec/rtld-elf/rtld.c 2006-09-02 21:38:13 +0100
147 +++ libexec/rtld-elf/rtld.c 2007-09-10 11:22:48 +0100
148 @@ -153,6 +153,7 @@
149 static Obj_Entry *obj_main; /* The main program shared object */
150 static Obj_Entry obj_rtld; /* The dynamic linker shared object */
151 static unsigned int obj_count; /* Number of objects in obj_list */
152 +static unsigned int obj_loads; /* Number of objects in obj_list */
153
154 static Objlist list_global = /* Objects dlopened with RTLD_GLOBAL */
155 STAILQ_HEAD_INITIALIZER(list_global);
156 @@ -192,6 +193,9 @@
157 (func_ptr_type) &__tls_get_addr,
158 (func_ptr_type) &_rtld_allocate_tls,
159 (func_ptr_type) &_rtld_free_tls,
160 +#ifdef _GENTOO_DL_ITERATE_PHDR_
161 + (func_ptr_type) &dl_iterate_phdr,
162 +#endif
163 NULL
164 };
165
166 @@ -363,6 +365,7 @@
167 *obj_tail = obj_main;
168 obj_tail = &obj_main->next;
169 obj_count++;
170 + obj_loads++;
171 /* Make sure we don't call the main program's init and fini functions. */
172 obj_main->init = obj_main->fini = (Elf_Addr)NULL;
173
174 @@ -1287,6 +1290,7 @@
175 *obj_tail = obj;
176 obj_tail = &obj->next;
177 obj_count++;
178 + obj_loads++;
179 linkmap_add(obj); /* for GDB & dlinfo() */
180
181 dbg(" %p .. %p: %s", obj->mapbase,
182 @@ -1951,6 +1955,39 @@
183 return (error);
184 }
185
186 +#ifdef _GENTOO_DL_ITERATE_PHDR
187 +int
188 +dl_iterate_phdr(__dl_iterate_hdr_callback callback, void *param)
189 +{
190 + struct dl_phdr_info phdr_info;
191 + const Obj_Entry *obj;
192 + int error, lockstate;
193 +
194 + lockstate = rlock_acquire(rtld_bind_lock);
195 +
196 + error = 0;
197 +
198 + for (obj = obj_list; obj != NULL; obj = obj->next) {
199 + phdr_info.dlpi_addr = (Elf_Addr)obj->relocbase;
200 + phdr_info.dlpi_name = STAILQ_FIRST(&obj->names) ?
201 + STAILQ_FIRST(&obj->names)->name : obj->path;
202 + phdr_info.dlpi_phdr = obj->phdr;
203 + phdr_info.dlpi_phnum = obj->phsize / sizeof(obj->phdr[0]);
204 + phdr_info.dlpi_tls_modid = obj->tlsindex;
205 + phdr_info.dlpi_tls_data = obj->tlsinit;
206 + phdr_info.dlpi_adds = obj_loads;
207 + phdr_info.dlpi_subs = obj_loads - obj_count;
208 +
209 + if ((error = callback(&phdr_info, sizeof phdr_info, param)) != 0)
210 + break;
211 +
212 + }
213 + rlock_release(rtld_bind_lock, lockstate);
214 +
215 + return (error);
216 +}
217 +#endif
218 +
219 struct fill_search_info_args {
220 int request;
221 unsigned int flags;
222 diff -ur libexec/rtld-elf/rtld.h libexec/rtld-elf/rtld.h
223 --- libexec/rtld-elf/rtld.h 2005-12-30 22:13:56 +0000
224 +++ libexec/rtld-elf/rtld.h 2007-09-10 11:22:22 +0100
225 @@ -176,15 +176,16 @@
226 Elf_Addr init; /* Initialization function to call */
227 Elf_Addr fini; /* Termination function to call */
228
229 - bool mainprog; /* True if this is the main program */
230 - bool rtld; /* True if this is the dynamic linker */
231 - bool textrel; /* True if there are relocations to text seg */
232 - bool symbolic; /* True if generated with "-Bsymbolic" */
233 - bool bind_now; /* True if all relocations should be made first */
234 - bool traced; /* Already printed in ldd trace output */
235 - bool jmpslots_done; /* Already have relocated the jump slots */
236 - bool init_done; /* Already have added object to init list */
237 - bool tls_done; /* Already allocated offset for static TLS */
238 + bool mainprog : 1; /* True if this is the main program */
239 + bool rtld : 1; /* True if this is the dynamic linker */
240 + bool textrel : 1; /* True if there are relocations to text seg */
241 + bool symbolic : 1; /* True if generated with "-Bsymbolic" */
242 + bool bind_now : 1; /* True if all relocations should be made first */
243 + bool traced : 1; /* Already printed in ldd trace output */
244 + bool jmpslots_done : 1; /* Already have relocated the jump slots */
245 + bool init_done : 1; /* Already have added object to init list */
246 + bool tls_done : 1; /* Already allocated offset for static TLS */
247 + bool phdr_alloc : 1; /* Phdr is allocated and needs to be freed. */
248
249 struct link_map linkmap; /* for GDB and dlinfo() */
250 Objlist dldags; /* Object belongs to these dlopened DAGs (%) */
251 diff -ur libexec.orig/rtld-elf/rtld_lock.c libexec/rtld-elf/rtld_lock.c
252 --- libexec.orig/rtld-elf/rtld_lock.c 2004-11-16 20:45:51 +0000
253 +++ libexec/rtld-elf/rtld_lock.c 2007-09-10 11:22:22 +0100
254 @@ -54,7 +54,7 @@
255 #define RC_INCR 0x2 /* Adjusts count of readers desiring lock */
256
257 typedef struct Struct_Lock {
258 - volatile int lock;
259 + volatile u_int lock;
260 void *base;
261 } Lock;
262
263
264
265
266 1.1 sys-freebsd/freebsd-libexec/files/digest-freebsd-libexec-6.2-r2
267
268 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-freebsd/freebsd-libexec/files/digest-freebsd-libexec-6.2-r2?rev=1.1&view=markup
269 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-freebsd/freebsd-libexec/files/digest-freebsd-libexec-6.2-r2?rev=1.1&content-type=text/plain
270
271 Index: digest-freebsd-libexec-6.2-r2
272 ===================================================================
273 MD5 be30e9d113cb08eabbc8c2ad7a99b648 freebsd-bin-6.2.tar.bz2 406748
274 RMD160 d687c8ee46fdcc6ea441367a50aad03b695ee616 freebsd-bin-6.2.tar.bz2 406748
275 SHA256 202c2024d9a5326ddfd07cae49e2f663118a8ae2f8c79a40c92d513acece3935 freebsd-bin-6.2.tar.bz2 406748
276 MD5 da39228784512bd5bb4fba41f84d70d5 freebsd-contrib-6.2.tar.bz2 36594160
277 RMD160 8b89f1ac72ba0054efe1aec2d747ecd33789fde3 freebsd-contrib-6.2.tar.bz2 36594160
278 SHA256 dbbd9198597e176242806329242d0e12181820a921e5da42aadefaacda1b6277 freebsd-contrib-6.2.tar.bz2 36594160
279 MD5 a25ab389e5f4ebef301abe071b4c196e freebsd-etc-6.2.tar.bz2 190297
280 RMD160 1540601566ece689b3fc2935329a2eca62a24314 freebsd-etc-6.2.tar.bz2 190297
281 SHA256 ff5970db1d7842d2933589203ae0c3907dee427b2ea99de68fce678582bf1804 freebsd-etc-6.2.tar.bz2 190297
282 MD5 63b8b5552e729be41b98a73665bcd422 freebsd-lib-6.2.tar.bz2 2670374
283 RMD160 95bbce7862fc7a406b8629914f281d5e01e5ea71 freebsd-lib-6.2.tar.bz2 2670374
284 SHA256 8e0c909a79a9ed18841f8a5a6e25fc770f76de1a5dc20cbd6bc591bed52d1033 freebsd-lib-6.2.tar.bz2 2670374
285 MD5 5cad9ad0ed76a85bf9188020ed9be879 freebsd-libexec-6.2.tar.bz2 277231
286 RMD160 423490cb7c888bfce7edcf473d77868c65c21fe2 freebsd-libexec-6.2.tar.bz2 277231
287 SHA256 546821f50ff3e69cebd59e1415798233050259de33a4b37acfcbd56b8d92782b freebsd-libexec-6.2.tar.bz2 277231
288 MD5 c6c8f8a7218d2294e499f80a2c77def3 freebsd-ubin-6.2.tar.bz2 1772844
289 RMD160 8101bc3e98fa485e31ecf0d5529136ddeb4be5b9 freebsd-ubin-6.2.tar.bz2 1772844
290 SHA256 446c1a8c7031defda8b184ccf4535cacf651928f324db6ce0aaec3b87b04d9ae freebsd-ubin-6.2.tar.bz2 1772844
291 MD5 a1596f3407f95b33f927afc0e3eff428 freebsd-usbin-6.2.tar.bz2 2695872
292 RMD160 ea6104fcfbf6c0be511a80d0475e5a8f716292be freebsd-usbin-6.2.tar.bz2 2695872
293 SHA256 6195301d39e7bc7fa00f6dec71479b1800ea5c3dc9d3ea375dafe4e71e6485f0 freebsd-usbin-6.2.tar.bz2 2695872
294
295
296
297 --
298 gentoo-commits@g.o mailing list