From dfce2f6341556b2b4120ce281e4e30257d5e8a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Holz?= Date: Thu, 23 Nov 2023 01:38:14 +0100 Subject: [PATCH] Kernel/riscv64: Explicitly discard temporary local symbols This is for some reason needed for riscv64 clang, as otherwise the kernel.map file would grow too big to fit in its section inside the kernel image. None of our other architectures have temporary locals in their kernel.map. --- Kernel/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 773582fae0..db6cce26b7 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -759,7 +759,10 @@ if("${SERENITY_ARCH}" STREQUAL "aarch64") target_link_options(Kernel PRIVATE LINKER:-T ${CMAKE_CURRENT_SOURCE_DIR}/Arch/aarch64/linker.ld -nostdlib LINKER:--no-pie) set_target_properties(Kernel PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Arch/aarch64/linker.ld) elseif("${SERENITY_ARCH}" STREQUAL "riscv64") - target_link_options(Kernel PRIVATE LINKER:-T ${CMAKE_CURRENT_SOURCE_DIR}/Arch/riscv64/linker.ld -nostdlib LINKER:--no-pie) + # The final kernel binary for some reason includes temporary local symbols on riscv64 clang, which causes kernel.map to be too big to fit in its section in the kernel. + # Explicitly pass -X to the linker to remove them. + target_link_options(Kernel PRIVATE LINKER:-T ${CMAKE_CURRENT_SOURCE_DIR}/Arch/riscv64/linker.ld -nostdlib LINKER:--no-pie LINKER:-X) + set_target_properties(Kernel PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Arch/riscv64/linker.ld) elseif ("${SERENITY_ARCH}" STREQUAL "x86_64") add_custom_command(