Bug 12727 - ld ppc64 bug with dot symbols
Summary: ld ppc64 bug with dot symbols
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.22
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-03 11:40 UTC by Jakub Jelinek
Modified: 2011-05-04 00:56 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2011-05-03 11:40:21 UTC
cat > test.c <<\EOF
extern char *dlerror (void);
volatile int i;

void _start (void)
{
  if (dlerror ())
    i++;
}
EOF
gcc -c -m64 test.c -o test.o
ld -o test -L . -ldl test.o -lc ./ld64.so.1
ld -o test -L . -ldl test.o -ldl -lc ./ld64.so.1
ld -o test -L . test.o -ldl -lc ./ld64.so.1
gcc -c -m64 -mcall=aixdesc -o test.o
ld -o test -L . -ldl test.o -lc ./ld64.so.1
ld -o test -L . -ldl test.o -ldl -lc ./ld64.so.1
ld -o test -L . test.o -ldl -lc ./ld64.so.1

(this assumes libc.so, libdl.so and ld64.so.1 are in current working directory,
and have been built with gcc that defaults to the new linux ABI (i.e. not -mcall=aixdesc) and thus doesn't have .dlerror etc. symbols in it).
When test.o is built without dot symbols, all 3 ld commands succeed just fine,
when it is built with dot symbols and libdl.so.2 is not, only the command line with -ldl solely after test.o succeeds.
Verified with today's CVS HEAD with a cross compiler, cross assembler and cross linker, and is reported to be also present on RHEL6, which has ld based on hjl's
2.20.51.0.2.  It is reported to succeed on RHEL5, which is based on
2.17.50.0.6.
Comment 1 Jakub Jelinek 2011-05-03 11:41:55 UTC
In the original the dot symbols compiled object was in an *.a library and was dragged in by some other objects, again if -ldl preceeded it on the command line, link would fail.
Comment 2 cvs-commit@gcc.gnu.org 2011-05-04 00:31:46 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2011-05-04 00:31:41

Modified files:
	bfd            : ChangeLog elf64-ppc.c 

Log message:
	PR ld/12727
	* elf64-ppc.c (ppc_build_one_stub <ppc_sub_plt_call>): Clear
	was_undefined on dot-symbols.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5326&r2=1.5327
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-ppc.c.diff?cvsroot=src&r1=1.348&r2=1.349
Comment 3 cvs-commit@gcc.gnu.org 2011-05-04 00:34:15 UTC
CVSROOT:	/cvs/src
Module name:	src
Branch: 	binutils-2_21-branch
Changes by:	amodra@sourceware.org	2011-05-04 00:34:13

Modified files:
	bfd            : ChangeLog elf64-ppc.c 

Log message:
	PR ld/12727
	* elf64-ppc.c (ppc_build_one_stub <ppc_sub_plt_call>): Clear
	was_undefined on dot-symbols.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.5180.2.27&r2=1.5180.2.28
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-ppc.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.339.2.8&r2=1.339.2.9
Comment 4 Alan Modra 2011-05-04 00:56:05 UTC
Fixed.