Bug 12392 - Many static link tests fail
Summary: Many static link tests fail
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-12 10:58 UTC by Richard Biener
Modified: 2011-07-06 05:14 UTC (History)
0 users

See Also:
Host:
Target: i?86-*-linux
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2011-01-12 10:58:25 UTC
One example, the errors are common:

g++ -W -Wall    -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fmerge-constants -O2 -g   -o basic_static_test -Bgcctestdir/ -static basic_test.o
gcctestdir/ld: /usr/lib/gcc/i586-suse-linux/4.5/../../../libc.a(errlist.o):(.debug_info+0x1c3): warning: `sys_errlist' is deprecated; use `strerror' or `strerror_r' instead
gcctestdir/ld: /usr/lib/gcc/i586-suse-linux/4.5/../../../libc.a(errlist.o):(.debug_info+0x1f1): warning: `sys_nerr' is deprecated; use `strerror' or `strerror_r' instead
gcctestdir/ld: /usr/lib/gcc/i586-suse-linux/4.5/../../../libc.a(elf-init.o): in function __libc_csu_irel:elf-init.c:94: error: undefined reference to '__rel_iplt_end'
gcctestdir/ld: /usr/lib/gcc/i586-suse-linux/4.5/../../../libc.a(elf-init.o): in function __libc_csu_irel:elf-init.c:94: error: undefined reference to '__rel_iplt_start'
gcctestdir/ld: /usr/lib/gcc/i586-suse-linux/4.5/../../../libc.a(elf-init.o): in function __libc_csu_irel:../sysdeps/i386/dl-irel.h:36: error: undefined reference to '__rel_iplt_start'
gcctestdir/ld: /usr/lib/gcc/i586-suse-linux/4.5/../../../libc.a(elf-init.o): in function __libc_csu_irel:../sysdeps/i386/dl-irel.h:33: error: undefined reference to '__rel_iplt_start'
gcctestdir/ld: /usr/lib/gcc/i586-suse-linux/4.5/../../../libc.a(elf-init.o): in function __libc_csu_irel:../sysdeps/i386/dl-irel.h:36: error: undefined reference to '__rel_iplt_start'
collect2: ld returned 1 exit status
make[5]: *** [basic_static_test] Error 1

The linker is invoked as

./gcctestdir/ld -m elf_i386 -static -o basic_static_test /usr/lib/gcc/i586-suse-linux/4.5/../../../crt1.o /usr/lib/gcc/i586-suse-linux/4.5/../../../crti.o /usr/lib/gcc/i586-suse-linux/4.5/crtbeginT.o -Lgcctestdir -L/usr/lib/gcc/i586-suse-linux/4.5 -L/usr/lib/gcc/i586-suse-linux/4.5/../../../../i586-suse-linux/lib -L/usr/lib/gcc/i586-suse-linux/4.5/../../.. basic_test.o -lstdc++ -lm --start-group -lgcc -lgcc_eh -lc --end-group /usr/lib/gcc/i586-suse-linux/4.5/crtend.o /usr/lib/gcc/i586-suse-linux/4.5/../../../crtn.o

using GNU ld the link works fine.

On x86_64-linux this works fine, but on i586-linux it breaks.
Comment 1 Richard Biener 2011-01-12 11:02:16 UTC
Is there a way to easily extract all files used for the link?  Most standard
libraries are linker scripts and pull in stuff from somewhere.
Comment 2 Richard Biener 2011-01-12 11:33:42 UTC
Which means the fix for PR10893 isn't working?
Comment 3 Ian Lance Taylor 2011-01-12 14:27:50 UTC
Passing the -t option to the linker will get you a complete list of all object files and shared libraries that the linker includes in the link.

The warning about sys_errlist being deprecated suggests that your system is going to generate a warning on any static link.  At least, I don't see anything in basic_static_test which would refer to errlist, so I think the reference must be coming from libgcc or libc itself.  Does the GNU linker give a warning when linking with -static?

The error about __rel_iplt_start and __rel_iplt_end not being defined is very odd.  The 32-bit x86 linker always defines those when linking with -static.
Comment 4 Richard Biener 2011-01-12 14:44:49 UTC
(In reply to comment #3)
> Passing the -t option to the linker will get you a complete list of all object
> files and shared libraries that the linker includes in the link.
> 
> The warning about sys_errlist being deprecated suggests that your system is
> going to generate a warning on any static link.  At least, I don't see anything
> in basic_static_test which would refer to errlist, so I think the reference
> must be coming from libgcc or libc itself.  Does the GNU linker give a warning
> when linking with -static?

No, the GNU linker doesn't give this warning.  Maybe gold warns about the
symbol definition?

> The error about __rel_iplt_start and __rel_iplt_end not being defined is very
> odd.  The 32-bit x86 linker always defines those when linking with -static.

I will produce a tarfile with the objects, anything else you want to know?
Comment 5 Richard Biener 2011-01-12 14:51:10 UTC
# g++ -W -Wall    -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fmerge-constants -O2 -g   -o basic_static_test -Bgcctestdir/ -static basic_test.o -Wl,-t
/usr/lib/gcc/i586-suse-linux/4.5/../../../crt1.o
/usr/lib/gcc/i586-suse-linux/4.5/../../../crti.o
/usr/lib/gcc/i586-suse-linux/4.5/crtbeginT.o
basic_test.o
/usr/lib/gcc/i586-suse-linux/4.5/libstdc++.a(si_class_type_info.o)
/usr/lib/gcc/i586-suse-linux/4.5/libstdc++.a(del_op.o)
/usr/lib/gcc/i586-suse-linux/4.5/libstdc++.a(class_type_info.o)
/usr/lib/gcc/i586-suse-linux/4.5/libstdc++.a(tinfo.o)
/usr/lib/gcc/i586-suse-linux/4.5/../../../libc.a(libc-start.o)
/usr/lib/gcc/i586-suse-linux/4.5/../../../libc.a(check_fds.o)
...
/usr/lib/gcc/i586-suse-linux/4.5/libgcc_eh.a(unwind-dw2.o)
/usr/lib/gcc/i586-suse-linux/4.5/libgcc_eh.a(unwind-dw2-fde-glibc.o)
/usr/lib/gcc/i586-suse-linux/4.5/libgcc_eh.a(unwind-c.o)
/usr/lib/gcc/i586-suse-linux/4.5/../../../libc.a(dl-iteratephdr.o)
/usr/lib/gcc/i586-suse-linux/4.5/crtend.o
/usr/lib/gcc/i586-suse-linux/4.5/../../../crtn.o
...

files too large to attach.  They will appear (at some point) at
http://gcc.opensuse.org/gold-bug.tar.xz
Comment 6 cvs-commit@gcc.gnu.org 2011-07-06 05:12:07 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	ian@sourceware.org	2011-07-06 05:12:03

Modified files:
	gold           : ChangeLog i386.cc x86_64.cc 

Log message:
	PR gold/12392
	* i386.cc (Target_i386::do_finalize_sections): Define __rel_iplt
	symbols if necessary.
	* x86_64.cc (Target_x86_64::do_finalize_sections): Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.788&r2=1.789
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/i386.cc.diff?cvsroot=src&r1=1.134&r2=1.135
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/x86_64.cc.diff?cvsroot=src&r1=1.132&r2=1.133
Comment 7 Ian Lance Taylor 2011-07-06 05:14:26 UTC
I finally got back to this and fixed it.  It was a bug which occurred when doing a static link on a system which supports STT_GNU_IFUNC symbols but does not actually use any.