Bug 29540 - ld ppc64: unneeded R_PPC64_NONE in .rela.dyn when linking Linux vdso
Summary: ld ppc64: unneeded R_PPC64_NONE in .rela.dyn when linking Linux vdso
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: 2.40
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-30 20:14 UTC by Fangrui Song
Modified: 2022-09-14 02:33 UTC (History)
0 users

See Also:
Host:
Target: powerpc64-linux
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2022-08-30 20:14:21 UTC
This should be reproducible with many Linux versions, but I have just checked some recent commits, e.g. dcf8e5633e2e69ad60b730ab5905608b756a032f today

% git remote -v | grep origin
origin  https://github.com/torvalds/linux (fetch)
origin  https://github.com/torvalds/linux (push)
% make O=/tmp/linux/ppc64le ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- -j60 defconfig all
% readelf -Wr /tmp/linux/ppc64le/arch/powerpc/kernel/vdso/vdso64.so.dbg

Relocation section '.rela.dyn' at offset 0x14f0 contains 4 entries:
    Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
0000000000000000  0000000000000000 R_PPC64_NONE                              0
0000000000000000  0000000000000000 R_PPC64_NONE                              0
0000000000000000  0000000000000000 R_PPC64_NONE                              0
0000000000000000  0000000000000000 R_PPC64_NONE                              0

The linker script is innocent. I don't reproduce the problem with other ports (though I know that the riscv port produces R_RISCV_NONE in certain scenarios)

make O=/tmp/linux/x86_64 -j60 defconfig all && readelf -Wr /tmp/linux/x86_64/arch/x86/entry/vdso/vdso64.so
make O=/tmp/linux/aarch64 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 -j60 all && readelf -Wr /tmp/linux/aarch64/arch/arm64/kernel/vdso/vdso.so
make O=/tmp/linux/riscv64 ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- -j60 defconfig all && readelf -Wr /tmp/linux/riscv64/arch/riscv/kernel/vdso/vdso.so
make O=/tmp/linux/s390x ARCH=s390 CROSS_COMPILE=s390x-linux-gnu- -j60 defconfig all && readelf -Wr /tmp/linux/s390x/arch/s390/kernel/vdso64/vdso64.so
Comment 1 Alan Modra 2022-09-10 03:23:06 UTC
Despite the use of a powerpc64le-linux compiler, defconfig builds an ELFv1 kernel not ELFv2.  So this is a powerpc64-linux problem triggerered by discarding .opd in the linker script.
Comment 2 cvs-commit@gcc.gnu.org 2022-09-14 00:50:22 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit 365bf300da35c11e27bb8cdd3964f82e3d32f094
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Sep 10 12:58:44 2022 +0930

    PR29540, R_PPC64_NONE in .rela.dyn when linking Linux vdso
    
            PR 29540
            * elf64-ppc.c (allocate_dynrelocs): Don't alloc space for relocs
            against discarded sections.
            (ppc64_elf_size_dynamic_sections): Use standard test for discarded
            sections.
            * elf32-ppc.c (allocate_dynrelocs): Don't alloc space for relocs
            against discarded sections.
            (ppc_elf_size_dynamic_sections): Use standard test for discarded
            sections.
Comment 3 Alan Modra 2022-09-14 02:33:03 UTC
Fixed for 2.40