]> git.itanic.dy.fi Git - linux-stable/commit
powerpc/vmlinux.lds: Don't discard .rela* for relocatable builds
authorMichael Ellerman <mpe@ellerman.id.au>
Thu, 5 Jan 2023 11:28:36 +0000 (22:28 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Feb 2023 10:25:42 +0000 (11:25 +0100)
commita783d7f7cb957c5b652b5456020ece4e39f61a29
tree9f5559f7b9611e466a84bdb760452c0873a281b0
parent9c87fd4a3044b6950179669fbdde624e881bc669
powerpc/vmlinux.lds: Don't discard .rela* for relocatable builds

commit 07b050f9290ee012a407a0f64151db902a1520f5 upstream.

Relocatable kernels must not discard relocations, they need to be
processed at runtime. As such they are included for CONFIG_RELOCATABLE
builds in the powerpc linker script (line 340).

However they are also unconditionally discarded later in the
script (line 414). Previously that worked because the earlier inclusion
superseded the discard.

However commit 99cb0d917ffa ("arch: fix broken BuildID for arm64 and
riscv") introduced an earlier use of DISCARD as part of the RO_DATA
macro (line 137). With binutils < 2.36 that causes the DISCARD
directives later in the script to be applied earlier, causing .rela* to
actually be discarded at link time, leading to build warnings and a
kernel that doesn't boot:

  ld: warning: discarding dynamic section .rela.init.rodata

Fix it by conditionally discarding .rela* only when CONFIG_RELOCATABLE
is disabled.

Fixes: 99cb0d917ffa ("arch: fix broken BuildID for arm64 and riscv")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20230105132349.384666-2-mpe@ellerman.id.au
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tom Saeger <tom.saeger@oracle.com>
arch/powerpc/kernel/vmlinux.lds.S