From bda5c02164869ac17015786d5de22c10a098709d Mon Sep 17 00:00:00 2001 From: slipher Date: Fri, 12 Dec 2025 08:50:11 -0600 Subject: [PATCH] Discard extra sections linking nacl_helper_bootstrap Use --orphan-handling=unwanted when linking nacl_helper_bootstrap which makes the linker discard any sections not explicitly mentioned in the linker script. This prevents the linker from producing a defective binary with overlapping PT_LOAD headers when using GCC on certain distros such as Ubuntu and Arch that have it configured to produce a .note.gnu.property section --- src/trusted/service_runtime/build.scons | 1 + src/trusted/service_runtime/linux/nacl_bootstrap.x | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/trusted/service_runtime/build.scons b/src/trusted/service_runtime/build.scons index 33aa2e0ebd..085d948378 100644 --- a/src/trusted/service_runtime/build.scons +++ b/src/trusted/service_runtime/build.scons @@ -428,6 +428,7 @@ if (env.Bit('linux') and not env.Bit('built_elsewhere')): [bootstrap_obj], ("env CXX='${CXX}' ${PYTHON} %s %s " + '-m %s --build-id -static -z max-page-size=0x1000 ' + + '--orphan-handling=discard ' + '--defsym RESERVE_TOP=%s --script %s -o ${TARGET} ${SOURCES}') % (bootstrap_env.File('linux/ld_bfd.py'), compiler_override, ld_emul, reserve_top, bootstrap_env.File('linux/nacl_bootstrap.x')), diff --git a/src/trusted/service_runtime/linux/nacl_bootstrap.x b/src/trusted/service_runtime/linux/nacl_bootstrap.x index b49a2a3044..93051f1058 100644 --- a/src/trusted/service_runtime/linux/nacl_bootstrap.x +++ b/src/trusted/service_runtime/linux/nacl_bootstrap.x @@ -5,8 +5,9 @@ * * This is a custom linker script used to build nacl_helper_bootstrap. * It has a very special layout. This script will only work with input - * that is kept extremely minimal. If there are unexpected input sections - * not named here, the result will not be correct. + * that is kept extremely minimal. Unexpected input sections will be + * discarded so if there are unexpected input sections not named here which + * are actually important, the result will not be correct. * * We need to use a standalone loader program rather than just using a * dynamically-linked program here because its entire address space will be