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