From a2a2cfae8a36a040b25ec3d5af941b2eccf76da8 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 13 Apr 2026 08:23:05 +0800 Subject: [PATCH 1/2] Check if linker supports -z separate-code Set have-separate-code to yes if linker supports -z separate-code. Signed-off-by: H.J. Lu --- configure | 35 +++++++++++++++++++++++++++++++++++ configure.ac | 6 ++++++ 2 files changed, 41 insertions(+) diff --git a/configure b/configure index c84d283bd5..2c1a66f6c5 100755 --- a/configure +++ b/configure @@ -7350,6 +7350,41 @@ printf "%s\n" "$libc_linker_feature" >&6; } config_vars="$config_vars have-no-dynamic-linker = $libc_cv_no_dynamic_linker" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for linker that supports -z separate-code" >&5 +printf %s "checking for linker that supports -z separate-code... " >&6; } +libc_linker_feature=no +cat > conftest.c <&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } +then + if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp -Wl,-z,separate-code -nostdlib \ + -nostartfiles -fPIC -shared -o conftest.so conftest.c 2>&1 \ + | grep "warning: -z separate-code ignored" > /dev/null 2>&1; then + true + else + libc_linker_feature=yes + fi +fi +rm -f conftest* +if test $libc_linker_feature = yes; then + libc_cv_separate_code=yes +else + libc_cv_separate_code=no +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_linker_feature" >&5 +printf "%s\n" "$libc_linker_feature" >&6; } +config_vars="$config_vars +have-separate-code = $libc_cv_separate_code" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -static-pie" >&5 printf %s "checking for -static-pie... " >&6; } diff --git a/configure.ac b/configure.ac index 280ec8e5b3..71b13ad104 100644 --- a/configure.ac +++ b/configure.ac @@ -1356,6 +1356,12 @@ LIBC_LINKER_FEATURE([--no-dynamic-linker], [libc_cv_no_dynamic_linker=no]) LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker]) +LIBC_LINKER_FEATURE([-z separate-code], + [-Wl,-z,separate-code], + [libc_cv_separate_code=yes], + [libc_cv_separate_code=no]) +LIBC_CONFIG_VAR([have-separate-code], [$libc_cv_separate_code]) + LIBC_TRY_CC_AND_TEST_CC_OPTION(for -static-pie, [-static-pie], libc_cv_static_pie, [libc_cv_static_pie=yes], [libc_cv_static_pie=no], -- 2.53.0