summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/eglibc/ldconfig-native-2.12.1
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/eglibc/ldconfig-native-2.12.1')
-rw-r--r--meta/recipes-core/eglibc/ldconfig-native-2.12.1/32and64bit.patch331
-rw-r--r--meta/recipes-core/eglibc/ldconfig-native-2.12.1/README8
-rw-r--r--meta/recipes-core/eglibc/ldconfig-native-2.12.1/endian-ness_handling.patch454
-rw-r--r--meta/recipes-core/eglibc/ldconfig-native-2.12.1/endianess-header.patch113
-rw-r--r--meta/recipes-core/eglibc/ldconfig-native-2.12.1/flag_fix.patch24
-rw-r--r--meta/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig-native-2.12.1.tar.bz2bin0 -> 21491 bytes
-rw-r--r--meta/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig.patch471
-rw-r--r--meta/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig_aux-cache_path_fix.patch36
8 files changed, 1437 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..cdfeaeadd8
--- /dev/null
+++ b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/32and64bit.patch
@@ -0,0 +1,331 @@
1Upstream-Status: Inappropriate [embedded specific]
2
3We run the ldconfig in the cross fashion. make the code bitsize aware so that
4we can cross build ldconfig cache for various architectures.
5
6Richard Purdie <richard.purdie@linuxfoundation.org> 2009/05/19
7Nitin A Kamble <nitin.a.kamble@intel.com> 2009/03/29
8
9Index: ldconfig-native-2.12.1/readelflib.c
10===================================================================
11--- ldconfig-native-2.12.1.orig/readelflib.c
12+++ ldconfig-native-2.12.1/readelflib.c
13@@ -40,39 +40,212 @@ do \
14
15 /* Returns 0 if everything is ok, != 0 in case of error. */
16 int
17-process_elf_file (const char *file_name, const char *lib, int *flag,
18+process_elf_file32 (const char *file_name, const char *lib, int *flag,
19 unsigned int *osversion, char **soname, void *file_contents,
20 size_t file_length)
21 {
22 int i;
23 unsigned int j;
24- ElfW(Addr) loadaddr;
25+ Elf32_Addr loadaddr;
26 unsigned int dynamic_addr;
27 size_t dynamic_size;
28 char *program_interpreter;
29
30- ElfW(Ehdr) *elf_header;
31- ElfW(Phdr) *elf_pheader, *segment;
32- ElfW(Dyn) *dynamic_segment, *dyn_entry;
33+ Elf32_Ehdr *elf_header;
34+ Elf32_Phdr *elf_pheader, *segment;
35+ Elf32_Dyn *dynamic_segment, *dyn_entry;
36 char *dynamic_strings;
37
38- elf_header = (ElfW(Ehdr) *) file_contents;
39+ elf_header = (Elf32_Ehdr *) file_contents;
40 *osversion = 0;
41
42- if (elf_header->e_ident [EI_CLASS] != ElfW (CLASS))
43+ if (elf_header->e_type != ET_DYN)
44 {
45- if (opt_verbose)
46+ error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name,
47+ elf_header->e_type);
48+ return 1;
49+ }
50+
51+ /* Get information from elf program header. */
52+ elf_pheader = (Elf32_Phdr *) (elf_header->e_phoff + file_contents);
53+ check_ptr (elf_pheader);
54+
55+ /* The library is an elf library, now search for soname and
56+ libc5/libc6. */
57+ *flag = FLAG_ELF;
58+
59+ loadaddr = -1;
60+ dynamic_addr = 0;
61+ dynamic_size = 0;
62+ program_interpreter = NULL;
63+ for (i = 0, segment = elf_pheader;
64+ i < elf_header->e_phnum; i++, segment++)
65+ {
66+ check_ptr (segment);
67+
68+ switch (segment->p_type)
69 {
70- if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
71- error (0, 0, _("%s is a 32 bit ELF file.\n"), file_name);
72- else if (elf_header->e_ident [EI_CLASS] == ELFCLASS64)
73- error (0, 0, _("%s is a 64 bit ELF file.\n"), file_name);
74- else
75- error (0, 0, _("Unknown ELFCLASS in file %s.\n"), file_name);
76+ case PT_LOAD:
77+ if (loadaddr == (Elf32_Addr) -1)
78+ loadaddr = segment->p_vaddr - segment->p_offset;
79+ break;
80+
81+ case PT_DYNAMIC:
82+ if (dynamic_addr)
83+ error (0, 0, _("more than one dynamic segment\n"));
84+
85+ dynamic_addr = segment->p_offset;
86+ dynamic_size = segment->p_filesz;
87+ break;
88+
89+ case PT_INTERP:
90+ program_interpreter = (char *) (file_contents + segment->p_offset);
91+ check_ptr (program_interpreter);
92+
93+ /* Check if this is enough to classify the binary. */
94+ for (j = 0; j < sizeof (interpreters) / sizeof (interpreters [0]);
95+ ++j)
96+ if (strcmp (program_interpreter, interpreters[j].soname) == 0)
97+ {
98+ *flag = interpreters[j].flag;
99+ break;
100+ }
101+ break;
102+
103+ case PT_NOTE:
104+ if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4)
105+ {
106+ Elf32_Word *abi_note = (Elf32_Word *) (file_contents
107+ + segment->p_offset);
108+ Elf32_Addr size = segment->p_filesz;
109+
110+ while (abi_note [0] != 4 || abi_note [1] != 16
111+ || abi_note [2] != 1
112+ || memcmp (abi_note + 3, "GNU", 4) != 0)
113+ {
114+#define ROUND(len) (((len) + sizeof (Elf32_Word)) - 1) & -sizeof (Elf32_Word)))
115+ Elf32_Addr) note_size = 3 * sizeof (Elf32_Word))
116+ + ROUND (abi_note[0])
117+ + ROUND (abi_note[1]);
118+
119+ if (size - 32 < note_size || note_size == 0)
120+ {
121+ size = 0;
122+ break;
123+ }
124+ size -= note_size;
125+ abi_note = (void *) abi_note + note_size;
126+ }
127+
128+ if (size == 0)
129+ break;
130+
131+ *osversion = (abi_note [4] << 24) |
132+ ((abi_note [5] & 0xff) << 16) |
133+ ((abi_note [6] & 0xff) << 8) |
134+ (abi_note [7] & 0xff);
135+ }
136+ break;
137+
138+ default:
139+ break;
140+ }
141+
142+ }
143+ if (loadaddr == (Elf32_Addr) -1)
144+ {
145+ /* Very strange. */
146+ loadaddr = 0;
147+ }
148+
149+ /* Now we can read the dynamic sections. */
150+ if (dynamic_size == 0)
151+ return 1;
152+
153+ dynamic_segment = (Elf32_Dyn *) (file_contents + dynamic_addr);
154+ check_ptr (dynamic_segment);
155+
156+ /* Find the string table. */
157+ dynamic_strings = NULL;
158+ for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
159+ ++dyn_entry)
160+ {
161+ check_ptr (dyn_entry);
162+ if (dyn_entry->d_tag == DT_STRTAB)
163+ {
164+ dynamic_strings = (char *) (file_contents + dyn_entry->d_un.d_val - loadaddr);
165+ check_ptr (dynamic_strings);
166+ break;
167 }
168- return 1;
169 }
170
171+ if (dynamic_strings == NULL)
172+ return 1;
173+
174+ /* Now read the DT_NEEDED and DT_SONAME entries. */
175+ for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
176+ ++dyn_entry)
177+ {
178+ if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME)
179+ {
180+ char *name = dynamic_strings + dyn_entry->d_un.d_val;
181+ check_ptr (name);
182+
183+ if (dyn_entry->d_tag == DT_NEEDED)
184+ {
185+
186+ if (*flag == FLAG_ELF)
187+ {
188+ /* Check if this is enough to classify the binary. */
189+ for (j = 0;
190+ j < sizeof (known_libs) / sizeof (known_libs [0]);
191+ ++j)
192+ if (strcmp (name, known_libs [j].soname) == 0)
193+ {
194+ *flag = known_libs [j].flag;
195+ break;
196+ }
197+ }
198+ }
199+
200+ else if (dyn_entry->d_tag == DT_SONAME)
201+ *soname = xstrdup (name);
202+
203+ /* Do we have everything we need? */
204+ if (*soname && *flag != FLAG_ELF)
205+ return 0;
206+ }
207+ }
208+
209+ /* We reach this point only if the file doesn't contain a DT_SONAME
210+ or if we can't classify the library. If it doesn't have a
211+ soname, return the name of the library. */
212+ if (*soname == NULL)
213+ *soname = xstrdup (lib);
214+
215+ return 0;
216+}
217+
218+int
219+process_elf_file64 (const char *file_name, const char *lib, int *flag,
220+ unsigned int *osversion, char **soname, void *file_contents,
221+ size_t file_length)
222+{
223+ int i;
224+ unsigned int j;
225+ Elf64_Addr loadaddr;
226+ unsigned int dynamic_addr;
227+ size_t dynamic_size;
228+ char *program_interpreter;
229+
230+ Elf64_Ehdr *elf_header;
231+ Elf64_Phdr *elf_pheader, *segment;
232+ Elf64_Dyn *dynamic_segment, *dyn_entry;
233+ char *dynamic_strings;
234+
235+ elf_header = (Elf64_Ehdr *) file_contents;
236+ *osversion = 0;
237+
238 if (elf_header->e_type != ET_DYN)
239 {
240 error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name,
241@@ -81,7 +254,7 @@ process_elf_file (const char *file_name,
242 }
243
244 /* Get information from elf program header. */
245- elf_pheader = (ElfW(Phdr) *) (elf_header->e_phoff + file_contents);
246+ elf_pheader = (Elf64_Phdr *) (elf_header->e_phoff + file_contents);
247 check_ptr (elf_pheader);
248
249 /* The library is an elf library, now search for soname and
250@@ -100,7 +273,7 @@ process_elf_file (const char *file_name,
251 switch (segment->p_type)
252 {
253 case PT_LOAD:
254- if (loadaddr == (ElfW(Addr)) -1)
255+ if (loadaddr == (Elf64_Addr) -1)
256 loadaddr = segment->p_vaddr - segment->p_offset;
257 break;
258
259@@ -129,16 +302,16 @@ process_elf_file (const char *file_name,
260 case PT_NOTE:
261 if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4)
262 {
263- ElfW(Word) *abi_note = (ElfW(Word) *) (file_contents
264+ Elf64_Word *abi_note = (Elf64_Word *) (file_contents
265 + segment->p_offset);
266- ElfW(Addr) size = segment->p_filesz;
267+ Elf64_Addr size = segment->p_filesz;
268
269 while (abi_note [0] != 4 || abi_note [1] != 16
270 || abi_note [2] != 1
271 || memcmp (abi_note + 3, "GNU", 4) != 0)
272 {
273-#define ROUND(len) (((len) + sizeof (ElfW(Word)) - 1) & -sizeof (ElfW(Word)))
274- ElfW(Addr) note_size = 3 * sizeof (ElfW(Word))
275+#define ROUND(len) (((len) + sizeof (Elf64_Word) - 1) & -sizeof (Elf64_Word))
276+ Elf64_Addr note_size = 3 * sizeof (Elf64_Word)
277 + ROUND (abi_note[0])
278 + ROUND (abi_note[1]);
279
280@@ -166,7 +339,7 @@ process_elf_file (const char *file_name,
281 }
282
283 }
284- if (loadaddr == (ElfW(Addr)) -1)
285+ if (loadaddr == (Elf64_Addr) -1)
286 {
287 /* Very strange. */
288 loadaddr = 0;
289@@ -176,7 +349,7 @@ process_elf_file (const char *file_name,
290 if (dynamic_size == 0)
291 return 1;
292
293- dynamic_segment = (ElfW(Dyn) *) (file_contents + dynamic_addr);
294+ dynamic_segment = (Elf64_Dyn *) (file_contents + dynamic_addr);
295 check_ptr (dynamic_segment);
296
297 /* Find the string table. */
298@@ -233,3 +406,33 @@ process_elf_file (const char *file_name,
299
300 return 0;
301 }
302+/* Returns 0 if everything is ok, != 0 in case of error. */
303+int
304+process_elf_file (const char *file_name, const char *lib, int *flag,
305+ unsigned int *osversion, char **soname, void *file_contents,
306+ size_t file_length)
307+{
308+ int i;
309+ unsigned int j;
310+ ElfW(Addr) loadaddr;
311+ unsigned int dynamic_addr;
312+ size_t dynamic_size;
313+ char *program_interpreter;
314+
315+ ElfW(Ehdr) *elf_header;
316+ ElfW(Phdr) *elf_pheader, *segment;
317+ ElfW(Dyn) *dynamic_segment, *dyn_entry;
318+ char *dynamic_strings;
319+
320+ elf_header = (ElfW(Ehdr) *) file_contents;
321+ *osversion = 0;
322+
323+ if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
324+ return process_elf_file32(file_name, lib,flag, osversion, soname, file_contents, file_length);
325+ else if (elf_header->e_ident [EI_CLASS] == ELFCLASS64)
326+ return process_elf_file64(file_name, lib,flag, osversion, soname, file_contents, file_length);
327+ error (0, 0, _("Unknown ELFCLASS in file %s.\n"), file_name);
328+ return 1;
329+}
330+
331+
diff --git a/meta/recipes-core/eglibc/ldconfig-native-2.12.1/README b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/README
new file mode 100644
index 0000000000..43fb983729
--- /dev/null
+++ b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/README
@@ -0,0 +1,8 @@
1The files are pulled verbatim from glibc 2.5 and then patched to allow
2standalone compilation of ldconfig.
3
4Richard Purdie
5OpenedHand Ltd.
6
7Upgraded the ldconfig recipe to eglibc 2.12.1
8Nitin A Kamble <nitin.a.kamble@intel.com> 2011/03/29
diff --git a/meta/recipes-core/eglibc/ldconfig-native-2.12.1/endian-ness_handling.patch b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/endian-ness_handling.patch
new file mode 100644
index 0000000000..7f8e4db78a
--- /dev/null
+++ b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/endian-ness_handling.patch
@@ -0,0 +1,454 @@
1Upstream-Status: Inappropriate [embedded specific]
2
3Do data input/output handling according to endien-ness of the library file. That
4enables use of ldconfig in the cross fashion for any architecture.
5
62011/04/04
7Richard Purdie <richard.purdie@linuxfoundation.org>
8Nitin Kamble <nitin.a.kamble@intel.com>
9
10Index: ldconfig-native-2.12.1/readelflib.c
11===================================================================
12--- ldconfig-native-2.12.1.orig/readelflib.c
13+++ ldconfig-native-2.12.1/readelflib.c
14@@ -38,6 +38,28 @@ do \
15 } \
16 while (0);
17
18+int be;
19+static uint16_t read16(uint16_t x, int be)
20+{
21+ if (be)
22+ return be16toh(x);
23+ return le16toh(x);
24+}
25+
26+static uint32_t read32(uint32_t x, int be)
27+{
28+ if (be)
29+ return be32toh(x);
30+ return le32toh(x);
31+}
32+
33+static uint64_t read64(uint64_t x, int be)
34+{
35+ if (be)
36+ return be64toh(x);
37+ return le64toh(x);
38+}
39+
40 /* Returns 0 if everything is ok, != 0 in case of error. */
41 int
42 process_elf_file32 (const char *file_name, const char *lib, int *flag,
43@@ -59,15 +81,17 @@ process_elf_file32 (const char *file_nam
44 elf_header = (Elf32_Ehdr *) file_contents;
45 *osversion = 0;
46
47- if (elf_header->e_type != ET_DYN)
48+ be = (elf_header->e_ident[EI_DATA] == ELFDATA2MSB);
49+
50+ if (read16(elf_header->e_type, be) != ET_DYN)
51 {
52 error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name,
53- elf_header->e_type);
54+ read16(elf_header->e_type, be));
55 return 1;
56 }
57
58 /* Get information from elf program header. */
59- elf_pheader = (Elf32_Phdr *) (elf_header->e_phoff + file_contents);
60+ elf_pheader = (Elf32_Phdr *) (read32(elf_header->e_phoff, be) + file_contents);
61 check_ptr (elf_pheader);
62
63 /* The library is an elf library, now search for soname and
64@@ -79,27 +103,27 @@ process_elf_file32 (const char *file_nam
65 dynamic_size = 0;
66 program_interpreter = NULL;
67 for (i = 0, segment = elf_pheader;
68- i < elf_header->e_phnum; i++, segment++)
69+ i < read16(elf_header->e_phnum, be); i++, segment++)
70 {
71 check_ptr (segment);
72
73- switch (segment->p_type)
74+ switch (read32(segment->p_type, be))
75 {
76 case PT_LOAD:
77 if (loadaddr == (Elf32_Addr) -1)
78- loadaddr = segment->p_vaddr - segment->p_offset;
79+ loadaddr = read32(segment->p_vaddr, be) - read32(segment->p_offset, be);
80 break;
81
82 case PT_DYNAMIC:
83 if (dynamic_addr)
84 error (0, 0, _("more than one dynamic segment\n"));
85
86- dynamic_addr = segment->p_offset;
87- dynamic_size = segment->p_filesz;
88+ dynamic_addr = read32(segment->p_offset, be);
89+ dynamic_size = read32(segment->p_filesz, be);
90 break;
91
92 case PT_INTERP:
93- program_interpreter = (char *) (file_contents + segment->p_offset);
94+ program_interpreter = (char *) (file_contents + read32(segment->p_offset, be));
95 check_ptr (program_interpreter);
96
97 /* Check if this is enough to classify the binary. */
98@@ -113,20 +137,20 @@ process_elf_file32 (const char *file_nam
99 break;
100
101 case PT_NOTE:
102- if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4)
103+ if (!*osversion && read32(segment->p_filesz, be) >= 32 && segment->p_align >= 4)
104 {
105 Elf32_Word *abi_note = (Elf32_Word *) (file_contents
106- + segment->p_offset);
107- Elf32_Addr size = segment->p_filesz;
108+ + read32(segment->p_offset, be));
109+ Elf32_Addr size = read32(segment->p_filesz, be);
110
111- while (abi_note [0] != 4 || abi_note [1] != 16
112- || abi_note [2] != 1
113+ while (read32(abi_note [0], be) != 4 || read32(abi_note [1], be) != 16
114+ || read32(abi_note [2], be) != 1
115 || memcmp (abi_note + 3, "GNU", 4) != 0)
116 {
117-#define ROUND(len) (((len) + sizeof (Elf32_Word)) - 1) & -sizeof (Elf32_Word)))
118- Elf32_Addr) note_size = 3 * sizeof (Elf32_Word))
119- + ROUND (abi_note[0])
120- + ROUND (abi_note[1]);
121+#define ROUND(len) (((len) + sizeof (Elf32_Word) - 1) & -sizeof (Elf32_Word))
122+ Elf32_Addr note_size = 3 * sizeof (Elf32_Word)
123+ + ROUND (read32(abi_note[0], be))
124+ + ROUND (read32(abi_note[1], be));
125
126 if (size - 32 < note_size || note_size == 0)
127 {
128@@ -140,10 +164,10 @@ process_elf_file32 (const char *file_nam
129 if (size == 0)
130 break;
131
132- *osversion = (abi_note [4] << 24) |
133- ((abi_note [5] & 0xff) << 16) |
134- ((abi_note [6] & 0xff) << 8) |
135- (abi_note [7] & 0xff);
136+ *osversion = (read32(abi_note [4], be) << 24) |
137+ ((read32(abi_note [5], be) & 0xff) << 16) |
138+ ((read32(abi_note [6], be) & 0xff) << 8) |
139+ (read32(abi_note [7], be) & 0xff);
140 }
141 break;
142
143@@ -167,13 +191,13 @@ process_elf_file32 (const char *file_nam
144
145 /* Find the string table. */
146 dynamic_strings = NULL;
147- for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
148+ for (dyn_entry = dynamic_segment; read32(dyn_entry->d_tag, be) != DT_NULL;
149 ++dyn_entry)
150 {
151 check_ptr (dyn_entry);
152- if (dyn_entry->d_tag == DT_STRTAB)
153+ if (read32(dyn_entry->d_tag, be) == DT_STRTAB)
154 {
155- dynamic_strings = (char *) (file_contents + dyn_entry->d_un.d_val - loadaddr);
156+ dynamic_strings = (char *) (file_contents + read32(dyn_entry->d_un.d_val, be) - loadaddr);
157 check_ptr (dynamic_strings);
158 break;
159 }
160@@ -183,15 +207,15 @@ process_elf_file32 (const char *file_nam
161 return 1;
162
163 /* Now read the DT_NEEDED and DT_SONAME entries. */
164- for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
165+ for (dyn_entry = dynamic_segment; read32(dyn_entry->d_tag, be) != DT_NULL;
166 ++dyn_entry)
167 {
168- if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME)
169+ if (read32(dyn_entry->d_tag, be) == DT_NEEDED || read32(dyn_entry->d_tag, be) == DT_SONAME)
170 {
171- char *name = dynamic_strings + dyn_entry->d_un.d_val;
172+ char *name = dynamic_strings + read32(dyn_entry->d_un.d_val, be);
173 check_ptr (name);
174
175- if (dyn_entry->d_tag == DT_NEEDED)
176+ if (read32(dyn_entry->d_tag, be) == DT_NEEDED)
177 {
178
179 if (*flag == FLAG_ELF)
180@@ -208,7 +232,7 @@ process_elf_file32 (const char *file_nam
181 }
182 }
183
184- else if (dyn_entry->d_tag == DT_SONAME)
185+ else if (read32(dyn_entry->d_tag, be) == DT_SONAME)
186 *soname = xstrdup (name);
187
188 /* Do we have everything we need? */
189@@ -246,15 +270,17 @@ process_elf_file64 (const char *file_nam
190 elf_header = (Elf64_Ehdr *) file_contents;
191 *osversion = 0;
192
193- if (elf_header->e_type != ET_DYN)
194+ be = (elf_header->e_ident[EI_DATA] == ELFDATA2MSB);
195+
196+ if (read16(elf_header->e_type, be) != ET_DYN)
197 {
198 error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name,
199- elf_header->e_type);
200+ read16(elf_header->e_type, be));
201 return 1;
202 }
203
204 /* Get information from elf program header. */
205- elf_pheader = (Elf64_Phdr *) (elf_header->e_phoff + file_contents);
206+ elf_pheader = (Elf64_Phdr *) (read64(elf_header->e_phoff, be) + file_contents);
207 check_ptr (elf_pheader);
208
209 /* The library is an elf library, now search for soname and
210@@ -266,27 +292,27 @@ process_elf_file64 (const char *file_nam
211 dynamic_size = 0;
212 program_interpreter = NULL;
213 for (i = 0, segment = elf_pheader;
214- i < elf_header->e_phnum; i++, segment++)
215+ i < read16(elf_header->e_phnum, be); i++, segment++)
216 {
217 check_ptr (segment);
218
219- switch (segment->p_type)
220+ switch (read32(segment->p_type, be))
221 {
222 case PT_LOAD:
223 if (loadaddr == (Elf64_Addr) -1)
224- loadaddr = segment->p_vaddr - segment->p_offset;
225+ loadaddr = read64(segment->p_vaddr, be) - read64(segment->p_offset, be);
226 break;
227
228 case PT_DYNAMIC:
229 if (dynamic_addr)
230 error (0, 0, _("more than one dynamic segment\n"));
231
232- dynamic_addr = segment->p_offset;
233- dynamic_size = segment->p_filesz;
234+ dynamic_addr = read64(segment->p_offset, be);
235+ dynamic_size = read32(segment->p_filesz, be);
236 break;
237
238 case PT_INTERP:
239- program_interpreter = (char *) (file_contents + segment->p_offset);
240+ program_interpreter = (char *) (file_contents + read64(segment->p_offset, be));
241 check_ptr (program_interpreter);
242
243 /* Check if this is enough to classify the binary. */
244@@ -300,20 +326,21 @@ process_elf_file64 (const char *file_nam
245 break;
246
247 case PT_NOTE:
248- if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4)
249+ if (!*osversion && read32(segment->p_filesz, be) >= 32 && read32(segment->p_align, be) >= 4)
250 {
251 Elf64_Word *abi_note = (Elf64_Word *) (file_contents
252- + segment->p_offset);
253- Elf64_Addr size = segment->p_filesz;
254+ + read64(segment->p_offset, be));
255+ Elf64_Addr size = read32(segment->p_filesz, be);
256
257- while (abi_note [0] != 4 || abi_note [1] != 16
258- || abi_note [2] != 1
259+ while (read32(abi_note [0], be) != 4 || read32(abi_note [1], be) != 16
260+ || read32(abi_note [2], be) != 1
261 || memcmp (abi_note + 3, "GNU", 4) != 0)
262 {
263+#undef ROUND
264 #define ROUND(len) (((len) + sizeof (Elf64_Word) - 1) & -sizeof (Elf64_Word))
265 Elf64_Addr note_size = 3 * sizeof (Elf64_Word)
266- + ROUND (abi_note[0])
267- + ROUND (abi_note[1]);
268+ + ROUND (read32(abi_note[0], be))
269+ + ROUND (read32(abi_note[1], be));
270
271 if (size - 32 < note_size || note_size == 0)
272 {
273@@ -327,10 +354,10 @@ process_elf_file64 (const char *file_nam
274 if (size == 0)
275 break;
276
277- *osversion = (abi_note [4] << 24) |
278- ((abi_note [5] & 0xff) << 16) |
279- ((abi_note [6] & 0xff) << 8) |
280- (abi_note [7] & 0xff);
281+ *osversion = (read32(abi_note [4], be) << 24) |
282+ ((read32(abi_note [5], be) & 0xff) << 16) |
283+ ((read32(abi_note [6], be) & 0xff) << 8) |
284+ (read32(abi_note [7], be) & 0xff);
285 }
286 break;
287
288@@ -354,13 +381,13 @@ process_elf_file64 (const char *file_nam
289
290 /* Find the string table. */
291 dynamic_strings = NULL;
292- for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
293+ for (dyn_entry = dynamic_segment; read64(dyn_entry->d_tag, be) != DT_NULL;
294 ++dyn_entry)
295 {
296 check_ptr (dyn_entry);
297- if (dyn_entry->d_tag == DT_STRTAB)
298+ if (read64(dyn_entry->d_tag, be) == DT_STRTAB)
299 {
300- dynamic_strings = (char *) (file_contents + dyn_entry->d_un.d_val - loadaddr);
301+ dynamic_strings = (char *) (file_contents + read64(dyn_entry->d_un.d_val, be) - loadaddr);
302 check_ptr (dynamic_strings);
303 break;
304 }
305@@ -370,15 +397,15 @@ process_elf_file64 (const char *file_nam
306 return 1;
307
308 /* Now read the DT_NEEDED and DT_SONAME entries. */
309- for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
310+ for (dyn_entry = dynamic_segment; read64(dyn_entry->d_tag, be) != DT_NULL;
311 ++dyn_entry)
312 {
313- if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME)
314+ if (read64(dyn_entry->d_tag, be) == DT_NEEDED || read64(dyn_entry->d_tag, be) == DT_SONAME)
315 {
316- char *name = dynamic_strings + dyn_entry->d_un.d_val;
317+ char *name = dynamic_strings + read64(dyn_entry->d_un.d_val, be);
318 check_ptr (name);
319
320- if (dyn_entry->d_tag == DT_NEEDED)
321+ if (read64(dyn_entry->d_tag, be) == DT_NEEDED)
322 {
323
324 if (*flag == FLAG_ELF)
325@@ -395,7 +422,7 @@ process_elf_file64 (const char *file_nam
326 }
327 }
328
329- else if (dyn_entry->d_tag == DT_SONAME)
330+ else if (read64(dyn_entry->d_tag, be) == DT_SONAME)
331 *soname = xstrdup (name);
332
333 /* Do we have everything we need? */
334Index: ldconfig-native-2.12.1/readlib.c
335===================================================================
336--- ldconfig-native-2.12.1.orig/readlib.c
337+++ ldconfig-native-2.12.1/readlib.c
338@@ -169,7 +169,8 @@ process_file (const char *real_file_name
339 ret = 1;
340 }
341 /* Libraries have to be shared object files. */
342- else if (elf_header->e_type != ET_DYN)
343+ else if ((elf_header->e_ident[EI_DATA] == ELFDATA2MSB && be16toh(elf_header->e_type) != ET_DYN) ||
344+ (elf_header->e_ident[EI_DATA] == ELFDATA2LSB && le16toh(elf_header->e_type) != ET_DYN))
345 ret = 1;
346 else if (process_elf_file (file_name, lib, flag, osversion, soname,
347 file_contents, statbuf.st_size))
348Index: ldconfig-native-2.12.1/cache.c
349===================================================================
350--- ldconfig-native-2.12.1.orig/cache.c
351+++ ldconfig-native-2.12.1/cache.c
352@@ -39,6 +39,29 @@
353 # define N_(msgid) msgid
354 #define _(msg) msg
355
356+extern int be;
357+
358+static uint16_t write16(uint16_t x, int be)
359+{
360+ if (be)
361+ return htobe16(x);
362+ return htole16(x);
363+}
364+
365+static uint32_t write32(uint32_t x, int be)
366+{
367+ if (be)
368+ return htobe32(x);
369+ return htole32(x);
370+}
371+
372+static uint64_t write64(uint64_t x, int be)
373+{
374+ if (be)
375+ return htobe64(x);
376+ return htole64(x);
377+}
378+
379 struct cache_entry
380 {
381 char *lib; /* Library name. */
382@@ -279,7 +302,12 @@ save_cache (const char *cache_name)
383 /* Number of normal cache entries. */
384 int cache_entry_old_count = 0;
385
386- for (entry = entries; entry != NULL; entry = entry->next)
387+ if (be)
388+ printf("saving cache in big endian encoding\n");
389+ else
390+ printf("saving cache in little endian encoding\n");
391+
392+ for (entry = entries; entry != NULL; entry = entry->next)
393 {
394 /* Account the final NULs. */
395 total_strlen += strlen (entry->lib) + strlen (entry->path) + 2;
396@@ -310,7 +338,7 @@ save_cache (const char *cache_name)
397 memset (file_entries, '\0', sizeof (struct cache_file));
398 memcpy (file_entries->magic, CACHEMAGIC, sizeof CACHEMAGIC - 1);
399
400- file_entries->nlibs = cache_entry_old_count;
401+ file_entries->nlibs = write32(cache_entry_old_count, be);
402 }
403
404 struct cache_file_new *file_entries_new = NULL;
405@@ -330,8 +358,8 @@ save_cache (const char *cache_name)
406 memcpy (file_entries_new->version, CACHE_VERSION,
407 sizeof CACHE_VERSION - 1);
408
409- file_entries_new->nlibs = cache_entry_count;
410- file_entries_new->len_strings = total_strlen;
411+ file_entries_new->nlibs = write32(cache_entry_count, be);
412+ file_entries_new->len_strings = write32(total_strlen, be);
413 }
414
415 /* Pad for alignment of cache_file_new. */
416@@ -358,9 +386,9 @@ save_cache (const char *cache_name)
417 /* First the library. */
418 if (opt_format != 2 && entry->hwcap == 0)
419 {
420- file_entries->libs[idx_old].flags = entry->flags;
421+ file_entries->libs[idx_old].flags = write32(entry->flags, be);
422 /* XXX: Actually we can optimize here and remove duplicates. */
423- file_entries->libs[idx_old].key = str_offset + pad;
424+ file_entries->libs[idx_old].key = write32(str_offset + pad, be);
425 }
426 if (opt_format != 0)
427 {
428@@ -368,10 +396,10 @@ save_cache (const char *cache_name)
429 not doing so makes the code easier, the string table
430 always begins at the beginning of the the new cache
431 struct. */
432- file_entries_new->libs[idx_new].flags = entry->flags;
433- file_entries_new->libs[idx_new].osversion = entry->osversion;
434- file_entries_new->libs[idx_new].hwcap = entry->hwcap;
435- file_entries_new->libs[idx_new].key = str_offset;
436+ file_entries_new->libs[idx_new].flags = write32(entry->flags, be);
437+ file_entries_new->libs[idx_new].osversion = write32(entry->osversion, be);
438+ file_entries_new->libs[idx_new].hwcap = write64(entry->hwcap, be);
439+ file_entries_new->libs[idx_new].key = write32(str_offset, be);
440 }
441
442 size_t len = strlen (entry->lib) + 1;
443@@ -379,9 +407,9 @@ save_cache (const char *cache_name)
444 str_offset += len;
445 /* Then the path. */
446 if (opt_format != 2 && entry->hwcap == 0)
447- file_entries->libs[idx_old].value = str_offset + pad;
448+ file_entries->libs[idx_old].value = write32(str_offset + pad, be);
449 if (opt_format != 0)
450- file_entries_new->libs[idx_new].value = str_offset;
451+ file_entries_new->libs[idx_new].value = write32(str_offset, be);
452 len = strlen (entry->path) + 1;
453 str = mempcpy (str, entry->path, len);
454 str_offset += len;
diff --git a/meta/recipes-core/eglibc/ldconfig-native-2.12.1/endianess-header.patch b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/endianess-header.patch
new file mode 100644
index 0000000000..a18b2c20de
--- /dev/null
+++ b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/endianess-header.patch
@@ -0,0 +1,113 @@
1Upstream-Status: Inappropriate [fix poky patch]
2
3This patch fixes build issues with a previous endian-ness_handling.patch on
4distros that don't have macros referenced
5
67/20/2011
7Matthew McClintock <msm@freescale.com>
8
9diff -purN ldconfig-native-2.12.1.orig/endian_extra.h ldconfig-native-2.12.1/endian_extra.h
10--- ldconfig-native-2.12.1.orig/endian_extra.h 1969-12-31 18:00:00.000000000 -0600
11+++ ldconfig-native-2.12.1/endian_extra.h 2011-07-19 18:09:14.323048417 -0500
12@@ -0,0 +1,64 @@
13+/* Copyright (C) 1992, 1996, 1997, 2000, 2008 Free Software Foundation, Inc.
14+ This file is part of the GNU C Library.
15+
16+ The GNU C Library is free software; you can redistribute it and/or
17+ modify it under the terms of the GNU Lesser General Public
18+ License as published by the Free Software Foundation; either
19+ version 2.1 of the License, or (at your option) any later version.
20+
21+ The GNU C Library is distributed in the hope that it will be useful,
22+ but WITHOUT ANY WARRANTY; without even the implied warranty of
23+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24+ Lesser General Public License for more details.
25+
26+ You should have received a copy of the GNU Lesser General Public
27+ License along with the GNU C Library; if not, write to the Free
28+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
29+ 02111-1307 USA. */
30+
31+#include <endian.h>
32+
33+#ifndef _ENDIAN_EXTRA_H
34+#define _ENDIAN_EXTRA_H 1
35+
36+/* Don't redefine these macros if they already exist */
37+#ifndef htobe16
38+#ifdef __USE_BSD
39+/* Conversion interfaces. */
40+# include <byteswap.h>
41+
42+# if __BYTE_ORDER == __LITTLE_ENDIAN
43+# define htobe16(x) __bswap_16 (x)
44+# define htole16(x) (x)
45+# define be16toh(x) __bswap_16 (x)
46+# define le16toh(x) (x)
47+
48+# define htobe32(x) __bswap_32 (x)
49+# define htole32(x) (x)
50+# define be32toh(x) __bswap_32 (x)
51+# define le32toh(x) (x)
52+
53+# define htobe64(x) __bswap_64 (x)
54+# define htole64(x) (x)
55+# define be64toh(x) __bswap_64 (x)
56+# define le64toh(x) (x)
57+# else
58+# define htobe16(x) (x)
59+# define htole16(x) __bswap_16 (x)
60+# define be16toh(x) (x)
61+# define le16toh(x) __bswap_16 (x)
62+
63+# define htobe32(x) (x)
64+# define htole32(x) __bswap_32 (x)
65+# define be32toh(x) (x)
66+# define le32toh(x) __bswap_32 (x)
67+
68+# define htobe64(x) (x)
69+# define htole64(x) __bswap_64 (x)
70+# define be64toh(x) (x)
71+# define le64toh(x) __bswap_64 (x)
72+# endif
73+#endif
74+#endif
75+
76+#endif /* endian_extra.h */
77diff -purN ldconfig-native-2.12.1.orig/cache.c ldconfig-native-2.12.1/cache.c
78--- ldconfig-native-2.12.1.orig/cache.c 2011-07-19 18:21:28.347041301 -0500
79+++ ldconfig-native-2.12.1/cache.c 2011-07-19 18:22:54.118048064 -0500
80@@ -39,6 +39,8 @@
81 # define N_(msgid) msgid
82 #define _(msg) msg
83
84+#include "endian_extra.h"
85+
86 extern int be;
87
88 static uint16_t write16(uint16_t x, int be)
89diff -purN ldconfig-native-2.12.1.orig/readelflib.c ldconfig-native-2.12.1/readelflib.c
90--- ldconfig-native-2.12.1.orig/readelflib.c 2011-07-19 18:21:28.346041593 -0500
91+++ ldconfig-native-2.12.1/readelflib.c 2011-07-19 18:23:05.324059875 -0500
92@@ -25,6 +25,9 @@
93
94 /* check_ptr checks that a pointer is in the mmaped file and doesn't
95 point outside it. */
96+
97+#include "endian_extra.h"
98+
99 #undef check_ptr
100 #define check_ptr(ptr) \
101 do \
102diff -purN ldconfig-native-2.12.1.orig/readlib.c ldconfig-native-2.12.1/readlib.c
103--- ldconfig-native-2.12.1.orig/readlib.c 2011-07-19 18:21:28.346041593 -0500
104+++ ldconfig-native-2.12.1/readlib.c 2011-07-19 18:23:23.877046210 -0500
105@@ -40,6 +40,8 @@
106
107 #include "ldconfig.h"
108
109+#include "endian_extra.h"
110+
111 #define _(msg) msg
112
113 #define Elf32_CLASS ELFCLASS32
diff --git a/meta/recipes-core/eglibc/ldconfig-native-2.12.1/flag_fix.patch b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/flag_fix.patch
new file mode 100644
index 0000000000..4e9aab9416
--- /dev/null
+++ b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/flag_fix.patch
@@ -0,0 +1,24 @@
1Upstream-Status: Inappropriate [embedded specific]
2
3The native version of ldconfig was using native definition of LD_SO (i.e.
4ld-linux-x86-64.so.2 ) which is not correct for doing the cross ldconfig.
5This was causing libc.so on the target marked as ELF lib rather than
6FLAG_ELF_LIBC6 in the ld.so.cache.
7
8Nitin A Kamble <nitin.a.kamble@intel.com> 2011/04/4
9
10Index: ldconfig-native-2.12.1/readlib.c
11===================================================================
12--- ldconfig-native-2.12.1.orig/readlib.c
13+++ ldconfig-native-2.12.1/readlib.c
14@@ -51,6 +51,10 @@ struct known_names
15 int flag;
16 };
17
18+/* don't use host's definition of LD_SO */
19+#undef LD_SO
20+#define LD_SO "ld.so.1"
21+
22 static struct known_names interpreters[] =
23 {
24 { "/lib/" LD_SO, FLAG_ELF_LIBC6 },
diff --git a/meta/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig-native-2.12.1.tar.bz2 b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig-native-2.12.1.tar.bz2
new file mode 100644
index 0000000000..dc1e79888e
--- /dev/null
+++ b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig-native-2.12.1.tar.bz2
Binary files differ
diff --git a/meta/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig.patch b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig.patch
new file mode 100644
index 0000000000..52986e61c7
--- /dev/null
+++ b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig.patch
@@ -0,0 +1,471 @@
1Upstream-Status: Inappropriate [embedded specific]
2
3enable standalone building of ldconfig
4
5---
6 cache.c | 11 +-
7 chroot_canon.c | 7 +
8 dl-cache.c | 235 ---------------------------------------------------------
9 dl-cache.h | 3
10 ldconfig.c | 27 ++++--
11 readlib.c | 7 +
12 xstrdup.c | 11 --
13 7 files changed, 45 insertions(+), 256 deletions(-)
14
15Index: ldconfig-native-2.12.1/cache.c
16===================================================================
17--- ldconfig-native-2.12.1.orig/cache.c
18+++ ldconfig-native-2.12.1/cache.c
19@@ -16,6 +16,9 @@
20 along with this program; if not, write to the Free Software Foundation,
21 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22
23+#define _LARGEFILE64_SOURCE
24+#define _GNU_SOURCE
25+
26 #include <errno.h>
27 #include <error.h>
28 #include <dirent.h>
29@@ -31,8 +34,10 @@
30 #include <sys/stat.h>
31 #include <sys/types.h>
32
33-#include <ldconfig.h>
34-#include <dl-cache.h>
35+#include "ldconfig.h"
36+#include "dl-cache.h"
37+# define N_(msgid) msgid
38+#define _(msg) msg
39
40 struct cache_entry
41 {
42Index: ldconfig-native-2.12.1/chroot_canon.c
43===================================================================
44--- ldconfig-native-2.12.1.orig/chroot_canon.c
45+++ ldconfig-native-2.12.1/chroot_canon.c
46@@ -17,6 +17,9 @@
47 along with this program; if not, write to the Free Software Foundation,
48 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
49
50+#define _LARGEFILE64_SOURCE
51+#define _GNU_SOURCE
52+
53 #include <stdlib.h>
54 #include <string.h>
55 #include <unistd.h>
56@@ -27,7 +30,9 @@
57 #include <stddef.h>
58 #include <stdint.h>
59
60-#include <ldconfig.h>
61+#include "ldconfig.h"
62+
63+#define __set_errno(Val) errno = (Val)
64
65 #ifndef PATH_MAX
66 #define PATH_MAX 1024
67Index: ldconfig-native-2.12.1/dl-cache.c
68===================================================================
69--- ldconfig-native-2.12.1.orig/dl-cache.c
70+++ ldconfig-native-2.12.1/dl-cache.c
71@@ -20,12 +20,12 @@
72
73 #include <assert.h>
74 #include <unistd.h>
75-#include <ldsodefs.h>
76+//#include "ldsodefs.h"
77 #include <sys/mman.h>
78 #include <dl-cache.h>
79 #include <dl-procinfo.h>
80
81-#include <stdio-common/_itoa.h>
82+//#include "_itoa.h"
83
84 #ifndef _DL_PLATFORMS_COUNT
85 # define _DL_PLATFORMS_COUNT 0
86@@ -39,103 +39,7 @@ static size_t cachesize;
87 /* 1 if cache_data + PTR points into the cache. */
88 #define _dl_cache_verify_ptr(ptr) (ptr < cache_data_size)
89
90-#define SEARCH_CACHE(cache) \
91-/* We use binary search since the table is sorted in the cache file. \
92- The first matching entry in the table is returned. \
93- It is important to use the same algorithm as used while generating \
94- the cache file. */ \
95-do \
96- { \
97- left = 0; \
98- right = cache->nlibs - 1; \
99- \
100- while (left <= right) \
101- { \
102- __typeof__ (cache->libs[0].key) key; \
103- \
104- middle = (left + right) / 2; \
105- \
106- key = cache->libs[middle].key; \
107- \
108- /* Make sure string table indices are not bogus before using \
109- them. */ \
110- if (! _dl_cache_verify_ptr (key)) \
111- { \
112- cmpres = 1; \
113- break; \
114- } \
115- \
116- /* Actually compare the entry with the key. */ \
117- cmpres = _dl_cache_libcmp (name, cache_data + key); \
118- if (__builtin_expect (cmpres == 0, 0)) \
119- { \
120- /* Found it. LEFT now marks the last entry for which we \
121- know the name is correct. */ \
122- left = middle; \
123- \
124- /* There might be entries with this name before the one we \
125- found. So we have to find the beginning. */ \
126- while (middle > 0) \
127- { \
128- __typeof__ (cache->libs[0].key) key; \
129- \
130- key = cache->libs[middle - 1].key; \
131- /* Make sure string table indices are not bogus before \
132- using them. */ \
133- if (! _dl_cache_verify_ptr (key) \
134- /* Actually compare the entry. */ \
135- || _dl_cache_libcmp (name, cache_data + key) != 0) \
136- break; \
137- --middle; \
138- } \
139- \
140- do \
141- { \
142- int flags; \
143- __typeof__ (cache->libs[0]) *lib = &cache->libs[middle]; \
144- \
145- /* Only perform the name test if necessary. */ \
146- if (middle > left \
147- /* We haven't seen this string so far. Test whether the \
148- index is ok and whether the name matches. Otherwise \
149- we are done. */ \
150- && (! _dl_cache_verify_ptr (lib->key) \
151- || (_dl_cache_libcmp (name, cache_data + lib->key) \
152- != 0))) \
153- break; \
154- \
155- flags = lib->flags; \
156- if (_dl_cache_check_flags (flags) \
157- && _dl_cache_verify_ptr (lib->value)) \
158- { \
159- if (best == NULL || flags == GLRO(dl_correct_cache_id)) \
160- { \
161- HWCAP_CHECK; \
162- best = cache_data + lib->value; \
163- \
164- if (flags == GLRO(dl_correct_cache_id)) \
165- /* We've found an exact match for the shared \
166- object and no general `ELF' release. Stop \
167- searching. */ \
168- break; \
169- } \
170- } \
171- } \
172- while (++middle <= right); \
173- break; \
174- } \
175- \
176- if (cmpres < 0) \
177- left = middle + 1; \
178- else \
179- right = middle - 1; \
180- } \
181- } \
182-while (0)
183-
184-
185 int
186-internal_function
187 _dl_cache_libcmp (const char *p1, const char *p2)
188 {
189 while (*p1 != '\0')
190@@ -172,139 +76,3 @@ _dl_cache_libcmp (const char *p1, const
191 }
192 return *p1 - *p2;
193 }
194-
195-
196-/* Look up NAME in ld.so.cache and return the file name stored there,
197- or null if none is found. */
198-
199-const char *
200-internal_function
201-_dl_load_cache_lookup (const char *name)
202-{
203- int left, right, middle;
204- int cmpres;
205- const char *cache_data;
206- uint32_t cache_data_size;
207- const char *best;
208-
209- /* Print a message if the loading of libs is traced. */
210- if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0))
211- _dl_debug_printf (" search cache=%s\n", LD_SO_CACHE);
212-
213- if (cache == NULL)
214- {
215- /* Read the contents of the file. */
216- void *file = _dl_sysdep_read_whole_file (LD_SO_CACHE, &cachesize,
217- PROT_READ);
218-
219- /* We can handle three different cache file formats here:
220- - the old libc5/glibc2.0/2.1 format
221- - the old format with the new format in it
222- - only the new format
223- The following checks if the cache contains any of these formats. */
224- if (file != MAP_FAILED && cachesize > sizeof *cache
225- && memcmp (file, CACHEMAGIC, sizeof CACHEMAGIC - 1) == 0)
226- {
227- size_t offset;
228- /* Looks ok. */
229- cache = file;
230-
231- /* Check for new version. */
232- offset = ALIGN_CACHE (sizeof (struct cache_file)
233- + cache->nlibs * sizeof (struct file_entry));
234-
235- cache_new = (struct cache_file_new *) ((void *) cache + offset);
236- if (cachesize < (offset + sizeof (struct cache_file_new))
237- || memcmp (cache_new->magic, CACHEMAGIC_VERSION_NEW,
238- sizeof CACHEMAGIC_VERSION_NEW - 1) != 0)
239- cache_new = (void *) -1;
240- }
241- else if (file != MAP_FAILED && cachesize > sizeof *cache_new
242- && memcmp (file, CACHEMAGIC_VERSION_NEW,
243- sizeof CACHEMAGIC_VERSION_NEW - 1) == 0)
244- {
245- cache_new = file;
246- cache = file;
247- }
248- else
249- {
250- if (file != MAP_FAILED)
251- __munmap (file, cachesize);
252- cache = (void *) -1;
253- }
254-
255- assert (cache != NULL);
256- }
257-
258- if (cache == (void *) -1)
259- /* Previously looked for the cache file and didn't find it. */
260- return NULL;
261-
262- best = NULL;
263-
264- if (cache_new != (void *) -1)
265- {
266- uint64_t platform;
267-
268- /* This is where the strings start. */
269- cache_data = (const char *) cache_new;
270-
271- /* Now we can compute how large the string table is. */
272- cache_data_size = (const char *) cache + cachesize - cache_data;
273-
274- platform = _dl_string_platform (GLRO(dl_platform));
275- if (platform != (uint64_t) -1)
276- platform = 1ULL << platform;
277-
278-#define _DL_HWCAP_TLS_MASK (1LL << 63)
279- uint64_t hwcap_exclude = ~((GLRO(dl_hwcap) & GLRO(dl_hwcap_mask))
280- | _DL_HWCAP_PLATFORM | _DL_HWCAP_TLS_MASK);
281-
282- /* Only accept hwcap if it's for the right platform. */
283-#define HWCAP_CHECK \
284- if (lib->hwcap & hwcap_exclude) \
285- continue; \
286- if (GLRO(dl_osversion) && lib->osversion > GLRO(dl_osversion)) \
287- continue; \
288- if (_DL_PLATFORMS_COUNT \
289- && (lib->hwcap & _DL_HWCAP_PLATFORM) != 0 \
290- && (lib->hwcap & _DL_HWCAP_PLATFORM) != platform) \
291- continue
292- SEARCH_CACHE (cache_new);
293- }
294- else
295- {
296- /* This is where the strings start. */
297- cache_data = (const char *) &cache->libs[cache->nlibs];
298-
299- /* Now we can compute how large the string table is. */
300- cache_data_size = (const char *) cache + cachesize - cache_data;
301-
302-#undef HWCAP_CHECK
303-#define HWCAP_CHECK do {} while (0)
304- SEARCH_CACHE (cache);
305- }
306-
307- /* Print our result if wanted. */
308- if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0)
309- && best != NULL)
310- _dl_debug_printf (" trying file=%s\n", best);
311-
312- return best;
313-}
314-
315-#ifndef MAP_COPY
316-/* If the system does not support MAP_COPY we cannot leave the file open
317- all the time since this would create problems when the file is replaced.
318- Therefore we provide this function to close the file and open it again
319- once needed. */
320-void
321-_dl_unload_cache (void)
322-{
323- if (cache != NULL && cache != (struct cache_file *) -1)
324- {
325- __munmap (cache, cachesize);
326- cache = NULL;
327- }
328-}
329-#endif
330Index: ldconfig-native-2.12.1/dl-cache.h
331===================================================================
332--- ldconfig-native-2.12.1.orig/dl-cache.h
333+++ ldconfig-native-2.12.1/dl-cache.h
334@@ -101,5 +101,4 @@ struct cache_file_new
335 (((addr) + __alignof__ (struct cache_file_new) -1) \
336 & (~(__alignof__ (struct cache_file_new) - 1)))
337
338-extern int _dl_cache_libcmp (const char *p1, const char *p2)
339- internal_function;
340+extern int _dl_cache_libcmp (const char *p1, const char *p2);
341Index: ldconfig-native-2.12.1/ldconfig.c
342===================================================================
343--- ldconfig-native-2.12.1.orig/ldconfig.c
344+++ ldconfig-native-2.12.1/ldconfig.c
345@@ -16,6 +16,9 @@
346 along with this program; if not, write to the Free Software Foundation,
347 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
348
349+#define _LARGEFILE64_SOURCE
350+#define _GNU_SOURCE
351+
352 #define PROCINFO_CLASS static
353 #include <alloca.h>
354 #include <argp.h>
355@@ -39,10 +42,20 @@
356 #include <glob.h>
357 #include <libgen.h>
358
359-#include <ldconfig.h>
360-#include <dl-cache.h>
361+#include "ldconfig.h"
362+#include "dl-cache.h"
363+
364+#include "dl-procinfo.h"
365+
366+#include "argp.h"
367+
368+
369+#define SYSCONFDIR "/etc"
370+#define LIBDIR "/usr/lib"
371+#define SLIBDIR "/lib"
372+# define N_(msgid) msgid
373+#define _(msg) msg
374
375-#include <dl-procinfo.h>
376
377 #ifdef _DL_FIRST_PLATFORM
378 # define _DL_FIRST_EXTRA (_DL_FIRST_PLATFORM + _DL_PLATFORMS_COUNT)
379@@ -55,7 +68,7 @@
380 #endif
381
382 /* Get libc version number. */
383-#include <version.h>
384+#include "version.h"
385
386 #define PACKAGE _libc_intl_domainname
387
388@@ -152,8 +165,8 @@ static const struct argp_option options[
389 { NULL, 0, NULL, 0, NULL, 0 }
390 };
391
392-#define PROCINFO_CLASS static
393-#include <dl-procinfo.c>
394+//#define PROCINFO_CLASS static
395+//#include <dl-procinfo.c>
396
397 /* Short description of program. */
398 static const char doc[] = N_("Configure Dynamic Linker Run Time Bindings.");
399@@ -291,6 +304,7 @@ parse_opt (int key, char *arg, struct ar
400 return 0;
401 }
402
403+#define REPORT_BUGS_TO "mailing list : poky@yoctoproject.org"
404 /* Print bug-reporting information in the help message. */
405 static char *
406 more_help (int key, const char *text, void *input)
407@@ -315,7 +329,7 @@ For bug reporting instructions, please s
408 static void
409 print_version (FILE *stream, struct argp_state *state)
410 {
411- fprintf (stream, "ldconfig %s%s\n", PKGVERSION, VERSION);
412+ fprintf (stream, "ldconfig (Hacked Poky Version)\n");
413 fprintf (stream, gettext ("\
414 Copyright (C) %s Free Software Foundation, Inc.\n\
415 This is free software; see the source for copying conditions. There is NO\n\
416@@ -1233,6 +1247,7 @@ set_hwcap (void)
417 hwcap_mask = strtoul (mask, NULL, 0);
418 }
419
420+const char _libc_intl_domainname[] = "libc";
421
422 int
423 main (int argc, char **argv)
424Index: ldconfig-native-2.12.1/readlib.c
425===================================================================
426--- ldconfig-native-2.12.1.orig/readlib.c
427+++ ldconfig-native-2.12.1/readlib.c
428@@ -22,6 +22,9 @@
429 development version. Besides the simplification, it has also been
430 modified to read some other file formats. */
431
432+#define _LARGEFILE64_SOURCE
433+#define _GNU_SOURCE
434+
435 #include <a.out.h>
436 #include <elf.h>
437 #include <error.h>
438@@ -35,7 +38,9 @@
439 #include <sys/stat.h>
440 #include <gnu/lib-names.h>
441
442-#include <ldconfig.h>
443+#include "ldconfig.h"
444+
445+#define _(msg) msg
446
447 #define Elf32_CLASS ELFCLASS32
448 #define Elf64_CLASS ELFCLASS64
449Index: ldconfig-native-2.12.1/xstrdup.c
450===================================================================
451--- ldconfig-native-2.12.1.orig/xstrdup.c
452+++ ldconfig-native-2.12.1/xstrdup.c
453@@ -16,15 +16,10 @@
454 along with this program; if not, write to the Free Software Foundation,
455 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
456
457-#ifdef HAVE_CONFIG_H
458-# include <config.h>
459-#endif
460+#define _GNU_SOURCE
461+
462+#include <string.h>
463
464-#if defined STDC_HEADERS || defined HAVE_STRING_H || _LIBC
465-# include <string.h>
466-#else
467-# include <strings.h>
468-#endif
469 void *xmalloc (size_t n) __THROW;
470 char *xstrdup (char *string) __THROW;
471
diff --git a/meta/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig_aux-cache_path_fix.patch b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig_aux-cache_path_fix.patch
new file mode 100644
index 0000000000..27bc411078
--- /dev/null
+++ b/meta/recipes-core/eglibc/ldconfig-native-2.12.1/ldconfig_aux-cache_path_fix.patch
@@ -0,0 +1,36 @@
1Upstream-Status: Pending
2
3Coming from this bug: http://sourceware.org/bugzilla/show_bug.cgi?id=11149
4
5Nitin A Kamble <nitin.a.kamble@intel.com>2011/03/29
6
7--- ldconfig-native-2.12.1.orig/ldconfig.c
8+++ ldconfig-native-2.12.1/ldconfig.c
9@@ -1359,14 +1359,9 @@ main (int argc, char **argv)
10
11 const char *aux_cache_file = _PATH_LDCONFIG_AUX_CACHE;
12 if (opt_chroot)
13- {
14- aux_cache_file = chroot_canon (opt_chroot, aux_cache_file);
15- if (aux_cache_file == NULL)
16- error (EXIT_FAILURE, errno, _("Can't open cache file %s\n"),
17- _PATH_LDCONFIG_AUX_CACHE);
18- }
19+ aux_cache_file = chroot_canon (opt_chroot, aux_cache_file);
20
21- if (! opt_ignore_aux_cache)
22+ if (! opt_ignore_aux_cache && aux_cache_file)
23 load_aux_cache (aux_cache_file);
24 else
25 init_aux_cache ();
26@@ -1376,7 +1371,8 @@ main (int argc, char **argv)
27 if (opt_build_cache)
28 {
29 save_cache (cache_file);
30- save_aux_cache (aux_cache_file);
31+ if (aux_cache_file)
32+ save_aux_cache (aux_cache_file);
33 }
34
35 return 0;
36