Bug 11088

Summary: Internal Error in ppc64_elf_gc_sweep_hook
Product: binutils Reporter: Nick Clifton <nickc>
Component: ldAssignee: Alan Modra <amodra>
Status: RESOLVED FIXED    
Severity: normal CC: bug-binutils
Priority: P2    
Version: 2.21   
Target Milestone: ---   
Host: i686-pc-linux-gnu Target: powerpc64-linux-gnu
Build: Last reconfirmed:
Attachments: Do not scan empty PLT list

Description Nick Clifton 2009-12-14 11:31:04 UTC
Running this command line:

 ld-new -shared --gc-sections JSSVGElementInstance.o JSSVGElementInstanceList.o

With the uploaded object files results in:

 ld-new: BFD (GNU Binutils) 2.20.51.20091214 internal error, aborting at
   bfd/elf64-ppc.c line 5868 in ppc64_elf_gc_sweep_hook
 ld-new: Please report this bug.

Applying the uploaded patch fixes the problem, but it may just be acting as a
workaround, rather than fixing an underlying problem.
Comment 1 Nick Clifton 2009-12-14 11:33:28 UTC
Created attachment 4466 [details]
Do not scan empty PLT list
Comment 2 Nick Clifton 2009-12-14 11:36:59 UTC
Subject: Re:  Internal Error in  ppc64_elf_gc_sweep_hook

For some unknown reason bugzilla is not letting me upload the object
tarball via the web interface so I am trying via an email attachment.

Comment 3 Alan Modra 2009-12-14 23:40:56 UTC
I'd like to know why we have the failure before you apply your patch, Nick. 
Especially since there's a similar ppc32 report but no testcase.  In looking
over the ppc32 code I found a number of problems with handling of pltrel24
relocs but nothing that might cause a failure in gc_sweep_hook.  :-(
Comment 4 Alan Modra 2009-12-16 23:34:14 UTC
Found it.  The symbol in question is hidden.  check_relocs records a need for a
plt entry ok, but then we hit code after this comment in elflink.c
	    /* If the symbol already has a dynamic index, but
	       visibility says it should not be visible, turn it into
	       a local symbol.  */
So elf_backend_hide_symbol zaps the plt entry.
Comment 5 cvs-commit@gcc.gnu.org 2009-12-17 00:07:51 UTC
Subject: Bug 11088

CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2009-12-17 00:07:38

Modified files:
	bfd            : ChangeLog elf64-ppc.c 

Log message:
	PR ld/11088
	* elf64-ppc.c (ppc64_elf_gc_sweep_hook): Don't abort if symbol
	hiding has nulled out plt.plist.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.4862&r2=1.4863
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/elf64-ppc.c.diff?cvsroot=src&r1=1.304&r2=1.305

Comment 6 cvs-commit@gcc.gnu.org 2009-12-17 00:08:15 UTC
Subject: Bug 11088

CVSROOT:	/cvs/src
Module name:	src
Branch: 	binutils-2_20-branch
Changes by:	amodra@sourceware.org	2009-12-17 00:08:01

Modified files:
	bfd            : ChangeLog elf64-ppc.c 

Log message:
	PR ld/11088
	* elf64-ppc.c (ppc64_elf_gc_sweep_hook): Don't abort if symbol
	hiding has nulled out plt.plist.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_20-branch&r1=1.4761.2.33&r2=1.4761.2.34
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/elf64-ppc.c.diff?cvsroot=src&only_with_tag=binutils-2_20-branch&r1=1.299.2.3&r2=1.299.2.4

Comment 7 cvs-commit@gcc.gnu.org 2009-12-17 05:45:48 UTC
Subject: Bug 11088

CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2009-12-17 05:45:26

Modified files:
	include/elf    : ChangeLog ppc.h 
	bfd            : ChangeLog elf32-ppc.c 

Log message:
	PR ld/11088
	include/elf/
	* ppc.h (R_PPC_RELAX32, R_PPC_RELAX32PC, R_PPC_RELAX32_PLT,
	R_PPC_RELAX32PC_PLT): Delete.
	(R_PPC_RELAX, R_PPC_RELAX_PLT, R_PPC_RELAX_PLTREL24): Define.
	bfd/
	* elf32-ppc.c (update_plt_info): Clear sec here when addend is
	less than 32768..
	(ppc_elf_check_relocs): ..rather than doing so here.  Ignore new
	relax relocs.
	(ppc_elf_gc_sweep_hook): Don't segfault when symbol hiding has
	removed plt_entry records.
	(ppc_elf_tls_setup): Handle PIE calls to __tls_get_addr correctly.
	(ppc_elf_tls_optimize): Likewise.  Also dec __tls_get_addr refcount
	when optimizing code using new tlsgd and tlsld marker relocs.
	(ppc_elf_relax_section): Differentiate relaxed PLTREL24 relocs
	from ADDR24 relocs using plt or glink.  Don't clear the addend
	for R_PPC_RELAX_PLTREL24.
	(ppc_elf_relocate_section): Correctly handle addends on relaxed
	PLTREL24 relocs.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/include/elf/ChangeLog.diff?cvsroot=src&r1=1.383&r2=1.384
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/include/elf/ppc.h.diff?cvsroot=src&r1=1.26&r2=1.27
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.4863&r2=1.4864
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/elf32-ppc.c.diff?cvsroot=src&r1=1.272&r2=1.273

Comment 8 cvs-commit@gcc.gnu.org 2009-12-17 05:46:21 UTC
Subject: Bug 11088

CVSROOT:	/cvs/src
Module name:	src
Branch: 	binutils-2_20-branch
Changes by:	amodra@sourceware.org	2009-12-17 05:46:06

Modified files:
	include/elf    : ChangeLog ppc.h 
	bfd            : ChangeLog elf32-ppc.c 

Log message:
	PR ld/11088
	include/elf/
	* ppc.h (R_PPC_RELAX32, R_PPC_RELAX32PC, R_PPC_RELAX32_PLT,
	R_PPC_RELAX32PC_PLT): Delete.
	(R_PPC_RELAX, R_PPC_RELAX_PLT, R_PPC_RELAX_PLTREL24): Define.
	bfd/
	* elf32-ppc.c (update_plt_info): Clear sec here when addend is
	less than 32768..
	(ppc_elf_check_relocs): ..rather than doing so here.  Ignore new
	relax relocs.
	(ppc_elf_gc_sweep_hook): Don't segfault when symbol hiding has
	removed plt_entry records.
	(ppc_elf_tls_setup): Handle PIE calls to __tls_get_addr correctly.
	(ppc_elf_tls_optimize): Likewise.  Also dec __tls_get_addr refcount
	when optimizing code using new tlsgd and tlsld marker relocs.
	(ppc_elf_relax_section): Differentiate relaxed PLTREL24 relocs
	from ADDR24 relocs using plt or glink.  Don't clear the addend
	for R_PPC_RELAX_PLTREL24.
	(ppc_elf_relocate_section): Correctly handle addends on relaxed
	PLTREL24 relocs.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/include/elf/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_20-branch&r1=1.379.2.1&r2=1.379.2.2
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/include/elf/ppc.h.diff?cvsroot=src&only_with_tag=binutils-2_20-branch&r1=1.25.4.1&r2=1.25.4.2
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_20-branch&r1=1.4761.2.34&r2=1.4761.2.35
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/elf32-ppc.c.diff?cvsroot=src&only_with_tag=binutils-2_20-branch&r1=1.267.2.3&r2=1.267.2.4

Comment 9 Alan Modra 2009-12-17 05:48:57 UTC
Fixed