Skip to content

Commit a4c2d66

Browse files
committed
build: Use -z noseparate-code on NetBSD < 11.0
This can be dropped once Bitcoin Core no longer supports NetBSD 10.0 or if upstream fix is backported. NetBSD's dynamic linker ld.elf_so < 11.0 supports exactly 2 `PT_LOAD` segments and binaries linked with `-z separate-code` have 4 `PT_LOAD` segments. bitcoin#28724 (comment) https://mail-index.netbsd.org/tech-userlevel/2023/01/05/msg013666.html
1 parent 8046759 commit a4c2d66

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,20 @@ if(ENABLE_HARDENING)
533533
try_append_linker_flag("-Wl,--high-entropy-va" TARGET hardening_interface)
534534
try_append_linker_flag("-Wl,-z,relro" TARGET hardening_interface)
535535
try_append_linker_flag("-Wl,-z,now" TARGET hardening_interface)
536-
try_append_linker_flag("-Wl,-z,separate-code" TARGET hardening_interface)
536+
537+
# TODO: This can be dropped once Bitcoin Core no longer supports
538+
# NetBSD 10.0 or if upstream fix is backported.
539+
# NetBSD's dynamic linker ld.elf_so < 11.0 supports exactly 2
540+
# `PT_LOAD` segments, and binaries linked with `-z separate-code`,
541+
# have 4 `PT_LOAD` segments.
542+
# Relevant discussions:
543+
# - https://github.com/bitcoin/bitcoin/pull/28724#issuecomment-2589347934
544+
# - https://mail-index.netbsd.org/tech-userlevel/2023/01/05/msg013666.html
545+
if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD" AND CMAKE_SYSTEM_VERSION VERSION_LESS 11.0)
546+
try_append_linker_flag("-Wl,-z,noseparate-code" TARGET hardening_interface)
547+
else()
548+
try_append_linker_flag("-Wl,-z,separate-code" TARGET hardening_interface)
549+
endif()
537550
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
538551
try_append_linker_flag("-Wl,-fixup_chains" TARGET hardening_interface)
539552
endif()

0 commit comments

Comments
 (0)