Bug 27100

Summary: final link failed: bad value
Product: binutils Reporter: Cameron MacPherson <cameron.macpherson>
Component: ldAssignee: Alan Modra <amodra>
Status: RESOLVED FIXED    
Severity: normal CC: glaubitz, nickc
Priority: P2    
Version: 2.36   
Target Milestone: 2.36   
Host: Target: powerpc64le-linux, x86_64-linux, aarch64-linux
Build: Last reconfirmed: 2020-12-23 00:00:00
Bug Depends on:    
Bug Blocks: 28903    

Description Cameron MacPherson 2020-12-20 20:02:49 UTC
after upgrading to the latest debian ppc64 binutils (via apt -t experimental upgrade) i am no longer able to compile a linux kernel.  i haven't had problems compiling anything else.

$ cat /proc/cpuinfo
processor	: 0
cpu		: PPC970, altivec supported
clock		: 1600.000000MHz
revision	: 2.2 (pvr 0039 0202)

timebase	: 33333333
platform	: PowerMac
model		: PowerMac7,2
machine		: PowerMac7,2
motherboard	: PowerMac7,2 MacRISC4 Power Macintosh
detected as	: 336 (PowerMac G5)
pmac flags	: 00000000
L2 cache	: 512K unified
pmac-generation	: NewWorld

$ make V=1 bindeb-pkg
make KERNELRELEASE=5.10.1 ARCH=powerpc 	KBUILD_BUILD_VERSION=1 -f ./Makefile
[...]
  gcc -Wp,-MMD,init/.main.o.d -nostdinc -isystem /usr/lib/gcc/powerpc64-linux-gnu/10/include -I./arch/powerpc/include -I./arch/powerpc/include/generated  -I./include -I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -I ./arch/powerpc -DHAVE_AS_ATHIGH=1 -fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89 -mbig-endian -m64 -msoft-float -pipe -mtraceback=no -mabi=elfv1 -mcall-aixdesc -mcmodel=medium -mno-pointers-to-nested-functions -mtune=power7 -mcpu=power5 -mno-altivec -mno-vsx -fno-asynchronous-unwind-tables -mno-string -Wa,-maltivec -Wa,-mpower4 -Wa,-many -mabi=elfv1 -mcall-aixdesc -mbig-endian -mstack-protector-guard=tls -mstack-protector-guard-reg=r13 -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 -fno-allow-store-data-races -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fomit-frame-pointer -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wno-packed-not-aligned -mstack-protector-guard-offset=880 -D_TASK_CPU=304 -fno-function-sections -fno-data-sections    -DKBUILD_MODFILE='"init/main"' -DKBUILD_BASENAME='"main"' -DKBUILD_MODNAME='"main"' -c -o init/main.o init/main.c

  if objdump -h init/main.o | grep -q __ksymtab; then gcc -E -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89 -mbig-endian -m64 -msoft-float -pipe -mtraceback=no -mabi=elfv1 -mcall-aixdesc -mcmodel=medium -mno-pointers-to-nested-functions -mtune=power7 -mcpu=power5 -mno-altivec -mno-vsx -fno-asynchronous-unwind-tables -mno-string -Wa,-maltivec -Wa,-mpower4 -Wa,-many -mabi=elfv1 -mcall-aixdesc -mbig-endian -mstack-protector-guard=tls -mstack-protector-guard-reg=r13 -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 -fno-allow-store-data-races -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fomit-frame-pointer -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wno-packed-not-aligned -mstack-protector-guard-offset=880 -D_TASK_CPU=304 -D__GENKSYMS__ -Wp,-MMD,init/.main.o.d -nostdinc -isystem /usr/lib/gcc/powerpc64-linux-gnu/10/include -I./arch/powerpc/include -I./arch/powerpc/include/generated  -I./include -I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -I ./arch/powerpc -DHAVE_AS_ATHIGH=1 -fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89 -mbig-endian -m64 -msoft-float -pipe -mtraceback=no -mabi=elfv1 -mcall-aixdesc -mcmodel=medium -mno-pointers-to-nested-functions -mtune=power7 -mcpu=power5 -mno-altivec -mno-vsx -fno-asynchronous-unwind-tables -mno-string -Wa,-maltivec -Wa,-mpower4 -Wa,-many -mabi=elfv1 -mcall-aixdesc -mbig-endian -mstack-protector-guard=tls -mstack-protector-guard-reg=r13 -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 -fno-allow-store-data-races -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fomit-frame-pointer -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wno-packed-not-aligned -mstack-protector-guard-offset=880 -D_TASK_CPU=304 -fno-function-sections -fno-data-sections    -DKBUILD_MODFILE='"init/main"' -DKBUILD_BASENAME='"main"' -DKBUILD_MODNAME='"main"' init/main.c | scripts/genksyms/genksyms  -R  -r /dev/null > init/.tmp_main.ver; ld -EB -m elf64ppc -r -o init/.tmp_main.o init/main.o -T init/.tmp_main.ver; mv -f init/.tmp_main.o init/main.o; rm -f init/.tmp_main.ver; fi

