Bug 20519 - "PowerPC64, Don't copy weak symbol dyn_relocs to weakdef." causes abort at elf64-ppc.c:14898
Summary: "PowerPC64, Don't copy weak symbol dyn_relocs to weakdef." causes abort at el...
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.28
: P2 normal
Target Milestone: 2.28
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-26 08:06 UTC by npiggin
Modified: 2017-03-07 04:33 UTC (History)
1 user (show)

See Also:
Host: powerpc64le-unknown-linux-gnu
Target: powerpc64le-unknown-linux-gnu
Build:
Last reconfirmed: 2016-08-26 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description npiggin 2016-08-26 08:06:23 UTC
With a powerpc64le allyesconfig build of the Linux kernel, using thin archives and --gc-sections, I see ld failing:

npiggin@p84-npiggin:~/src/linux$ time ../binutils/binutils-gdb/ld/ld-new -EL -m elf64lppc -pie --emit-relocs --build-id --gc-sections -X -o vmlinux -T ./arch/powerpc/kernel/vmlinux.lds --whole-archive built-in.o .tmp_kallsyms3.o
../binutils/binutils-gdb/ld/ld-new: BFD (GNU Binutils) 2.27.51.20160819 internal error, aborting at elf64-ppc.c:14898 in ppc64_elf_relocate_section

Bisected to d311bc8bf85f8358df21301fe8a357aa1212f80c

This build requires some out of tree patches to the kernel, so I can test patches and report back, or for IBMers I can give a login to my VM if that would help.
Comment 1 npiggin 2016-08-26 10:34:46 UTC
Confirmed to fail with head of tree as of Aug 26, commit

980aa3e6dfeb0f018915f65be4b2987667f31fe9
Comment 2 npiggin 2016-08-26 11:09:05 UTC
Confirmed this does not require any kernel modifications, a large kernel, or --gc-sections or --emit-relocs etc.

Standard upstream Linux kernel with minimal config reproduces the error.
Comment 3 Sourceware Commits 2016-08-27 01:02:20 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8a9e8e72fe88095043d16f8a56b5a1e150ee288b

commit 8a9e8e72fe88095043d16f8a56b5a1e150ee288b
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Aug 27 08:59:29 2016 +0930

    Fix commit 980aa3e6
    
    Commit 980aa3e6 was supposed to cure dyn_reloc counting problems, but
    did the opposite.  For PIC we count two types of dyn_reloc, those on
    pc-relative relocs, and the total.  If a sym needs pc-relative dyn
    relocs then all the relocs are dynamic.  If not, then only those that
    are must_be_dyn_reloc are dynamic.
    
    	PR 20519
    	* elf64-ppc.c (pc_dynrelocs): New function.
    	(ppc64_elf_relocate_section): Use it and must_be_dyn_reloc to
    	handle pic dynamic relocs.
Comment 4 Alan Modra 2016-08-27 01:36:32 UTC
Fixed, I think.
Comment 5 npiggin 2016-08-29 02:07:36 UTC
Yes this works now, thank you.
Comment 6 Sourceware Commits 2017-03-07 02:28:41 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b1b07054c08eea65ba8d1a9f771796d686f337e5

commit b1b07054c08eea65ba8d1a9f771796d686f337e5
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Mar 7 11:04:19 2017 +1030

    PowerPC64 abort due to dynamic relocs on hidden undefweak
    
    ppc64_elf_relocate_section lacked a check which meant that it emitted
    dynamic relocs against a hidden undefweak symbol for which no dynamic
    relocs had been allocated.
    
    	PR 21224
    	PR 20519
    	* elf64-ppc.c (ppc64_elf_relocate_section): Add missing
    	dyn_relocs check.
Comment 7 Sourceware Commits 2017-03-07 04:33:55 UTC
The binutils-2_28-branch branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0d69827324f704b75ac7e5c2b39219cdd15e790b

commit 0d69827324f704b75ac7e5c2b39219cdd15e790b
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Mar 7 11:04:19 2017 +1030

    PowerPC64 abort due to dynamic relocs on hidden undefweak
    
    ppc64_elf_relocate_section lacked a check which meant that it emitted
    dynamic relocs against a hidden undefweak symbol for which no dynamic
    relocs had been allocated.
    
    	PR 21224
    	PR 20519
    	* elf64-ppc.c (ppc64_elf_relocate_section): Add missing
    	dyn_relocs check.