]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: ld: sframe: add new internal header
authorIndu Bhagat <indu.bhagat@oracle.com>
Tue, 8 Jul 2025 19:10:04 +0000 (12:10 -0700)
committerIndu Bhagat <indu.bhagat@oracle.com>
Wed, 9 Jul 2025 08:40:41 +0000 (01:40 -0700)
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
gas/gen-sframe.c
include/sframe-api.h
include/sframe-internal.h [new file with mode: 0644]

index 24a3d35013ad932e278a673d95da6b89d1021d03..d74235b030a49d620964cd1ac93fd28ee07f22b2 100644 (file)
@@ -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"
index 7e29f840378796a0ddfa9c63ca6f358652c5cf63..3cba5085e1ce5b9d278cd1c5c27aaddaadb35d43 100644 (file)
@@ -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
index 753a91f5b3f414e9e45d8f2281873ce52b8ef388..3dc18b6ad394977f97f595c38390210ba2974941 100644 (file)
@@ -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 (file)
index 0000000..a246f26
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.  */
+
+#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 */