Skip to content

Commit 07b050f

Browse files
committed
powerpc/vmlinux.lds: Don't discard .rela* for relocatable builds
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 99cb0d9 ("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: 99cb0d9 ("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
1 parent 4b9880d commit 07b050f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arch/powerpc/kernel/vmlinux.lds.S

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,12 @@ SECTIONS
411411
DISCARDS
412412
/DISCARD/ : {
413413
*(*.EMB.apuinfo)
414-
*(.glink .iplt .plt .rela* .comment)
414+
*(.glink .iplt .plt .comment)
415415
*(.gnu.version*)
416416
*(.gnu.attributes)
417417
*(.eh_frame)
418+
#ifndef CONFIG_RELOCATABLE
419+
*(.rela*)
420+
#endif
418421
}
419422
}

0 commit comments

Comments
 (0)