linux/arch/sh/kernel
Tom Saeger c1c551bebf sh: define RUNTIME_DISCARD_EXIT
sh vmlinux fails to link with GNU ld < 2.40 (likely < 2.36) since
commit 99cb0d917f ("arch: fix broken BuildID for arm64 and riscv").

This is similar to fixes for powerpc and s390:
commit 4b9880dbf3 ("powerpc/vmlinux.lds: Define RUNTIME_DISCARD_EXIT").
commit a494398bde ("s390: define RUNTIME_DISCARD_EXIT to fix link error
with GNU ld < 2.36").

  $ sh4-linux-gnu-ld --version | head -n1
  GNU ld (GNU Binutils for Debian) 2.35.2

  $ make ARCH=sh CROSS_COMPILE=sh4-linux-gnu- microdev_defconfig
  $ make ARCH=sh CROSS_COMPILE=sh4-linux-gnu-

  `.exit.text' referenced in section `__bug_table' of crypto/algboss.o:
  defined in discarded section `.exit.text' of crypto/algboss.o
  `.exit.text' referenced in section `__bug_table' of
  drivers/char/hw_random/core.o: defined in discarded section
  `.exit.text' of drivers/char/hw_random/core.o
  make[2]: *** [scripts/Makefile.vmlinux:34: vmlinux] Error 1
  make[1]: *** [Makefile:1252: vmlinux] Error 2

arch/sh/kernel/vmlinux.lds.S keeps EXIT_TEXT:

	/*
	 * .exit.text is discarded at runtime, not link time, to deal with
	 * references from __bug_table
	 */
	.exit.text : AT(ADDR(.exit.text)) { EXIT_TEXT }

However, EXIT_TEXT is thrown away by
DISCARD(include/asm-generic/vmlinux.lds.h) because
sh does not define RUNTIME_DISCARD_EXIT.

GNU ld 2.40 does not have this issue and builds fine.
This corresponds with Masahiro's comments in a494398bde:
"Nathan [Chancellor] also found that binutils
commit 21401fc7bf67 ("Duplicate output sections in scripts") cured this
issue, so we cannot reproduce it with binutils 2.36+, but it is better
to not rely on it."

Link: https://lkml.kernel.org/r/9166a8abdc0f979e50377e61780a4bba1dfa2f52.1674518464.git.tom.saeger@oracle.com
Fixes: 99cb0d917f ("arch: fix broken BuildID for arm64 and riscv")
Link: https://lore.kernel.org/all/Y7Jal56f6UBh1abE@dev-arch.thelio-3990X/
Link: https://lore.kernel.org/all/20230123194218.47ssfzhrpnv3xfez@oracle.com/
Signed-off-by: Tom Saeger <tom.saeger@oracle.com>
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dennis Gilmore <dennis@ausil.us>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Palmer Dabbelt <palmer@rivosinc.com>
Cc: Rich Felker <dalias@libc.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-01-31 16:44:09 -08:00
..
cpu sh: sq: use default_groups in kobj_type 2022-01-05 19:11:52 +01:00
syscalls arch: syscalls: simplify uapi/kapi directory creation 2022-03-31 12:03:46 +09:00
vsyscall
.gitignore
asm-offsets.c
crash_dump.c vmcore: convert copy_oldmem_page() to take an iov_iter 2022-04-29 14:37:59 -07:00
debugtraps.S
disassemble.c
dma-coherent.c
dumpstack.c
dwarf.c
entry-common.S
ftrace.c ftrace: Cleanup ftrace_dyn_arch_init() 2021-10-08 19:41:39 -04:00
head_32.S
hw_breakpoint.c
idle.c
io_trapped.c sh: remove CONFIG_SET_FS support 2022-02-25 09:36:06 +01:00
io.c
iomap.c
ioport.c
irq_32.c
irq.c asm-generic: Conditionally enable do_softirq_own_stack() via Kconfig. 2022-09-05 17:20:55 +02:00
kdebugfs.c
kgdb.c
kprobes.c kprobes: treewide: Make it harder to refer kretprobe_trampoline directly 2021-09-30 21:24:06 -04:00
machine_kexec.c
machvec.c sh: machvec: Use char[] for section boundaries 2022-09-13 10:33:17 -07:00
Makefile kbuild: use obj-y instead extra-y for objects placed at the head 2022-10-02 18:04:05 +09:00
module.c
nmi_debug.c
perf_callchain.c
perf_event.c
process_32.c kernel: exit: cleanup release_thread() 2022-09-11 21:55:07 -07:00
process.c
ptrace_32.c sh: ptrace: user_regset_copyin_ignore() always returns 0 2022-11-15 14:30:41 -08:00
ptrace.c
reboot.c sh: Use do_kernel_power_off() 2022-05-19 19:30:31 +02:00
relocate_kernel.S
return_address.c
setup.c
sh_bios.c
sh_ksyms_32.c
signal_32.c resume_user_mode: Move to resume_user_mode.h 2022-03-10 16:51:50 -06:00
smp.c
stacktrace.c
swsusp.c
sys_sh32.c
sys_sh.c
syscalls_32.S
time.c
topology.c drivers/base/node: consolidate node device subsystem initialization in node_dev_init() 2022-03-22 15:57:10 -07:00
traps_32.c sh: remove CONFIG_SET_FS support 2022-02-25 09:36:06 +01:00
traps.c exit: Add and use make_task_dead. 2021-12-13 12:04:45 -06:00
unwinder.c
vmlinux.lds.S sh: define RUNTIME_DISCARD_EXIT 2023-01-31 16:44:09 -08:00