summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/eglibc/ldconfig-native-2.12.1/32and64bit.patch
diff options
context:
space:
mode:
authorNitin A Kamble <nitin.a.kamble@intel.com>2011-03-29 12:55:18 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-04-04 23:56:31 +0100
commitf897723207b00b4c9dcdb43107891b7b82ce22f3 (patch)
treed429a853ef252a1cf887c822535012c33ebf4d26 /meta/recipes-core/eglibc/ldconfig-native-2.12.1/32and64bit.patch
parent1418414e9d8d5ebbf38b95be8c0ce83dbe4b525f (diff)
downloadpoky-f897723207b00b4c9dcdb43107891b7b82ce22f3.tar.gz
ldconfig-native-2.12.1: newer recipe with eglibc sources
This fixes [YOCTO #780] Handle the input/output data with different endian-ness correctly Also fix the definition of LD_SO for cross environment And remove the older 2.5 version of ldconfig-native recipe (From OE-Core rev: 694db055f3729662e0e0193a31f2098be599877f) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Nitin A Kamble <nitin.a.kamble@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/eglibc/ldconfig-native-2.12.1/32and64bit.patch')
-rw-r--r--meta/recipes-core/eglibc/ldconfig-native-2.12.1/32and64bit.patch323
1 files changed, 323 insertions, 0 deletions
diff --git a/meta/recipes-core/eglibc/ldconfig-native-2.12.1/32and64bit.patch b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/32and64bit.patch
new file mode 100644
index 0000000000..8069c8931d
--- /dev/null
+++ b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/32and64bit.patch
@@ -0,0 +1,323 @@
1Index: ldconfig-native-2.12.1/readelflib.c
2===================================================================
3--- ldconfig-native-2.12.1.orig/readelflib.c
4+++ ldconfig-native-2.12.1/readelflib.c
5@@ -40,39 +40,212 @@ do \
6
7 /* Returns 0 if everything is ok, != 0 in case of error. */
8 int
9-process_elf_file (const char *file_name, const char *lib, int *flag,
10+process_elf_file32 (const char *file_name, const char *lib, int *flag,
11 unsigned int *osversion, char **soname, void *file_contents,
12 size_t file_length)
13 {
14 int i;
15 unsigned int j;
16- ElfW(Addr) loadaddr;
17+ Elf32_Addr loadaddr;
18 unsigned int dynamic_addr;
19 size_t dynamic_size;
20 char *program_interpreter;
21
22- ElfW(Ehdr) *elf_header;
23- ElfW(Phdr) *elf_pheader, *segment;
24- ElfW(Dyn) *dynamic_segment, *dyn_entry;
25+ Elf32_Ehdr *elf_header;
26+ Elf32_Phdr *elf_pheader, *segment;
27+ Elf32_Dyn *dynamic_segment, *dyn_entry;
28 char *dynamic_strings;
29
30- elf_header = (ElfW(Ehdr) *) file_contents;
31+ elf_header = (Elf32_Ehdr *) file_contents;
32 *osversion = 0;
33
34- if (elf_header->e_ident [EI_CLASS] != ElfW (CLASS))
35+ if (elf_header->e_type != ET_DYN)
36 {
37- if (opt_verbose)
38+ error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name,
39+ elf_header->e_type);
40+ return 1;
41+ }
42+
43+ /* Get information from elf program header. */
44+ elf_pheader = (Elf32_Phdr *) (elf_header->e_phoff + file_contents);
45+ check_ptr (elf_pheader);
46+
47+ /* The library is an elf library, now search for soname and
48+ libc5/libc6. */
49+ *flag = FLAG_ELF;
50+
51+ loadaddr = -1;
52+ dynamic_addr = 0;
53+ dynamic_size = 0;
54+ program_interpreter = NULL;
55+ for (i = 0, segment = elf_pheader;
56+ i < elf_header->e_phnum; i++, segment++)
57+ {
58+ check_ptr (segment);
59+
60+ switch (segment->p_type)
61 {
62- if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
63- error (0, 0, _("%s is a 32 bit ELF file.\n"), file_name);
64- else if (elf_header->e_ident [EI_CLASS] == ELFCLASS64)
65- error (0, 0, _("%s is a 64 bit ELF file.\n"), file_name);
66- else
67- error (0, 0, _("Unknown ELFCLASS in file %s.\n"), file_name);
68+ case PT_LOAD:
69+ if (loadaddr == (Elf32_Addr) -1)
70+ loadaddr = segment->p_vaddr - segment->p_offset;
71+ break;
72+
73+ case PT_DYNAMIC:
74+ if (dynamic_addr)
75+ error (0, 0, _("more than one dynamic segment\n"));
76+
77+ dynamic_addr = segment->p_offset;
78+ dynamic_size = segment->p_filesz;
79+ break;
80+
81+ case PT_INTERP:
82+ program_interpreter = (char *) (file_contents + segment->p_offset);
83+ check_ptr (program_interpreter);
84+
85+ /* Check if this is enough to classify the binary. */
86+ for (j = 0; j < sizeof (interpreters) / sizeof (interpreters [0]);
87+ ++j)
88+ if (strcmp (program_interpreter, interpreters[j].soname) == 0)
89+ {
90+ *flag = interpreters[j].flag;
91+ break;
92+ }
93+ break;
94+
95+ case PT_NOTE:
96+ if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4)
97+ {
98+ Elf32_Word *abi_note = (Elf32_Word *) (file_contents
99+ + segment->p_offset);
100+ Elf32_Addr size = segment->p_filesz;
101+
102+ while (abi_note [0] != 4 || abi_note [1] != 16
103+ || abi_note [2] != 1
104+ || memcmp (abi_note + 3, "GNU", 4) != 0)
105+ {
106+#define ROUND(len) (((len) + sizeof (Elf32_Word)) - 1) & -sizeof (Elf32_Word)))
107+ Elf32_Addr) note_size = 3 * sizeof (Elf32_Word))
108+ + ROUND (abi_note[0])
109+ + ROUND (abi_note[1]);
110+
111+ if (size - 32 < note_size || note_size == 0)
112+ {
113+ size = 0;
114+ break;
115+ }
116+ size -= note_size;
117+ abi_note = (void *) abi_note + note_size;
118+ }
119+
120+ if (size == 0)
121+ break;
122+
123+ *osversion = (abi_note [4] << 24) |
124+ ((abi_note [5] & 0xff) << 16) |
125+ ((abi_note [6] & 0xff) << 8) |
126+ (abi_note [7] & 0xff);
127+ }
128+ break;
129+
130+ default:
131+ break;
132+ }
133+
134+ }
135+ if (loadaddr == (Elf32_Addr) -1)
136+ {
137+ /* Very strange. */
138+ loadaddr = 0;
139+ }
140+
141+ /* Now we can read the dynamic sections. */
142+ if (dynamic_size == 0)
143+ return 1;
144+
145+ dynamic_segment = (Elf32_Dyn *) (file_contents + dynamic_addr);
146+ check_ptr (dynamic_segment);
147+
148+ /* Find the string table. */
149+ dynamic_strings = NULL;
150+ for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
151+ ++dyn_entry)
152+ {
153+ check_ptr (dyn_entry);
154+ if (dyn_entry->d_tag == DT_STRTAB)
155+ {
156+ dynamic_strings = (char *) (file_contents + dyn_entry->d_un.d_val - loadaddr);
157+ check_ptr (dynamic_strings);
158+ break;
159 }
160- return 1;
161 }
162
163+ if (dynamic_strings == NULL)
164+ return 1;
165+
166+ /* Now read the DT_NEEDED and DT_SONAME entries. */
167+ for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
168+ ++dyn_entry)
169+ {
170+ if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME)
171+ {
172+ char *name = dynamic_strings + dyn_entry->d_un.d_val;
173+ check_ptr (name);
174+
175+ if (dyn_entry->d_tag == DT_NEEDED)
176+ {
177+
178+ if (*flag == FLAG_ELF)
179+ {
180+ /* Check if this is enough to classify the binary. */
181+ for (j = 0;
182+ j < sizeof (known_libs) / sizeof (known_libs [0]);
183+ ++j)
184+ if (strcmp (name, known_libs [j].soname) == 0)
185+ {
186+ *flag = known_libs [j].flag;
187+ break;
188+ }
189+ }
190+ }
191+
192+ else if (dyn_entry->d_tag == DT_SONAME)
193+ *soname = xstrdup (name);
194+
195+ /* Do we have everything we need? */
196+ if (*soname && *flag != FLAG_ELF)
197+ return 0;
198+ }
199+ }
200+
201+ /* We reach this point only if the file doesn't contain a DT_SONAME
202+ or if we can't classify the library. If it doesn't have a
203+ soname, return the name of the library. */
204+ if (*soname == NULL)
205+ *soname = xstrdup (lib);
206+
207+ return 0;
208+}
209+
210+int
211+process_elf_file64 (const char *file_name, const char *lib, int *flag,
212+ unsigned int *osversion, char **soname, void *file_contents,
213+ size_t file_length)
214+{
215+ int i;
216+ unsigned int j;
217+ Elf64_Addr loadaddr;
218+ unsigned int dynamic_addr;
219+ size_t dynamic_size;
220+ char *program_interpreter;
221+
222+ Elf64_Ehdr *elf_header;
223+ Elf64_Phdr *elf_pheader, *segment;
224+ Elf64_Dyn *dynamic_segment, *dyn_entry;
225+ char *dynamic_strings;
226+
227+ elf_header = (Elf64_Ehdr *) file_contents;
228+ *osversion = 0;
229+
230 if (elf_header->e_type != ET_DYN)
231 {
232 error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name,
233@@ -81,7 +254,7 @@ process_elf_file (const char *file_name,
234 }
235
236 /* Get information from elf program header. */
237- elf_pheader = (ElfW(Phdr) *) (elf_header->e_phoff + file_contents);
238+ elf_pheader = (Elf64_Phdr *) (elf_header->e_phoff + file_contents);
239 check_ptr (elf_pheader);
240
241 /* The library is an elf library, now search for soname and
242@@ -100,7 +273,7 @@ process_elf_file (const char *file_name,
243 switch (segment->p_type)
244 {
245 case PT_LOAD:
246- if (loadaddr == (ElfW(Addr)) -1)
247+ if (loadaddr == (Elf64_Addr) -1)
248 loadaddr = segment->p_vaddr - segment->p_offset;
249 break;
250
251@@ -129,16 +302,16 @@ process_elf_file (const char *file_name,
252 case PT_NOTE:
253 if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4)
254 {
255- ElfW(Word) *abi_note = (ElfW(Word) *) (file_contents
256+ Elf64_Word *abi_note = (Elf64_Word *) (file_contents
257 + segment->p_offset);
258- ElfW(Addr) size = segment->p_filesz;
259+ Elf64_Addr size = segment->p_filesz;
260
261 while (abi_note [0] != 4 || abi_note [1] != 16
262 || abi_note [2] != 1
263 || memcmp (abi_note + 3, "GNU", 4) != 0)
264 {
265-#define ROUND(len) (((len) + sizeof (ElfW(Word)) - 1) & -sizeof (ElfW(Word)))
266- ElfW(Addr) note_size = 3 * sizeof (ElfW(Word))
267+#define ROUND(len) (((len) + sizeof (Elf64_Word) - 1) & -sizeof (Elf64_Word))
268+ Elf64_Addr note_size = 3 * sizeof (Elf64_Word)
269 + ROUND (abi_note[0])
270 + ROUND (abi_note[1]);
271
272@@ -166,7 +339,7 @@ process_elf_file (const char *file_name,
273 }
274
275 }
276- if (loadaddr == (ElfW(Addr)) -1)
277+ if (loadaddr == (Elf64_Addr) -1)
278 {
279 /* Very strange. */
280 loadaddr = 0;
281@@ -176,7 +349,7 @@ process_elf_file (const char *file_name,
282 if (dynamic_size == 0)
283 return 1;
284
285- dynamic_segment = (ElfW(Dyn) *) (file_contents + dynamic_addr);
286+ dynamic_segment = (Elf64_Dyn *) (file_contents + dynamic_addr);
287 check_ptr (dynamic_segment);
288
289 /* Find the string table. */
290@@ -233,3 +406,33 @@ process_elf_file (const char *file_name,
291
292 return 0;
293 }
294+/* Returns 0 if everything is ok, != 0 in case of error. */
295+int
296+process_elf_file (const char *file_name, const char *lib, int *flag,
297+ unsigned int *osversion, char **soname, void *file_contents,
298+ size_t file_length)
299+{
300+ int i;
301+ unsigned int j;
302+ ElfW(Addr) loadaddr;
303+ unsigned int dynamic_addr;
304+ size_t dynamic_size;
305+ char *program_interpreter;
306+
307+ ElfW(Ehdr) *elf_header;
308+ ElfW(Phdr) *elf_pheader, *segment;
309+ ElfW(Dyn) *dynamic_segment, *dyn_entry;
310+ char *dynamic_strings;
311+
312+ elf_header = (ElfW(Ehdr) *) file_contents;
313+ *osversion = 0;
314+
315+ if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
316+ return process_elf_file32(file_name, lib,flag, osversion, soname, file_contents, file_length);
317+ else if (elf_header->e_ident [EI_CLASS] == ELFCLASS64)
318+ return process_elf_file64(file_name, lib,flag, osversion, soname, file_contents, file_length);
319+ error (0, 0, _("Unknown ELFCLASS in file %s.\n"), file_name);
320+ return 1;
321+}
322+
323+