From patchwork Mon Jul 21 23:41:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 116714 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E8D76385C6D6 for ; Mon, 21 Jul 2025 23:44:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E8D76385C6D6 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=UrAoNHWS X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id 465EE385C6C9 for ; Mon, 21 Jul 2025 23:42:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 465EE385C6C9 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 465EE385C6C9 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::336 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1753141367; cv=none; b=Zvtrzim0SR6UJA/cu+9+owZxRdhVkW9tS2I/v84IRqjtZevyVmc/dlQs+3T7Jd3CV4nbXwoxwoUs8518L0lDHnzocOA2i5HRErC/osIn5RS7InaUTJ4AKZfgdf9tDmxuFq58taRn1tZct4bv9USZYDAyc+NXs6a89GDVgSVOa1Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1753141367; c=relaxed/simple; bh=elXrCiuBDOvpVc3gbr1Oe4IxHCp1EDTASxk11a8lhUI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=s9/Dn7QQrDuDzR8VzRBFn+m/tP2fEfGhqPV8pP36ra2PilLIa3hePVXuFoqBI62V2xUkmsqfUeH6bRb8xLdc1+gSefUS+zl0NiJho4z3TqAfRs4X4vCmEjm7Nw0WTUbwM5Xq6OnjCcePS+zQ46eANSrQ1MFv1qn5TVT7+MZDje0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 465EE385C6C9 Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-73e5e3c6a37so3269322a34.0 for ; Mon, 21 Jul 2025 16:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753141366; x=1753746166; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BhwOjFbmJD9bQ3mtwDTGx/WgCP2+eiMh6ZdZum8XRiE=; b=UrAoNHWSRltin6qiiagdS466Fnt79M11mzfhgltv27dickNY/Ne4CE9YV6qbWxCzil x9769kfp6LdIUxLBL77VNBvLM7oRnq+M2nTDZ+4IPHQWC88OYk7Qz8t1XxT1yhyE7rnD E/iBch2Y2K1ZaqBA1jQ8S+7Yp/EGbExb0EhC9vy+NkHb3Pfwv478DkkF13O87zTZk4Ed EJbXRAiXqcIpVyexrS2mY//TGpaUAnj/kpJsMIhPgKtYEQ4LsiG/kvzibdnheWKdxADg FekM+qOtF2rZl1SJiILEo+0vZacZNYpBrRPpTXbnvmN1cQcrIRFmBGjtmmtpz8H7Wyxh b9Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753141366; x=1753746166; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BhwOjFbmJD9bQ3mtwDTGx/WgCP2+eiMh6ZdZum8XRiE=; b=Zh+Ea5FRRFkNHdHoknd06qQrqZ1celpU87z9Ks5/bTqaYC8Q4+pOPaZMVqjx1WEjuX tk47fRb36jeBQZfJ1jZq+jRzkXR6HCZTEgV5HicVWj5XrUNUyhdm3KH/lYtt2mtRl0m+ 6v73/RFVCOLeTrAhvABUV/RDUu/w31vqetRVeKs7K7ldu2/tGVksppV/AGvM/r1eAJMC iux3lGBaCsnijWN/Vx6S1L2WdPPyUBfoRi1b0jTCnbfYqrg6xt8VurVf6Sbl4CvP8ts/ FysRbpqUIgmP/ctAG5xAvKv41d3A2FJzq1AhXRGN29uU3qVAAaMdvDNQrOiuj3R0FNN1 PSYg== X-Gm-Message-State: AOJu0YyXCX07Ula7YZ9oHeIpy12LV2wA/buVNTVxDr7HwCgpAl1AGjsx GvmD5rAo3c0UZWqAzWcJAM6Weh8O9qPL1X0PVM56u7NLzWas5tBJ4+h+TSKv23Ib9uOy1nUH4sj dxrEK X-Gm-Gg: ASbGncu582dQObzkwardHmyY+G7HZ2to21PwOewsPkTZXna42c8Z2YJVpNPREtrr1tm btYId0IMXZu1KXJiMQC5T9nVtMhi7M+Df+QC8HuDrZsIh9ZGAiTDPJCLiOWDcTtQK49nRZDwVbz ZxY6G30PdZ6RyfPnn/IXwvo3G33fzK6oXcJF80mM45sNAAbwOlsnfJnW/AGD/oZ4MopoE08Gz9t mKaCFeGG5nB3n1rS57FElMmhj7bPhk3d+n9UNepPwm8C2XHg4MphIzpTL+BfPAYQS7H+F5M9tmD F7dIJpf5KRi68tI7cDJnF6MywnKtBLuAVZDlGaqFZX0RaeSRzxBXf7DX7yezQ6zscg+K+DNygH7 u6AMFYIJOdgr0ZJlwe/ykLznXiM5zUv//XRM= X-Google-Smtp-Source: AGHT+IFYBnLPlNc3dO57r/723qnQTRrLr65iSwiZFH/CCw6w3mpNPOd88TwOy1HlAbw2sqsg2z6pOQ== X-Received: by 2002:a05:6830:3495:b0:72b:9c34:1361 with SMTP id 46e09a7af769-73e661b4beemr15043311a34.15.1753141365759; Mon, 21 Jul 2025 16:42:45 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:aa11:1ab1:a6b6:2142:527c]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73ebbad3b08sm334593a34.47.2025.07.21.16.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 16:42:45 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org, =?utf-8?q?Andreas_K_=2E_H=C3=BCttel?= Cc: Jose Marchesi , Elena Zannoni , indu.bhagat@oracle.com, jremus@linux.ibm.com, Florian Weimer , Claudiu Zissulecu-Ianculesecu , Cupertino Miranda Subject: [PATCH v2 1/2] Disable SFrame support by default Date: Mon, 21 Jul 2025 20:41:26 -0300 Message-ID: <20250721234236.1434590-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250721234236.1434590-1-adhemerval.zanella@linaro.org> References: <20250721234236.1434590-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org And add extra checks to enable for binutils 2.45 and if the archicture explicitly enables it. When SFrame is disabled, all the related code is also not enabled for backtrace() and _dl_find_object(), so SFrame backtracking is not used even if the binary has the SFrame segment. This patch also adds some other related fixes: * Fixed an issue with AC_CHECK_PROG_VER, where the READELF_SFRAME usage prevented specifying a different readelf through READELF environment variable at configure time. * Add an extra arch-specific internal definition, libc_cv_support_sframe, to disable --enable-sframe on architectures that have binutils but not glibc support (s390x). * Renamed the tests without the .sframe segment and move the tst-backtrace1 from pthread to debug. * Use the built compiler strip to remove the .sframe segment, instead of the system one (which might not support SFrame). Checked on x86_64-linux-gnu and aarch64-linux-gnu. Reviewed-by: Sam James --- INSTALL | 9 +-- aclocal.m4 | 4 ++ config.h.in | 3 + config.make.in | 2 +- configure | 62 ++++++++++++--------- configure.ac | 26 +++++---- debug/Makefile | 16 ++++-- debug/backtrace.c | 8 +++ {sysdeps/pthread => debug}/tst-backtrace1.c | 0 elf/dl-find_object.h | 10 ++++ manual/install.texi | 11 ++-- sysdeps/aarch64/configure | 2 + sysdeps/aarch64/configure.ac | 2 + sysdeps/generic/Makefile | 2 + sysdeps/pthread/Makefile | 1 - sysdeps/x86_64/configure | 2 + sysdeps/x86_64/configure.ac | 2 + 17 files changed, 108 insertions(+), 54 deletions(-) rename {sysdeps/pthread => debug}/tst-backtrace1.c (100%) diff --git a/INSTALL b/INSTALL index cf60e1a380..85382a8139 100644 --- a/INSTALL +++ b/INSTALL @@ -291,10 +291,11 @@ passed to 'configure'. For example: Default is to disable fortification. -'--disable-sframe' - By default, the GNU C Library is built with '-Wa,--gsframe' if the - current GNU 'binutils' supports it. You may want to use this - option if you don't plan to use SFrame stack tracer. +'--enable-sframe' + Experimental option supported by some architectures, where + the GNU C Library is built with '-Wa,--gsframe' if the binutils + supports it. You may want to use this option if you plan to use + SFrame stack tracer. To build the library and related programs, type 'make'. This will produce a lot of output, some of which may look like errors from 'make' diff --git a/aclocal.m4 b/aclocal.m4 index e06366cdb2..450646b0e4 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -145,6 +145,10 @@ if test -z "$NM"; then NM=`$CC -print-prog-name=nm` fi AC_SUBST(NM) +if test -z "$STRIP"; then + STRIP=`$CC -print-prog-name=nm` +fi +AC_SUBST(STRIP) ]) dnl Run a static link test with -nostdlib -nostartfiles. diff --git a/config.h.in b/config.h.in index 29126ea933..8b4077f578 100644 --- a/config.h.in +++ b/config.h.in @@ -287,6 +287,9 @@ /* Define if static PIE is enabled. */ #define ENABLE_STATIC_PIE 0 +/* Define if SFrame v2 is enabled. */ +#define ENABLE_SFRAME 0 + /* The default value of x86 CET control. */ #define DEFAULT_DL_X86_CET_CONTROL cet_elf_property diff --git a/config.make.in b/config.make.in index 382e003d87..fca75ab5d3 100644 --- a/config.make.in +++ b/config.make.in @@ -51,7 +51,6 @@ c++-cstdlib-header = @CXX_CSTDLIB_HEADER@ c++-cmath-header = @CXX_CMATH_HEADER@ c++-bits-std_abs-h = @CXX_BITS_STD_ABS_H@ enable-werror = @enable_werror@ -enable-gsframe = @enable_gsframe@ have-z-execstack = @libc_cv_z_execstack@ have-no-error-execstack = @libc_cv_no_error_execstack@ @@ -114,6 +113,7 @@ OBJDUMP = @OBJDUMP@ OBJCOPY = @OBJCOPY@ GPROF = @GPROF@ READELF = @READELF@ +STRIP = @STRIP@ # Installation tools. INSTALL = @INSTALL@ diff --git a/configure b/configure index 6595d6be54..2efa7e1bde 100755 --- a/configure +++ b/configure @@ -620,8 +620,6 @@ DEFINES static_nss profile libc_cv_multidir -enable_gsframe -READELF_SFRAME libc_cv_test_x86_have_amx_tile test_enable_cet libc_cv_test_cc_mprefer_vector_width @@ -694,6 +692,7 @@ MAKEINFO MSGFMT MAKE LD +STRIP NM OBJDUMP READELF @@ -1510,8 +1509,8 @@ Optional Features: Use -D_FORTIFY_SOURCE=[1|2|3] to control code hardening, defaults to highest possible value supported by the build compiler. - --disable-sframe Disable building with SFrame stack trace information - [default=yes if GNU as is 2.41 or older] + --enable-sframe Enable building with SFrame stack trace information + [default=no] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -4895,7 +4894,7 @@ if test ${enable_sframe+y} then : enableval=$enable_sframe; use_sframe=$enableval else case e in #( - e) use_sframe=notset ;; + e) use_sframe=no ;; esac fi @@ -5142,6 +5141,10 @@ if test -z "$NM"; then NM=`$CC -print-prog-name=nm` fi +if test -z "$STRIP"; then + STRIP=`$CC -print-prog-name=nm` +fi + # Accept binutils 2.39 or newer. @@ -9357,7 +9360,7 @@ have-libgcc_s = $libc_cv_have_libgcc_s" # Glibc stacktracer supports SFrame v2 or newer -libc_cv_readelf_version_ok=yes +libc_cv_sframe_readelf_version=yes # SFrame is supported from 2.41 or higher for ac_prog in $READELF do @@ -9365,12 +9368,12 @@ do set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_READELF_SFRAME+y} +if test ${ac_cv_prog_READELF+y} then : printf %s "(cached) " >&6 else case e in #( - e) if test -n "$READELF_SFRAME"; then - ac_cv_prog_READELF_SFRAME="$READELF_SFRAME" # Let the user override the test. + e) if test -n "$READELF"; then + ac_cv_prog_READELF="$READELF" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -9383,7 +9386,7 @@ do esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_READELF_SFRAME="$ac_prog" + ac_cv_prog_READELF="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi @@ -9394,29 +9397,29 @@ IFS=$as_save_IFS fi ;; esac fi -READELF_SFRAME=$ac_cv_prog_READELF_SFRAME -if test -n "$READELF_SFRAME"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $READELF_SFRAME" >&5 -printf "%s\n" "$READELF_SFRAME" >&6; } +READELF=$ac_cv_prog_READELF +if test -n "$READELF"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $READELF" >&5 +printf "%s\n" "$READELF" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi - test -n "$READELF_SFRAME" && break + test -n "$READELF" && break done -if test -z "$READELF_SFRAME"; then +if test -z "$READELF"; then ac_verc_fail=yes else # Found it, now check the version. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking version of $READELF_SFRAME" >&5 -printf %s "checking version of $READELF_SFRAME... " >&6; } - ac_prog_version=`$READELF_SFRAME --version 2>&1 | sed -n 's/^.*GNU readelf.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'` + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking version of $READELF" >&5 +printf %s "checking version of $READELF... " >&6; } + ac_prog_version=`$READELF --version 2>&1 | sed -n 's/^.*GNU readelf.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'` case $ac_prog_version in '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; - 2.4[1-9]*|2.[5-9][0-9]*|[3-9].*|[1-9][0-9][0-9]*) + 2.4[5-9]*|2.[5-9][0-9]*|[3-9].*|[1-9][0-9][0-9]*) ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; @@ -9425,12 +9428,12 @@ printf %s "checking version of $READELF_SFRAME... " >&6; } printf "%s\n" "$ac_prog_version" >&6; } fi if test $ac_verc_fail = yes; then - libc_cv_readelf_version_ok=no + libc_cv_sframe_readelf_version=no fi # Check the current toolchain for SFrame support -if test $libc_cv_readelf_version_ok = yes; then +if test $libc_cv_sframe_readelf_version = yes; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SFrame support" >&5 printf %s "checking for SFrame support... " >&6; } if test ${libc_cv_default_sframe+y} @@ -9459,16 +9462,23 @@ fi # Prevent enabling sframe on non-supporting toolchains enable_gsframe=no -if test $use_sframe$libc_cv_default_sframe = yesyes || \ - test $use_sframe$libc_cv_default_sframe = notsetyes; then - enable_gsframe=yes +if test $use_sframe$libc_cv_default_sframe$libc_cv_support_sframe = yesyesyes; then + enable_gsframe=yes + printf "%s\n" "#define ENABLE_SFRAME 1" >>confdefs.h + +elif test -z $libc_cv_support_sframe; then + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "the architecture doesn't support SFrame +See 'config.log' for more details" "$LINENO" 5; } elif test $use_sframe = yes; then { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error $? "toolchain doesn't support SFrame v2 or higher See 'config.log' for more details" "$LINENO" 5; } fi - +config_vars="$config_vars +enable-gsframe = $enable_gsframe" # Set the `multidir' variable by grabbing the variable from the compiler. # We do it once and save the result in a generated makefile. diff --git a/configure.ac b/configure.ac index 25b80e34e4..13fc4624ce 100644 --- a/configure.ac +++ b/configure.ac @@ -441,10 +441,10 @@ case "$enable_fortify_source" in esac AC_ARG_ENABLE([sframe], - [AS_HELP_STRING([--disable-sframe], - [Disable building with SFrame stack trace information @<:@default=yes if GNU as is 2.41 or older@:>@])], + [AS_HELP_STRING([--enable-sframe], + [Enable building with SFrame stack trace information @<:@default=no@:>@])], [use_sframe=$enableval], - [use_sframe=notset]) + [use_sframe=no]) # We keep the original values in `$config_*' and never modify them, so we # can write them unchanged into config.make. Everything else uses @@ -2122,15 +2122,15 @@ AC_SUBST(test_enable_cet) AC_SUBST(libc_cv_test_x86_have_amx_tile) # Glibc stacktracer supports SFrame v2 or newer -libc_cv_readelf_version_ok=yes +libc_cv_sframe_readelf_version=yes # SFrame is supported from 2.41 or higher -AC_CHECK_PROG_VER(READELF_SFRAME, $READELF, --version, +AC_CHECK_PROG_VER(READELF, $READELF, --version, [GNU readelf.* \([0-9][0-9]*\.[0-9.]*\)], - [2.4[1-9]*|2.[5-9][0-9]*|[3-9].*|[1-9][0-9][0-9]*], - libc_cv_readelf_version_ok=no) + [2.4[5-9]*|2.[5-9][0-9]*|[3-9].*|[1-9][0-9][0-9]*], + libc_cv_sframe_readelf_version=no) # Check the current toolchain for SFrame support -if test $libc_cv_readelf_version_ok = yes; then +if test $libc_cv_sframe_readelf_version = yes; then AC_CACHE_CHECK([for SFrame support], libc_cv_default_sframe, [dnl cat > conftest.c < #include #include +#if ENABLE_SFRAME #include +#endif struct trace_arg { @@ -31,6 +33,7 @@ struct trace_arg int size; }; +#if ENABLE_SFRAME /* Initialize the SFrame backtrace routine and attempt to backtrace the current stack using SFrame information. For the SFrame backtrace to be considered valid, the tracer must return more than @@ -64,6 +67,7 @@ do_sframe_backtrace (void **array, int size) frame.fp = (_Unwind_Ptr) __builtin_frame_address (0); return __stacktrace_sframe (array, size, &frame); } +#endif static _Unwind_Reason_Code backtrace_helper (struct _Unwind_Context *ctx, void *a) @@ -110,6 +114,7 @@ __backtrace (void **array, int size) if (size <= 0) return 0; +#if ENABLE_SFRAME /* Try first the SFrame backtracer. */ int cnt = do_sframe_backtrace (array, size); if (cnt > 1) @@ -117,6 +122,9 @@ __backtrace (void **array, int size) /* Try the dwarf unwinder. */ if (arg.unwind_link == NULL) +#else + if (arg.unwind_link == NULL) +#endif return 0; UNWIND_LINK_PTR (arg.unwind_link, _Unwind_Backtrace) diff --git a/sysdeps/pthread/tst-backtrace1.c b/debug/tst-backtrace1.c similarity index 100% rename from sysdeps/pthread/tst-backtrace1.c rename to debug/tst-backtrace1.c diff --git a/elf/dl-find_object.h b/elf/dl-find_object.h index 9aa2439eaa..6a50b4becf 100644 --- a/elf/dl-find_object.h +++ b/elf/dl-find_object.h @@ -43,7 +43,9 @@ struct dl_find_object_internal #if DLFO_STRUCT_HAS_EH_COUNT int eh_count; #endif +#if ENABLE_SFRAME void *sframe; +#endif }; /* Create a copy of *SOURCE in *COPY using relaxed MO loads and @@ -68,8 +70,10 @@ _dl_find_object_internal_copy (const struct dl_find_object_internal *source, atomic_store_relaxed (©->eh_count, atomic_load_relaxed (&source->eh_count)); #endif +#if ENABLE_SFRAME atomic_store_relaxed (©->sframe, atomic_load_relaxed (&source->sframe)); +#endif } static inline void @@ -86,10 +90,12 @@ _dl_find_object_to_external (struct dl_find_object_internal *internal, # if DLFO_STRUCT_HAS_EH_COUNT external->dlfo_eh_count = internal->eh_count; # endif +# if ENABLE_SFRAME external->dlfo_sframe = internal->sframe; if (internal->sframe != NULL) external->dlfo_flags = DLFO_FLAG_SFRAME; else +# endif external->dlfo_flags = 0; } @@ -112,7 +118,9 @@ _dl_find_object_from_map (struct link_map *l, /* Initialize object's exception handling segment and SFrame segment data. */ +#if ENABLE_SFRAME atomic_store_relaxed (&result->sframe, NULL); +#endif atomic_store_relaxed (&result->eh_frame, NULL); #if DLFO_STRUCT_HAS_EH_COUNT atomic_store_relaxed (&result->eh_count, 0); @@ -132,11 +140,13 @@ _dl_find_object_from_map (struct link_map *l, read_seg |= 1; break; +#if ENABLE_SFRAME case PT_GNU_SFRAME: atomic_store_relaxed (&result->sframe, (void *) (ph->p_vaddr + l->l_addr)); read_seg |= 2; /* Fall through. */ +#endif default: break; } diff --git a/manual/install.texi b/manual/install.texi index 0c8d448362..e360aa7589 100644 --- a/manual/install.texi +++ b/manual/install.texi @@ -321,10 +321,13 @@ the build compiler. Default is to disable fortification. -@item --disable-sframe -By default, the GNU C Library is built with @option{-Wa,--gsframe} if -the current GNU @code{binutils} supports it. You may want to use this -option if you don't plan to use SFrame stack tracer. +@item --enable-sframe +Experimental option supported by some architectures, where @theglibc{}i +is built with @option{-Wa,--gsframe} if the @code{binutils} supports it. +Currently it is only support on x86_64 and aarch64 it is required te +enable SFrame support on @code{backtrace} and @code{_dl_find_object}. + +Default is to disable SFrame support. @end table To build the library and related programs, type @code{make}. This will diff --git a/sysdeps/aarch64/configure b/sysdeps/aarch64/configure index 26a0989a33..f364e65fe7 100755 --- a/sysdeps/aarch64/configure +++ b/sysdeps/aarch64/configure @@ -194,3 +194,5 @@ if test $build_mathvec = no; then printf "%s\n" "$as_me: WARNING: mathvec is disabled, this results in incomplete ABI." >&2;} fi +libc_cv_support_sframe=yes + diff --git a/sysdeps/aarch64/configure.ac b/sysdeps/aarch64/configure.ac index 22fca8b565..a9a1b747f1 100644 --- a/sysdeps/aarch64/configure.ac +++ b/sysdeps/aarch64/configure.ac @@ -31,3 +31,5 @@ fi if test $build_mathvec = no; then AC_MSG_WARN([mathvec is disabled, this results in incomplete ABI.]) fi + +libc_cv_support_sframe=yes diff --git a/sysdeps/generic/Makefile b/sysdeps/generic/Makefile index c48e713eb3..1be63b74ce 100644 --- a/sysdeps/generic/Makefile +++ b/sysdeps/generic/Makefile @@ -21,7 +21,9 @@ CFLAGS-wordcopy.c += -Wno-uninitialized endif ifeq ($(subdir),elf) +ifeq ($(enable-gsframe),yes) sysdep_routines += sframe-read sframe +endif ifeq (yes:yes,$(build-shared):$(unwind-find-fde)) # This is needed to support g++ v2 and v3. sysdep_routines += framestate unwind-pe diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile index de146dddeb..7572f62cc0 100644 --- a/sysdeps/pthread/Makefile +++ b/sysdeps/pthread/Makefile @@ -62,7 +62,6 @@ tests += \ tst-abstime \ tst-atfork1 \ tst-attr1 \ - tst-backtrace1 \ tst-bad-schedattr \ tst-barrier1 \ tst-barrier2 \ diff --git a/sysdeps/x86_64/configure b/sysdeps/x86_64/configure index bbf520bfc9..32324f62da 100644 --- a/sysdeps/x86_64/configure +++ b/sysdeps/x86_64/configure @@ -289,6 +289,8 @@ fi config_vars="$config_vars have-x86-apx = $libc_cv_x86_have_apx" +libc_cv_support_sframe=yes + test -n "$critic_missing" && as_fn_error $? " *** $critic_missing" "$LINENO" 5 diff --git a/sysdeps/x86_64/configure.ac b/sysdeps/x86_64/configure.ac index 4a3f7f4541..a00958e219 100644 --- a/sysdeps/x86_64/configure.ac +++ b/sysdeps/x86_64/configure.ac @@ -104,5 +104,7 @@ if test $libc_cv_x86_have_apx = yes; then fi LIBC_CONFIG_VAR([have-x86-apx], [$libc_cv_x86_have_apx]) +libc_cv_support_sframe=yes + test -n "$critic_missing" && AC_MSG_ERROR([ *** $critic_missing]) From patchwork Mon Jul 21 23:41:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 116715 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1D6DE385C6E0 for ; Mon, 21 Jul 2025 23:46:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D6DE385C6E0 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=s8pbfzIY X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 665CA385C6FF for ; Mon, 21 Jul 2025 23:45:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 665CA385C6FF Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 665CA385C6FF Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::32e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1753141506; cv=none; b=cRF9rGdzF9YKad+bfHewYrcr7me6cJySP/qgfFJOvKypqOlEVd5B7kioJqvf/bAwRTaF3SPPNHQjbw4qHSWcPlHlmINyj1JgFuK/4H8muxPVNPFvVwd13tb4x2fS/cGyXIQ8IQgNsTPosYJ0r7FfA7wu9FRId+jc3foKdwEKRfA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1753141506; c=relaxed/simple; bh=wPjj5H9jnlEt6h9Dy04+/9DMJQiQV0ktesM0iykBUyk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=xZ2ETTh912Vrg2ZioQLp4qi0fBVT3QdYtTB7yWToEKfgu7SmDaTNsPQuuXTf4hBXjnN8hcfI9f5Bl89gh0cpjbpyH6Nve3b3+YZXgs9/PgGBCNGWNVAOJpe40TvkWX/lP+/jS9p0zNQxA3H08Wgkdc72lboWpZQogsXrw1wWYGs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 665CA385C6FF Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-73e62d692fbso2741721a34.2 for ; Mon, 21 Jul 2025 16:45:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753141505; x=1753746305; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rMp7vBIIZrj9wUxy9Pp4IASpNzZsPuffZNoJwob2x/s=; b=s8pbfzIY6Z34N0tptre1rseh8jyrqhIbyxz3ih9ydTGMegBhMJBzSc2W67R8vKsT/o GoXjNtlxRXANAoaeYKCqn8VB8hoEAsNBJN9NE/QoKXC2roxGkRJNX2Fl7eROOYIoDSuz uYC7yR7sby6a7jBp5rO+YC+4/JStRAvXRKR01dJJ3epbAlBfd7JBXB9VAGwFB9arHfmc wrnG+wAhjGVA+V2ldrtt2MfNz5eW0jfvN4ly9PV3GwM1vhY6aZ7KAiuqQIJ011IyxY6Y 0h2gCXp6nfp6AfpmKgMY7+Spm4QV2FMSdJ6jM+W7ZOdvEZSmZc/1smjYCgEm7Yyext3n v3Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753141505; x=1753746305; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rMp7vBIIZrj9wUxy9Pp4IASpNzZsPuffZNoJwob2x/s=; b=rJav4IpurXohpTrhV9nabI+2ZBkUOHRDQ5jwOg5HWn1AM8SjF/d0x8Qw46jhnhfHjs 4eVKtBZWW8DRSSSeALOFOrjpPT5rQdEvIDIVp4i31EVOdyzF762ffyrkjSUm5guQ0Amx GJWWhhneLHx+vMdko6gU/4jid/WCZWSQtX5Pdmqx4VCvxBoQnC21eE3r+4e017t5Y0TU uYUOu1+PhrGiZw3AFPcBMslRMja0kraaZmGx+0VepyazQngVPgJ8dAFWxxkMYlj4LvpC yFx6lcM7R/egv2tAkxDgJrO5KDyZf29Rwqw9mRpsk3J1rtaS5HTyRMWrOnKM1/2lYfYW WIXQ== X-Gm-Message-State: AOJu0YyRAA3njekQyFiU9D9U/S+nU3ueD0NyGJCljAZwgchHSPVU3ewm 7dymqhYMBzySlgzlUam5Q2xd/eFhXMFPisQXRIJfnpmDBQ50Ar7n0FceYR8DP4YTrCyo6HoRW23 bZCGq X-Gm-Gg: ASbGncv40QPF2TV3hR77rSEEM8AVKwXo8HYfAiZ2v1u+tNAhSGPwC9jgf2YMi0PKi9w TbpqsKPCuGPJ8SRC8z8veQ5Wc0eWphBd/uiujuvUwFL4HbNL0TYvPB1xolPg4pEhc8UQ6I0XZ35 Wcpyc8q5vVCABH8ftTW5HibElCCcqB5nnvsu9YeFtSVb4YdOYnUHueX4QW8iZHWIiqZY9GL6Tlu QoddZayGAzyUVW164kp3jQzcqnnb4HXn1l9NZJrxZ/EDUBbqiSdapH1kHQTkj/X5XB9CfRDnDAj ugGu88cSaE4fhH4Tk/8ZOuius6Sk3YaSAYOPJCASryJB1fqMH0da0jv+vVrAhbJULl1zlf0CuOk g03zl/IiMkN9AUzKH9kmp4S3u1yNphVSpzXY= X-Google-Smtp-Source: AGHT+IE8rGF/wzel2mTNIT6Crfz6X3ZWkYv869p44jCINJ9iIekDXFliudAO0yNVoqQnPYFUu9w2RA== X-Received: by 2002:a05:6830:7198:b0:727:3b06:112 with SMTP id 46e09a7af769-73e64a8ca2fmr16545187a34.14.1753141504923; Mon, 21 Jul 2025 16:45:04 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:aa11:1ab1:a6b6:2142:527c]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73ebbad3b08sm334593a34.47.2025.07.21.16.45.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 16:45:04 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org, =?utf-8?q?Andreas_K_=2E_H=C3=BCttel?= Cc: Jose Marchesi , Elena Zannoni , indu.bhagat@oracle.com, jremus@linux.ibm.com, Florian Weimer , Claudiu Zissulecu-Ianculesecu , Cupertino Miranda Subject: [PATCH v2 2/2] sframe: Add support for SFRAME_F_FDE_FUNC_START_PCREL flag Date: Mon, 21 Jul 2025 20:41:27 -0300 Message-ID: <20250721234236.1434590-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250721234236.1434590-1-adhemerval.zanella@linaro.org> References: <20250721234236.1434590-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org From: Claudiu Zissulescu The Sframe V2 has a new errata which introduces the SFRAME_F_FDE_FUNC_START_PCREL flag. This flag indicates the encoding of the SFrame FDE function start address field like this: - if set, sfde_func_start_address field contains the offset in bytes to the start PC of the associated function from the field itself. - if unset, sfde_func_start_address field contains the offset in bytes to the start PC of the associated function from the start of the SFrame section. Signed-off-by: Claudiu Zissulescu Reviewed-by: Sam James --- sysdeps/generic/sframe-read.c | 128 ++++++++++++++++++++++++++-------- sysdeps/generic/sframe-read.h | 6 ++ sysdeps/generic/sframe.h | 15 +++- 3 files changed, 118 insertions(+), 31 deletions(-) diff --git a/sysdeps/generic/sframe-read.c b/sysdeps/generic/sframe-read.c index d536575b2d..a6ebc42d66 100644 --- a/sysdeps/generic/sframe-read.c +++ b/sysdeps/generic/sframe-read.c @@ -75,11 +75,10 @@ sframe_get_fde_type (sframe_func_desc_entry *fdep) static bool sframe_header_sanity_check_p (sframe_header *hp) { - uint8_t all_flags = SFRAME_F_FDE_SORTED | SFRAME_F_FRAME_POINTER; /* Check preamble is valid. */ if ((hp->sfh_preamble.sfp_magic != SFRAME_MAGIC) || (hp->sfh_preamble.sfp_version != SFRAME_VERSION_2) - || ((hp->sfh_preamble.sfp_flags | all_flags) != all_flags)) + || (hp->sfh_preamble.sfp_flags & ~SFRAME_V2_F_ALL_FLAGS)) return false; /* Check offsets are valid. */ @@ -171,25 +170,103 @@ sframe_fre_entry_size (sframe_frame_row_entry *frep, size_t addr_size) + sframe_fre_offset_bytes_size (fre_info)); } -/* Check whether for the given FDEP, the SFrame Frame Row Entry identified via - the START_IP_OFFSET and the END_IP_OFFSET, provides the stack trace - information for the PC. */ +/* Get SFrame header from the given decoder context DCTX. */ + +static inline sframe_header * +sframe_decoder_get_header (sframe_decoder_ctx *dctx) +{ + sframe_header *hp = NULL; + if (dctx != NULL) + hp = &dctx->sfd_header; + return hp; +} + +/* Get the offset of the sfde_func_start_address field (from the start of the + on-disk layout of the SFrame section) of the FDE at FUNC_IDX in the decoder + context DCTX. */ + +static uint32_t +sframe_decoder_get_offsetof_fde_start_addr (sframe_decoder_ctx *dctx, + uint32_t func_idx, + _Unwind_Reason_Code *errp) +{ + sframe_header *dhp; + + dhp = sframe_decoder_get_header (dctx); + if (dhp == NULL) + { + if (errp != NULL) + *errp = _URC_END_OF_STACK; + return 0; + } + + if (func_idx >= dhp->sfh_num_fdes) + { + if (errp != NULL) + *errp = _URC_END_OF_STACK; + return 0; + } + else if (errp != NULL) + *errp = _URC_NO_REASON; + + return (sframe_get_hdr_size (dhp) + + func_idx * sizeof (sframe_func_desc_entry) + + offsetof (sframe_func_desc_entry, sfde_func_start_address)); +} + + +/* Get the offset of the start PC of the SFrame FDE at FUNC_IDX from + the start of the SFrame section. If the flag + SFRAME_F_FDE_FUNC_START_PCREL is set, sfde_func_start_address is + the offset of the start PC of the function from the field itself. + + If FUNC_IDX is not a valid index in the given decoder object, returns 0. */ + +static int32_t +sframe_decoder_get_secrel_func_start_addr (sframe_decoder_ctx *dctx, + uint32_t func_idx) +{ + int32_t func_start_addr; + _Unwind_Reason_Code err = 0; + int32_t offsetof_fde_in_sec = 0; + + /* Check if we have SFRAME_F_FDE_FUNC_START_PCREL. */ + sframe_header *sh = &dctx->sfd_header; + if ((sh->sfh_preamble.sfp_flags & SFRAME_F_FDE_FUNC_START_PCREL)) + { + offsetof_fde_in_sec = + sframe_decoder_get_offsetof_fde_start_addr (dctx, func_idx, &err); + /* If func_idx is not a valid index, return 0. */ + if (err == _URC_END_OF_STACK) + return 0; + } + + func_start_addr = dctx->sfd_funcdesc[func_idx].sfde_func_start_address; + + return func_start_addr + offsetof_fde_in_sec; +} + +/* Check if the SFrame Frame Row Entry identified via the + START_IP_OFFSET and the END_IP_OFFSET (for SFrame FDE at + FUNC_IDX). */ static bool -sframe_fre_check_range_p (sframe_func_desc_entry *fdep, +sframe_fre_check_range_p (sframe_decoder_ctx *dctx, uint32_t func_idx, uint32_t start_ip_offset, uint32_t end_ip_offset, int32_t pc) { + sframe_func_desc_entry *fdep; int32_t func_start_addr; uint8_t rep_block_size; uint32_t fde_type; uint32_t pc_offset; bool mask_p; + fdep = &dctx->sfd_funcdesc[func_idx]; if (fdep == NULL) return false; - func_start_addr = fdep->sfde_func_start_address; + func_start_addr = sframe_decoder_get_secrel_func_start_addr (dctx, func_idx); fde_type = sframe_get_fde_type (fdep); mask_p = (fde_type == SFRAME_FDE_TYPE_PCMASK); rep_block_size = fdep->sfde_func_rep_size; @@ -207,19 +284,6 @@ sframe_fre_check_range_p (sframe_func_desc_entry *fdep, return (start_ip_offset <= pc_offset) && (end_ip_offset >= pc_offset); } -/* The SFrame Decoder. */ - -/* Get SFrame header from the given decoder context DCTX. */ - -static inline sframe_header * -sframe_decoder_get_header (sframe_decoder_ctx *dctx) -{ - sframe_header *hp = NULL; - if (dctx != NULL) - hp = &dctx->sfd_header; - return hp; -} - /* Get IDX'th offset from FRE. Set ERRP as applicable. */ static int32_t @@ -298,7 +362,7 @@ sframe_decode_fre_start_address (const char *fre_buf, static sframe_func_desc_entry * sframe_get_funcdesc_with_addr_internal (sframe_decoder_ctx *ctx, int32_t addr, - int *errp) + int *errp, uint32_t *func_idx) { sframe_header *dhp; sframe_func_desc_entry *fdp; @@ -319,19 +383,23 @@ sframe_get_funcdesc_with_addr_internal (sframe_decoder_ctx *ctx, int32_t addr, /* Do the binary search. */ fdp = (sframe_func_desc_entry *) ctx->sfd_funcdesc; low = 0; - high = dhp->sfh_num_fdes; + high = dhp->sfh_num_fdes - 1; while (low <= high) { int mid = low + (high - low) / 2; /* Given sfde_func_start_address <= addr, addr - sfde_func_start_address must be positive. */ - if (fdp[mid].sfde_func_start_address <= addr - && ((uint32_t)(addr - fdp[mid].sfde_func_start_address) + if (sframe_decoder_get_secrel_func_start_addr (ctx, mid) <= addr + && ((uint32_t)(addr - sframe_decoder_get_secrel_func_start_addr (ctx, + mid)) < fdp[mid].sfde_func_size)) - return fdp + mid; + { + *func_idx = mid; + return fdp + mid; + } - if (fdp[mid].sfde_func_start_address < addr) + if (sframe_decoder_get_secrel_func_start_addr (ctx, mid) < addr) low = mid + 1; else high = mid - 1; @@ -510,6 +578,7 @@ __sframe_find_fre (sframe_decoder_ctx *ctx, int32_t pc, sframe_frame_row_entry *frep) { sframe_func_desc_entry *fdep; + uint32_t func_idx; uint32_t fre_type, i; uint32_t start_ip_offset; int32_t func_start_addr; @@ -522,14 +591,14 @@ __sframe_find_fre (sframe_decoder_ctx *ctx, int32_t pc, return _URC_END_OF_STACK; /* Find the FDE which contains the PC, then scan its fre entries. */ - fdep = sframe_get_funcdesc_with_addr_internal (ctx, pc, &err); + fdep = sframe_get_funcdesc_with_addr_internal (ctx, pc, &err, &func_idx); if (fdep == NULL || ctx->sfd_fres == NULL) return _URC_END_OF_STACK; fre_type = sframe_get_fre_type (fdep); fres = ctx->sfd_fres + fdep->sfde_func_start_fre_off; - func_start_addr = fdep->sfde_func_start_address; + func_start_addr = sframe_decoder_get_secrel_func_start_addr (ctx, func_idx); for (i = 0; i < fdep->sfde_func_num_fres; i++) { @@ -553,7 +622,8 @@ __sframe_find_fre (sframe_decoder_ctx *ctx, int32_t pc, if (start_ip_offset > (uint32_t) (pc - func_start_addr)) return _URC_END_OF_STACK; - if (sframe_fre_check_range_p (fdep, start_ip_offset, end_ip_offset, pc)) + if (sframe_fre_check_range_p (ctx, func_idx, start_ip_offset, + end_ip_offset, pc)) { /* Decode last FRE bits: offsets size. */ frep->fre_offsets = fres + addr_size + sizeof (frep->fre_info); diff --git a/sysdeps/generic/sframe-read.h b/sysdeps/generic/sframe-read.h index 1db1886bce..146142143c 100644 --- a/sysdeps/generic/sframe-read.h +++ b/sysdeps/generic/sframe-read.h @@ -99,6 +99,12 @@ __sframe_fre_get_ra_offset (sframe_decoder_ctx *dctx, sframe_frame_row_entry *fre, _Unwind_Reason_Code *errp); +/* Get the offset of the sfde_func_start_address field. */ + +extern uint32_t +__sframe_decoder_get_offsetof_fde_start_addr (sframe_decoder_ctx *dctx, + uint32_t func_idx, + _Unwind_Reason_Code *errp); #ifdef __cplusplus } #endif diff --git a/sysdeps/generic/sframe.h b/sysdeps/generic/sframe.h index 3f8ff1c80e..e38adcfe17 100644 --- a/sysdeps/generic/sframe.h +++ b/sysdeps/generic/sframe.h @@ -80,9 +80,20 @@ extern "C" /* Various flags for SFrame. */ /* Function Descriptor Entries are sorted on PC. */ -#define SFRAME_F_FDE_SORTED 0x1 +#define SFRAME_F_FDE_SORTED 0x1 /* Functions preserve frame pointer. */ -#define SFRAME_F_FRAME_POINTER 0x2 +#define SFRAME_F_FRAME_POINTER 0x2 +/* Function start address in SFrame FDE is encoded as the distance from the + location of the sfde_func_start_address to the start PC of the function. + If absent, the function start address in SFrame FDE is encoded as the + distance from the start of the SFrame FDE section to the start PC of the + function. */ +#define SFRAME_F_FDE_FUNC_START_PCREL 0x4 + +/* Set of all defined flags in SFrame V2. */ +#define SFRAME_V2_F_ALL_FLAGS \ + (SFRAME_F_FDE_SORTED | SFRAME_F_FRAME_POINTER \ + | SFRAME_F_FDE_FUNC_START_PCREL) #define SFRAME_CFA_FIXED_FP_INVALID 0 #define SFRAME_CFA_FIXED_RA_INVALID 0