This shows up in the ld testsuite: /home/dave/binutils-2.16.91/objdir/ld/ld-new -m hppalinux -o tmpdir/ld1 -dynami c-linker /lib/ld.so.1 /usr/lib/crt1.o /usr/lib/crti.o /home/dave/opt/gnu/gcc/gcc -4.0.2/lib/gcc/hppa-linux/4.0.2/crtbegin.o tmpdir/ld-partial.o ../bfd/.libs/lib bfd.a ../libiberty/libiberty.a -L/usr/lib --start-group /home/dave/opt/gnu/gcc /gcc-4.0.2/lib/gcc/hppa-linux/4.0.2/libgcc.a /home/dave/opt/gnu/gcc/gcc-4.0.2/li b/gcc/hppa-linux/4.0.2/libgcc_eh.a -lc --end-group /home/dave/opt/gnu/gcc/gcc-4. 0.2/lib/gcc/hppa-linux/4.0.2/crtend.o /usr/lib/crtn.o /lib/libc.so.6: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE' /lib/libc.so.6: undefined reference to `__libc_stack_end@GLIBC_2.2' FAIL: bootstrap It has something to do with debian libc6 2.3.5-6.0.1. I'm not seeing this problem with 2.3.2.ds1-22. It's not entirely reproducible (e.g., changing GCC version sometimes causes the problem to go away).
For some reason, the symbols in /lib/ld.so.1 aren't being resolved. Adding /lib/ld.so.1 to the link command resolves the symbols. I see Dynamic section at offset 0x140730 contains 24 entries: Tag Type Name/Value 0x00000001 (NEEDED) Shared library: [ld.so.1] in libc.so.6, so I'm not sure why the symbols aren't automatically resolved.
If you can provide all input files, I will try to take a look.
Subject: Re: /lib/libc.so.6: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE' > ------- Additional Comments From hjl at lucon dot org 2005-10-09 15:15 ------- > If you can provide all input files, I will try to take a look. I'll try to do this tomorrow. It's Thanksgiving holiday here today. Dave
Subject: Re: /lib/libc.so.6: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE' > > ------- Additional Comments From hjl at lucon dot org 2005-10-09 15:15 ------- > > If you can provide all input files, I will try to take a look. > > I'll try to do this tomorrow. It's Thanksgiving holiday here today. Thinking a bit more about this, I decided providing the files would be a bit tricky as I need to provide the glibc shared libraries. So, I looked a bit more into what's going on. When elf_add_dt_needed_tag is called for ld.so.1, DO_IT is false. Looking at this bit of code: /* If this dynamic lib was specified on the command line with --as-needed in effect, then we don't want to add a DT_NEEDED tag unless the lib is actually used. Similary for libs brought in by another lib's DT_NEEDED. When --no-add-needed is used on a dynamic lib, we don't want to add a DT_NEEDED entry for any dynamic library in DT_NEEDED tags in the dynamic lib at all. */ add_needed = (elf_dyn_lib_class (abfd) & (DYN_AS_NEEDED | DYN_DT_NEEDED | DYN_NO_NEEDED)) == 0; I see: (gdb) p *abfd $17 = {id = 28, filename = 0xf5308 "/home/dave/opt/gnu/lib/ld.so.1", xvec = 0xb7c24, iostream = 0x0, iovec = 0xaa6ac, cacheable = 1, ... (gdb) p abfd->tdata.elf_obj_data->dyn_lib_class $18 = DYN_DT_NEEDED So, add_needed is set to false. Dave
I should add that these dynamic symbols are references to global objects: 200: 00000000 4 OBJECT GLOBAL DEFAULT UND __libc_stack_end@GLIBC_2.2 (1 4) 848: 00000000 168 OBJECT GLOBAL DEFAULT UND _rtld_global_ro@GLIBC_PRIVATE (15)
This shouldn't be a problem since executable doesn't use any symbols in ld.so. If you can provide a testcase, I will try to look into it.
Can you show me your "readelf -d /lib/libc.so.6": [hjl@gnu-13 glibc-nptl-4.0]$ readelf -d /lib/libc.so.6 Dynamic section at offset 0x126cfc contains 26 entries: Tag Type Name/Value 0x00000001 (NEEDED) Shared library: [ld-linux.so.2] 0x0000000e (SONAME) Library soname: [libc.so.6]
Subject: Re: /lib/libc.so.6: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE' > Can you show me your "readelf -d /lib/libc.so.6": dave@gsyprf11:~/binutils-2.16.91/src/bfd$ readelf -d /lib/libc.so.6|less Dynamic section at offset 0x140730 contains 24 entries: Tag Type Name/Value 0x00000001 (NEEDED) Shared library: [ld.so.1] 0x0000000e (SONAME) Library soname: [libc.so.6] 0x0000000c (INIT) 0x20474 0x0000001a (FINI_ARRAY) 0x14ea54 0x0000001c (FINI_ARRAYSZ) 4 (bytes) 0x00000004 (HASH) 0x134 0x00000005 (STRTAB) 0xaf58 0x00000006 (SYMTAB) 0x30d8 0x0000000a (STRSZ) 20374 (bytes) 0x0000000b (SYMENT) 16 (bytes) 0x00000003 (PLTGOT) 0x1544d4 0x00000002 (PLTRELSZ) 5256 (bytes) 0x00000014 (PLTREL) RELA 0x00000017 (JMPREL) 0x1ead4 0x00000007 (RELA) 0x110ac 0x00000008 (RELASZ) 55848 (bytes) 0x00000009 (RELAENT) 12 (bytes) 0x6ffffffc (VERDEF) 0x10ec0 0x6ffffffd (VERDEFNUM) 13 0x6ffffffe (VERNEED) 0x1107c Dave
It looks OK. A testcase is needed.
Subject: Re: /lib/libc.so.6: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE' > It looks OK. A testcase is needed. The following C file triggers the problem: int main () { return 0; } The link command is: ./ld-new --eh-frame-hdr -dynamic-linker /lib/ld.so.1 -o main /usr/lib/gcc/hppa-linux-gnu/4.0.1/../../../crt1.o /usr/lib/gcc/hppa-linux-gnu/4.0.1/../../../crti.o /usr/lib/gcc/hppa-linux-gnu/4.0.1/crtbegin.o -L/usr/lib/gcc/hppa-linux-gnu/4.0.1 -L/usr/lib/gcc/hppa-linux-gnu/4.0.1 -L/usr/lib/gcc/hppa-linux-gnu/4.0.1/../../.. main.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/hppa-linux-gnu/4.0.1/crtend.o /usr/lib/gcc/hppa-linux-gnu/4.0.1/../../../crtn.o Dave
Please provide all input files for me to reproduce it with a cross linker.
Subject: Re: /lib/libc.so.6: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE' > This shouldn't be a problem since executable doesn't use any symbols in ld.so. > If you can provide a testcase, I will try to look into it. I see the following comment in elf-hppa.h: /* HP's shared libraries have references to symbols that are not defined anywhere. The generic ELF BFD linker code will complain about such symbols. So we detect the losing case and arrange for the flags on the symbol to indicate that it was never referenced. This keeps the generic ELF BFD link code happy and appears to not create any secondary problems. Ultimately we need a way to control the behavior of the generic ELF BFD link code better. */ elf_link_hash_traverse (elf_hash_table (info), elf_hppa_unmark_useless_dynamic_symbols, info); However, the code is only used for elf64. At the moment, I don't see any code that unsets DYN_DT_NEEDED. Possibly, the bug is that the info field unresolved_syms_in_shared_libs should be set to RM_IGNORE. Dave
Subject: Re: /lib/libc.so.6: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE' > Please provide all input files for me to reproduce it with a cross linker. Attached. Dave
Created attachment 693 [details] ld-1443.tar.gz
Subject: Re: /lib/libc.so.6: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE' On Mon, Oct 10, 2005 at 05:03:22PM -0400, John David Anglin wrote: > > Please provide all input files for me to reproduce it with a cross linker. > > Attached. Oops, missed two files. Dave
Created attachment 694 [details] ld-1443m.tar.gz
I also need /usr/lib/libc.so and the related files. Please do # cat /usr/lib/libc.so to see what they are.
Subject: Re: /lib/libc.so.6: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE' On Mon, Oct 10, 2005 at 09:17:12PM -0000, hjl at lucon dot org wrote: > > ------- Additional Comments From hjl at lucon dot org 2005-10-10 21:17 ------- > I also need /usr/lib/libc.so and the related files. Please do > > # cat /usr/lib/libc.so /* GNU ld script Use the shared library, but some functions are only in the static library, so try that secondarily. */ OUTPUT_FORMAT(elf32-hppa-linux) GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a ) Dave
Created attachment 695 [details] libc_nonshared.a
I also need /usr/lib/crti.o.
Subject: Re: /lib/libc.so.6: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE' On Mon, Oct 10, 2005 at 09:41:08PM -0000, hjl at lucon dot org wrote: > > ------- Additional Comments From hjl at lucon dot org 2005-10-10 21:41 ------- > I also need /usr/lib/crti.o. Attached. I have the feeling that the wrong bfd is being used for the DYN_DT_NEEDED check in elf_link_check_versioned_symbol: abfd = h->root.u.undef.abfd; if ((abfd->flags & DYNAMIC) == 0 || (elf_dyn_lib_class (abfd) & DYN_DT_NEEDED) == 0) return FALSE; libc.so.6 is DYN_NORMAL and ld.so.1 is DYN_DT_NEEDED. We are checking libc.so.6. Dave
Created attachment 696 [details] crti.o
I can't duplicate your problem: [hjl@gnu-13 hppa-3]$ make ./ld -o main --eh-frame-hdr -dynamic-linker /lib/ld.so.1 \ crt1.o crti.o crtbegin.o main.o -lgcc --as-needed \ -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s \ --no-as-needed crtend.o crtn.o -L. -rpath-link . [hjl@gnu-13 hppa-3]$ ./ld -V GNU ld version 2.16.91 20051007 Supported emulations: hppalinux
Subject: Re: /lib/libc.so.6: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE' > I can't duplicate your problem: I was afraid of that. As I indicated originally, the problem seemed start file sensitive. I have the following backtrace on the system that I consistently see the problem: (gdb) bt #0 undefined_symbol (info=0xd727c, name=0x19a7e8 "_rtld_global_ro@GLIBC_PRIVATE", abfd=0x118448, section=0x0, address=0, error=-1074603408) at ../../src/ld/ldmain.c:1321 #1 0x000669cc in elf_link_output_extsym (h=0x1a05a8, data=0x19a7e8) at ../../src/bfd/elflink.c:6349 #2 0x0003d6f4 in bfd_hash_traverse (table=0xe5fc8, func=@0xd238a: 0x668d8 <elf_link_output_extsym>, info=0xbff2da70) at ../../src/bfd/hash.c:484 #3 0x0003dd20 in bfd_link_hash_traverse (table=0xd727c, func=0x19a7e8, info=0x118448) at ../../src/bfd/linker.c:610 #4 0x00069564 in bfd_elf_final_link (abfd=0xe3d80, info=0xd727c) at ../../src/bfd/elflink.c:8320 #5 0x0004e664 in elf32_hppa_final_link (abfd=0xe3d80, info=0x19a7e8) at ../../src/bfd/elf32-hppa.c:3100 #6 0x000283e4 in ldwrite () at ../../src/ld/ldwrite.c:554 #7 0x00025e50 in main (argc=24, argv=0xbff2d6bc) at ../../src/ld/ldmain.c:468 (gdb) p h->root.type $49 = bfd_link_hash_undefined (gdb) p h->ref_dynamic $50 = 1 (gdb) p h->ref_regular $51 = 0 (gdb) p finfo->info->unresolved_syms_in_shared_libs $52 = RM_GENERATE_ERROR (gdb) p finfo->info->shared $53 = 0 (gdb) p finfo->info->relocatable $55 = 0 Why is the default to generate errors for undefined symbols in shared libraries that aren't referenced from the regular files? Presumably, when the shared libraries were linked, these references were resolved or the link was done to ignore unresolved symbols. Dave
You need to find out why those symbols aren't defined, given that ld.so.1 is loaded via DT_NEEDED in libc.so.6. I saw a few possibilities: 1. A bfd/ld bug which is platform dependent. 2. Different binutils sources. 3. Platform issue. You can do a binary search on binutils in CVS to see which patch causes this issue.
Subject: Re: /lib/libc.so.6: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE' > You need to find out why those symbols aren't defined, given that I just found the problem. It was an installation of an old libc6 that was causing an incorrect version of ld.so.1 to be found. Thanks for the help. Dave
Closing per comment #26.