ld: final link failed: bad value
make[4]: *** [scripts/Makefile.build:279: init/main.o] Error 1

$ ld --version
GNU ld (GNU Binutils for Debian) 2.35.50.20201218
Comment 1 Cameron MacPherson 2020-12-20 20:39:00 UTC
contents of init/.tmp_main.ver

SECTIONS { .rodata : ALIGN(4) { __crc_system_state = .; LONG(0x015af7f4); } }
SECTIONS { .rodata : ALIGN(4) { __crc_static_key_initialized = .; LONG(0xbea5ff1e); } }
SECTIONS { .rodata : ALIGN(4) { __crc_reset_devices = .; LONG(0xc2e587d1); } }
SECTIONS { .rodata : ALIGN(4) { __crc_loops_per_jiffy = .; LONG(0xba497f13); } }
Comment 2 Alan Modra 2020-12-23 03:28:02 UTC
This is a generic linker problem, triggered by the presence of two or more output sections of the same name containing LONG() or other data.

cat > pr27100.lnk <<\EOF
SECTIONS { .rodata : { __crc_system_state = .; LONG(0x015af7f4); } }
SECTIONS { .rodata : { __crc_static_key_initialized = .; LONG(0xbea5ff1e); } }
EOF
cat > pr27100.s <<\EOF
 .section ".rodata","a",%progbits
 .space 50
EOF
gas/as-new -o pr27100.o pr27100.s
ld/ld-new -r -o pr27100 pr27100.o -T pr27100.lnk

Looks to be a regression from 2.35
Comment 3 Alan Modra 2020-12-23 04:04:36 UTC
Regressed with 21401fc7bf67db
Comment 4 Sourceware Commits 2020-12-24 12:34:00 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit de34d42812a0b978b278cd344abeaee7c71fa55c
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Dec 24 15:56:23 2020 +1030

    PR27100, final link failed: bad value
    
    The failure on this PR is due to using the same bfd section for
    multiple output sections.  Commit 21401fc7bf67 managed to create
    duplicate linker script output section statements, but not the actual
    bfd sections.
    
            PR 27100
            * ldlang.h (lang_output_section_statement_type): Add dup_output.
            * ldlang.c (lang_output_section_statement_lookup): Set dup_output.
            (init_os): Test dup_output rather than constraint.
            * testsuite/ld-scripts/pr27100.d,
            * testsuite/ld-scripts/pr27100.s,
            * testsuite/ld-scripts/pr27100.t: New test.
            * testsuite/ld-scripts/data.exp: Run it.  Don't exclude aout here.
            * testsuite/ld-scripts/data.d: Do so here instead.
            * testsuite/ld-scripts/fill.d: Likewise.
            * testsuite/ld-scripts/fill16.d: Likewise.
Comment 5 Alan Modra 2020-12-24 12:40:02 UTC
Fixed, I believe.
Comment 6 Cameron MacPherson 2020-12-28 00:41:04 UTC
i can confirm its fixed with your diff i recompiled binutils and the kernel successfully
Comment 7 Alan Modra 2021-01-04 10:58:50 UTC
*** Bug 27073 has been marked as a duplicate of this bug. ***