From 61be4420118b4039b80894ff57ad25f063218bfe Mon Sep 17 00:00:00 2001 From: Indu Bhagat Date: Tue, 8 Jul 2025 12:10:04 -0700 Subject: [PATCH] gas: ld: sframe: add new internal header for SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS. The intention of creating an abstraction like SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS is to address the concern that there should be a central place to enforce harmonious flags between GNU as and ld. At the moment, the only flag that needs to be enforced is SFRAME_F_FDE_FUNC_START_PCREL. sframe.h and sframe-api.h are installed headers by libsframe for the specification and implementation respectively. Adding a definition like SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS does not fit in either. Create a new internal header instead to keep the definition uncoupled from sframe.h and sframe-api.h. Rename the previously added SFRAME_F_LD_MUSTHAVE_FLAGS to define the new SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS. bfd/ * elf-sframe.c (_bfd_elf_merge_section_sframe): Use the new internal header and SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS. gas/ * gen-sframe.c (output_sframe_internal): Likewise. include/ * sframe-api.h (SFRAME_F_LD_MUSTHAVE_FLAGS): Move from.. * sframe-internal.h: ..to here. New file. --- bfd/elf-sframe.c | 9 +++++---- gas/gen-sframe.c | 6 +++--- include/sframe-api.h | 5 ----- include/sframe-internal.h | 30 ++++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 include/sframe-internal.h diff --git a/bfd/elf-sframe.c b/bfd/elf-sframe.c index 24a3d35013a..d74235b030a 100644 --- a/bfd/elf-sframe.c +++ b/bfd/elf-sframe.c @@ -23,6 +23,7 @@ #include "libbfd.h" #include "elf-bfd.h" #include "sframe-api.h" +#include "sframe-internal.h" /* Return TRUE if the function has been marked for deletion during the linking process. */ @@ -373,8 +374,8 @@ _bfd_elf_merge_section_sframe (bfd *abfd, uint8_t tflags = dctx_flags & ~SFRAME_F_FDE_SORTED; /* ld always generates an output section with SFRAME_F_FDE_FUNC_START_PCREL flag set. Later using - SFRAME_F_LD_MUSTHAVE_FLAGS, it is enforced that the provided input - sections also have this flag set. */ + SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS, it is enforced that the provided + input sections also have this flag set. */ tflags |= SFRAME_F_FDE_FUNC_START_PCREL; htab->sfe_info.sfe_ctx = sframe_encode (SFRAME_VERSION_2, tflags, /* SFrame flags. */ @@ -430,8 +431,8 @@ _bfd_elf_merge_section_sframe (bfd *abfd, related flags set. The implementation does not support updating these data encodings on the fly; confirm by checking the ectx_flags. */ ectx_flags = sframe_encoder_get_flags (sfe_ctx); - if ((dctx_flags & ectx_flags & SFRAME_F_LD_MUSTHAVE_FLAGS) - != SFRAME_F_LD_MUSTHAVE_FLAGS) + if ((dctx_flags & ectx_flags & SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS) + != SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS) { _bfd_error_handler (_("SFrame sections with unexpected data encoding prevent" diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index 7e29f840378..3cba5085e1c 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -21,7 +21,7 @@ #include "as.h" #include "subsegs.h" #include "sframe.h" -#include "sframe-api.h" +#include "sframe-internal.h" #include "gen-sframe.h" #include "dw2gencfi.h" @@ -685,8 +685,8 @@ output_sframe_internal (void) out_one (SFRAME_VERSION); /* gas must ensure emitted SFrame sections have at least the required flags set. */ - gas_assert ((sframe_flags & SFRAME_F_LD_MUSTHAVE_FLAGS) - == SFRAME_F_LD_MUSTHAVE_FLAGS); + gas_assert ((sframe_flags & SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS) + == SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS); out_one (sframe_flags); /* abi/arch. */ #ifdef sframe_get_abi_arch diff --git a/include/sframe-api.h b/include/sframe-api.h index 753a91f5b3f..3dc18b6ad39 100644 --- a/include/sframe-api.h +++ b/include/sframe-api.h @@ -36,11 +36,6 @@ typedef struct sframe_encoder_ctx sframe_encoder_ctx; #define MAX_OFFSET_BYTES \ ((SFRAME_FRE_OFFSET_4B * 2 * MAX_NUM_STACK_OFFSETS)) -/* Set of flags that are required to be harmonious between all decoder and - encoder objects participating in a link. */ -#define SFRAME_F_LD_MUSTHAVE_FLAGS \ - (SFRAME_F_FDE_FUNC_START_PCREL) - /* User interfacing SFrame Row Entry. An abstraction provided by libsframe so the consumer is decoupled from the binary format representation of the same. diff --git a/include/sframe-internal.h b/include/sframe-internal.h new file mode 100644 index 00000000000..a246f26f1bb --- /dev/null +++ b/include/sframe-internal.h @@ -0,0 +1,30 @@ +/* Internal header for SFrame. + + Used by GNU as and ld. + + Copyright (C) 2025 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _SFRAME_INTERNAL_H +#define _SFRAME_INTERNAL_H + +#include "sframe.h" + +/* Set of flags which are required to be harmonious between GNU as and ld. All + objects participating in the link for GNU ld must have these flags set. */ +#define SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS \ + (SFRAME_F_FDE_FUNC_START_PCREL) + +#endif /* _SFRAME_INTERNAL_H */ -- 2.47.2