arm/execstack-native: add new recipe
PATCH 1/2 arm/execstack-native: add new recipe
From: Ross Burton <[email protected]>
Add a recipe for the execstack binary from prelink-cross. This tool is used to manipulate the GNU_STACK segment in ELF binaries, specifically to control whether the binary requests an executable stack or not.
--- .../recipes-devtools/fvp/execstack-native.bb | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 meta-arm/recipes-devtools/fvp/execstack-native.bb
meta-arm/recipes-devtools/fvp/execstack-native.bb new file +21 -0
@@ -0,0 +1,21 @@ +SUMMARY = "execstack tool" +LICENSE = "GPL-2.0-or-later" +LIC_FILES_CHKSUM = "file://COPYING;md5=c93c0550bd3173f4504b2cbd8991e50b" + +DEPENDS = "binutils-native elfutils-native" + +SRC_URI = "git://git.yoctoproject.org/prelink-cross;protocol=https;branch=master" +SRCREV = "ff2561c02ade96c5d4d56ddd4e27ff064840a176" +PV = "1.0+git${SRCPV}" + +S = "${WORKDIR}/git" + +inherit autotools native + +do_compile() { + oe_runmake -C ${B}/src execstack +} + +do_install() { + oe_runmake -C ${B}/src install-binPROGRAMS DESTDIR="${D}" +}
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH 2/2 arm/fvp-base-a-aem: remove spurious executable stack from one library
From: Ross Burton <[email protected]>
There are some objects in the FVP binary that are assembler source and fail to declare what permissions the stack needs to have, so GCC falls back to assuming that the final binary needs an executable stack.
glibc 2.41 (as now used in uninative) introduces changes here[1]: whether to have an executable stack or not when the binary doesn't specify a need (defaults to executable, but this is a tunable), and any binaries that are dlopen()ed that require an executable stack will fail.
Thus, some FVPs on some platforms (notable, fvp-base-a-aem on x86-64) now fail on startup:
libarmctmodel.so: cannot enable executable stack as shared object requires: Invalid argument
Luckily the solution here is to simply clear the executable bit, as an executable stack is not actually needed. Until a new release of the FVP is made we can fix the binary in our package using execstack.
[1] https://lists.gnu.org/archive/html/info-gnu/2025-01/msg00014.html
--- .../fvp/fvp-base-a-aem_11.25.15.bb | 3 +++ .../recipes-devtools/fvp/remove-execstack.inc | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 meta-arm/recipes-devtools/fvp/remove-execstack.inc
meta-arm/recipes-devtools/fvp/fvp-base-a-aem_11.25.15.bb +3 -0
@@ -14,3 +14,6 @@ UPSTREAM_VERSION_UNKNOWN = "1" MODEL_CODE = "FVP_Base_RevC-2xAEMvA" COMPATIBLE_HOST = "(aarch64|x86_64).*-linux" + +require remove-execstack.inc +REMOVE_EXECSTACKS:x86-64 = "${FVPDIR}/models/${FVP_ARCH_DIR}*/libarmctmodel.so"
meta-arm/recipes-devtools/fvp/remove-execstack.inc new file +26 -0
@@ -0,0 +1,26 @@ +# Clear the executable stack flag on named shared libraries. This are typically +# not needed, and glibc 2.41 will refuse to dlopen() a library that expects +# an executable stack. +# +# The stack permissions can be checked with readelf -lW <.so> | grep GNU_STACK. +# RW is read/write, RWE is read/write/execute. + +DEPENDS += "execstack-native" + +REMOVE_EXECSTACKS ?= "" + +do_install:append() { + for SO in ${REMOVE_EXECSTACKS}; do + NAME=$(basename $SO) + SO=${D}$SO + + test -f $SO || bbfatal remove-execstack: cannot find $SO + + if execstack --query $SO | grep -q ^X; then + bbnote "Stripping executable stack bit on $NAME" + execstack --clear-execstack $SO + else + bbwarn "Executable stack stripping no longer required for $NAME, remove" + fi + done +}
Signature · 1 line
2.39.5 (Apple Git-154)