]>
Commit | Line | Data |
---|---|---|
6256a65f JB |
1 | Date: Tue, 12 Apr 2005 00:00:15 +0930 |
2 | From: Alan Modra <amodra at bigpond dot net dot au> | |
3 | To: binutils at sources dot redhat dot com | |
4 | Cc: Anton Blanchard <anton at samba dot org>, | |
5 | Paul Mackerras <paulus at samba dot org> | |
6 | Subject: AS_NEEDED failure | |
7 | Message-ID: <20050411143015.GB861@bubble.modra.org> | |
8 | Mail-Followup-To: binutils at sources dot redhat dot com, | |
9 | Anton Blanchard <anton at samba dot org>, Paul Mackerras <paulus at samba dot org> | |
10 | Mime-Version: 1.0 | |
11 | Content-Type: text/plain; charset=us-ascii | |
12 | Content-Disposition: inline | |
13 | User-Agent: Mutt/1.4i | |
14 | ||
15 | On powerpc64, I've hit the following during an X11 server build | |
16 | .../libdl.so.2: undefined reference to _rtld_global@GLIBC_PRIVATE | |
17 | This symbol is defined in ld64.so.1, and ld64.so.1 is being searched, | |
18 | but the following conspires to make the link fail: | |
19 | ||
20 | - libc.so contains AS_NEEDED (ld64.so.1) | |
21 | - one or more of the X11 libs has DT_NEEDED libdl.so.2 | |
22 | - libdl.so.2 has DT_NEEDED ld64.so.1 | |
23 | ||
24 | The libc.so AS_NEEDED() causes symbols from ld64.so.1 to be loaded, but | |
25 | no regular object file needs them so all the ld64.so.1 syms are set back | |
26 | to bfd_link_hash_new, effectively removing them. The X11 lib is loaded, | |
27 | and its DT_NEEDED entry noted. libdl.so.2 is loaded, but ld decides | |
28 | that ld64.so.1 has already been looked at, so doesn't load it again. | |
29 | It should do, because AS_NEEDED lib symbols aren't really loaded. | |
30 | ||
31 | * emultempl/elf32.em (gld${EMULATION_NAME}_stat_needed): Ignore | |
32 | as_needed libs that were not needed. | |
33 | (gld${EMULATION_NAME}_check_needed): Likewise. | |
34 | ||
35 | Applied mainline. I think this should go on 2.16, but after some more | |
36 | testing.. | |
37 | ||
38 | Index: ld/emultempl/elf32.em | |
39 | =================================================================== | |
40 | RCS file: /cvs/src/src/ld/emultempl/elf32.em,v | |
41 | retrieving revision 1.138 | |
42 | diff -u -p -r1.138 elf32.em | |
43 | --- ld/emultempl/elf32.em 4 Apr 2005 11:27:15 -0000 1.138 | |
44 | +++ ld/emultempl/elf32.em 11 Apr 2005 14:23:08 -0000 | |
45 | @@ -230,6 +230,9 @@ gld${EMULATION_NAME}_stat_needed (lang_i | |
46 | return; | |
47 | if (s->the_bfd == NULL) | |
48 | return; | |
49 | + if (s->as_needed | |
50 | + && (bfd_elf_get_dyn_lib_class (s->the_bfd) & DYN_AS_NEEDED) != 0) | |
51 | + return; | |
52 | ||
53 | if (bfd_stat (s->the_bfd, &st) != 0) | |
54 | { | |
55 | @@ -737,6 +740,13 @@ gld${EMULATION_NAME}_check_needed (lang_ | |
56 | if (global_found) | |
57 | return; | |
58 | ||
59 | + /* If this input file was an as-needed entry, and wasn't found to be | |
60 | + needed at the stage it was linked, then don't say we have loaded it. */ | |
61 | + if (s->as_needed | |
62 | + && (s->the_bfd == NULL | |
63 | + || (bfd_elf_get_dyn_lib_class (s->the_bfd) & DYN_AS_NEEDED) != 0)) | |
64 | + return; | |
65 | + | |
66 | if (s->filename != NULL) | |
67 | { | |
68 | const char *f; | |
69 | ||
70 | -- | |
71 | Alan Modra | |
72 | IBM OzLabs - Linux Technology Centre | |
73 |