]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
include: gas: sframe: fix terminology from offset to data word
authorIndu Bhagat <indu.bhagat@oracle.com>
Fri, 23 Jan 2026 22:20:54 +0000 (14:20 -0800)
committerIndu Bhagat <indu.bhagat@oracle.com>
Fri, 23 Jan 2026 22:20:54 +0000 (14:20 -0800)
In SFrame V3, with the addition of flexible FDE type, the
variable-length array of bytes trailing the SFrame FRE header are no
longer exclusively interpreted as signed offsets. This data can now
include unsigned control data, unsigned padding word data or signed
offset data. Consequently, using the term "offsets" to describe this
trailing data is inaccurate and can be confusing.

This patch switches the terminology to 'Data Word' across the assembler
and the SFrame header file. Note that, the term 'Word' is used
colloquially here, the actual size (1, 2, or 4 bytes) remains determined
by the applicable bits in the FRE info byte.

gas/
* gen-sframe.c: Rename SFrame FRE 'offset' to 'data word'.
include/
* sframe.h (SFRAME_FRE_DATAWORD_1B, SFRAME_FRE_DATAWORD_2B,
SFRAME_FRE_DATAWORD_4B): New constants.
(struct sframe_fre_info): Update bitfield documentation.
(SFRAME_V3_FRE_DATAWORD_COUNT): New macro.
(SFRAME_V3_FRE_DATAWORD_SIZE): New macro.

gas/gen-sframe.c
include/sframe.h

index 61674021df94a135b5e1ae8c80a1c3ad5a92eff2..d62bb3dc64663a35ef37b09bc919e860016c630b 100644 (file)
@@ -159,8 +159,8 @@ sframe_fre_get_cfa_offset (const struct sframe_row_entry * fre)
 }
 
 /* All stack offsets in SFrame stack trace format must be representable as a
-   1-byte (SFRAME_FRE_OFFSET_1B), 2-byte (SFRAME_FRE_OFFSET_2B) or 4-byte
-   (SFRAME_FRE_OFFSET_4B) value.
+   1-byte (SFRAME_FRE_DATAWORD_1B), 2-byte (SFRAME_FRE_DATAWORD_2B) or 4-byte
+   (SFRAME_FRE_DATAWORD_4B) value.
 
    At the moment, sanity check on CFA offset (only) is performed to address PR
    gas/33277.  Arguably, such updates to ra_offset or fp_offset will only
@@ -240,37 +240,38 @@ get_udata_size_in_bytes (unsigned int value)
 
   return size;
 }
-#define SFRAME_FRE_OFFSET_FUNC_MAP_INDEX_1B  0 /* SFRAME_FRE_OFFSET_1B.  */
-#define SFRAME_FRE_OFFSET_FUNC_MAP_INDEX_2B  1 /* SFRAME_FRE_OFFSET_2B.  */
-#define SFRAME_FRE_OFFSET_FUNC_MAP_INDEX_4B  2 /* SFRAME_FRE_OFFSET_4B.  */
-#define SFRAME_FRE_OFFSET_FUNC_MAP_INDEX_8B  3 /* Not supported in SFrame.  */
-#define SFRAME_FRE_OFFSET_FUNC_MAP_INDEX_MAX SFRAME_FRE_OFFSET_FUNC_MAP_INDEX_8B
+#define SFRAME_FRE_DATAWORD_FUNC_MAP_INDEX_1B  0 /* SFRAME_FRE_DATAWORD_1B.  */
+#define SFRAME_FRE_DATAWORD_FUNC_MAP_INDEX_2B  1 /* SFRAME_FRE_DATAWORD_2B.  */
+#define SFRAME_FRE_DATAWORD_FUNC_MAP_INDEX_4B  2 /* SFRAME_FRE_DATAWORD_4B.  */
+#define SFRAME_FRE_DATAWORD_FUNC_MAP_INDEX_8B  3 /* Not supported in SFrame.  */
+#define SFRAME_FRE_DATAWORD_FUNC_MAP_INDEX_MAX \
+  SFRAME_FRE_DATAWORD_FUNC_MAP_INDEX_8B
 
-/* Helper struct for mapping offset size to output functions.  */
+/* Helper struct for mapping FRE data word size to output functions.  */
 
-struct sframe_fre_offset_func_map
+struct sframe_fre_dataword_func_map
 {
-  unsigned int offset_size;
+  unsigned int dataword_size;
   void (*out_func)(int);
 };
 
-/* Given an OFFSET_SIZE, return the size in bytes needed to represent it.  */
+/* Given an DATAWORD_SIZE, return the size in bytes needed to represent it.  */
 
 static unsigned int
-sframe_fre_offset_func_map_index (unsigned int offset_size)
+sframe_fre_dataword_func_map_index (unsigned int dataword_size)
 {
-  unsigned int idx = SFRAME_FRE_OFFSET_FUNC_MAP_INDEX_MAX;
+  unsigned int idx = SFRAME_FRE_DATAWORD_FUNC_MAP_INDEX_MAX;
 
-  switch (offset_size)
+  switch (dataword_size)
     {
-      case SFRAME_FRE_OFFSET_1B:
-       idx = SFRAME_FRE_OFFSET_FUNC_MAP_INDEX_1B;
+      case SFRAME_FRE_DATAWORD_1B:
+       idx = SFRAME_FRE_DATAWORD_FUNC_MAP_INDEX_1B;
        break;
-      case SFRAME_FRE_OFFSET_2B:
-       idx = SFRAME_FRE_OFFSET_FUNC_MAP_INDEX_2B;
+      case SFRAME_FRE_DATAWORD_2B:
+       idx = SFRAME_FRE_DATAWORD_FUNC_MAP_INDEX_2B;
        break;
-      case SFRAME_FRE_OFFSET_4B:
-       idx = SFRAME_FRE_OFFSET_FUNC_MAP_INDEX_4B;
+      case SFRAME_FRE_DATAWORD_4B:
+       idx = SFRAME_FRE_DATAWORD_FUNC_MAP_INDEX_4B;
        break;
       default:
        /* Not supported in SFrame.  */
@@ -280,15 +281,15 @@ sframe_fre_offset_func_map_index (unsigned int offset_size)
   return idx;
 }
 
-/* Mapping from offset size to the output function to emit the value.  */
+/* Mapping from data word size to the output function to emit the value.  */
 
 static const
-struct sframe_fre_offset_func_map
-fre_offset_func_map[SFRAME_FRE_OFFSET_FUNC_MAP_INDEX_MAX+1] =
+struct sframe_fre_dataword_func_map
+dataword_func_map[SFRAME_FRE_DATAWORD_FUNC_MAP_INDEX_MAX+1] =
 {
-  { SFRAME_FRE_OFFSET_1B, out_one },
-  { SFRAME_FRE_OFFSET_2B, out_two },
-  { SFRAME_FRE_OFFSET_4B, out_four },
+  { SFRAME_FRE_DATAWORD_1B, out_one },
+  { SFRAME_FRE_DATAWORD_2B, out_two },
+  { SFRAME_FRE_DATAWORD_4B, out_four },
   { -1, NULL } /* Not Supported in SFrame.  */
 };
 
@@ -299,11 +300,11 @@ static struct sframe_version_ops sframe_ver_ops;
 /* SFrame (SFRAME_VERSION_1) set FRE info.  */
 
 static unsigned char
-sframe_v1_set_fre_info (unsigned int cfa_base_reg, unsigned int num_offsets,
-                       unsigned int offset_size, bool mangled_ra_p)
+sframe_v1_set_fre_info (unsigned int cfa_base_reg, unsigned int dataword_count,
+                       unsigned int dataword_size, bool mangled_ra_p)
 {
   unsigned char fre_info;
-  fre_info = SFRAME_V1_FRE_INFO (cfa_base_reg, num_offsets, offset_size);
+  fre_info = SFRAME_V1_FRE_INFO (cfa_base_reg, dataword_count, dataword_size);
   fre_info = SFRAME_V1_FRE_INFO_UPDATE_MANGLED_RA_P (mangled_ra_p, fre_info);
   return fre_info;
 }
@@ -340,11 +341,11 @@ sframe_set_version (enum gen_sframe_version flag_ver)
 /* SFrame set FRE info.  */
 
 static unsigned char
-sframe_set_fre_info (unsigned int cfa_base_reg, unsigned int num_offsets,
-                    unsigned int offset_size, bool mangled_ra_p)
+sframe_set_fre_info (unsigned int cfa_base_reg, unsigned int dataword_count,
+                    unsigned int dataword_size, bool mangled_ra_p)
 {
-  return sframe_ver_ops.set_fre_info (cfa_base_reg, num_offsets,
-                                     offset_size, mangled_ra_p);
+  return sframe_ver_ops.set_fre_info (cfa_base_reg, dataword_count,
+                                     dataword_size, mangled_ra_p);
 }
 
 /* SFrame set func info. */
@@ -385,57 +386,56 @@ get_fre_base_reg_id (const struct sframe_row_entry *sframe_fre)
   return fre_base_reg;
 }
 
-/* Get number of offsets necessary for the SFrame Frame Row Entry.  */
+/* Get number of data words necessary for the SFrame Frame Row Entry.  */
 
 static unsigned int
-get_fre_num_offsets (const struct sframe_row_entry *sframe_fre,
-                    bool flex_p)
+get_fre_dataword_count (const struct sframe_row_entry *sframe_fre, bool flex_p)
 {
   /* For SFRAME_FDE_TYPE_FLEX FDE type, each entity (CFA, FP, RA) may carry up
-     to two offsets.  */
+     to two data words.  */
   unsigned int count = flex_p ? 2 : 1;
 
-  /* CFA offset (or offsets when flex_p) must always be present.  */
-  unsigned int fre_num_offsets = count;
+  /* CFA data word (or data words when flex_p) must always be present.  */
+  unsigned int fre_dataword_count = count;
 
-  /* For flexible frames encoding, there will be two offsets for RA (if RA is
-     being tracked).  1 padding offset otherwise.  */
+  /* For flexible FDE type, there will be two data words for RA (if RA
+     has a recovery rule applicable).  1 padding data word otherwise.  */
   if (flex_p)
     {
      if (sframe_fre->ra_loc != SFRAME_FRE_ELEM_LOC_NONE)
-       fre_num_offsets += count;
+       fre_dataword_count += count;
      else if (sframe_fre->fp_loc != SFRAME_FRE_ELEM_LOC_NONE)
-       fre_num_offsets += 1;
+       fre_dataword_count += 1;
     }
   else if (sframe_ra_tracking_p ()
           && (sframe_fre->ra_loc != SFRAME_FRE_ELEM_LOC_NONE
-              /* For s390x account padding RA offset, if FP without RA
+              /* For s390x account padding RA data word, if FP without RA
                  saved.  */
               || (sframe_get_abi_arch () == SFRAME_ABI_S390X_ENDIAN_BIG
                   && sframe_fre->fp_loc != SFRAME_FRE_ELEM_LOC_NONE)))
-    fre_num_offsets++;
+    fre_dataword_count++;
 
   if (sframe_fre->fp_loc != SFRAME_FRE_ELEM_LOC_NONE)
-    fre_num_offsets += count;
+    fre_dataword_count += count;
 
-  return fre_num_offsets;
+  return fre_dataword_count;
 }
 
-/* Get the minimum necessary offset size (in bytes) for this
+/* Get the minimum necessary data word size (in bytes) for this
    SFrame frame row entry.  */
 
 static unsigned int
-sframe_get_fre_offset_size (const struct sframe_row_entry *sframe_fre,
+sframe_get_fre_dataword_size (const struct sframe_row_entry *sframe_fre,
                            bool flex_p)
 {
-  unsigned int max_offset_size = 0;
+  unsigned int max_dataword_size = 0;
   unsigned int cfa_offset_size = 0;
   unsigned int fp_offset_size = 0;
   unsigned int ra_offset_size = 0;
 
-  unsigned int fre_offset_size = 0;
+  unsigned int fre_dataword_size = 0;
 
-  /* What size of offsets appear in this frame row entry.  */
+  /* What size of data words appear in this frame row entry.  */
   cfa_offset_size = get_offset_size_in_bytes (sframe_fre->cfa_offset);
   if (sframe_fre->fp_loc == SFRAME_FRE_ELEM_LOC_STACK)
     fp_offset_size = get_offset_size_in_bytes (sframe_fre->fp_offset);
@@ -450,11 +450,11 @@ sframe_get_fre_offset_size (const struct sframe_row_entry *sframe_fre,
     }
 
   /* Get the maximum size needed to represent the offsets.  */
-  max_offset_size = cfa_offset_size;
-  if (fp_offset_size > max_offset_size)
-    max_offset_size = fp_offset_size;
-  if (ra_offset_size > max_offset_size)
-    max_offset_size = ra_offset_size;
+  max_dataword_size = cfa_offset_size;
+  if (fp_offset_size > max_dataword_size)
+    max_dataword_size = fp_offset_size;
+  if (ra_offset_size > max_dataword_size)
+    max_dataword_size = ra_offset_size;
 
   /* If flex FDE, account for reg data too.  */
   if (flex_p)
@@ -463,18 +463,18 @@ sframe_get_fre_offset_size (const struct sframe_row_entry *sframe_fre,
       unsigned int data
        = SFRAME_V3_FLEX_FDE_REG_ENCODE (sframe_fre->cfa_base_reg,
                                         sframe_fre->cfa_deref_p, reg_p);
-      unsigned int data_size = get_udata_size_in_bytes (data);
-      if (data_size > max_offset_size)
-       max_offset_size = data_size;
+      unsigned int cfa_control_word_size = get_udata_size_in_bytes (data);
+      if (cfa_control_word_size > max_dataword_size)
+       max_dataword_size = cfa_control_word_size;
 
       if (sframe_fre->ra_loc == SFRAME_FRE_ELEM_LOC_REG)
        {
          data = SFRAME_V3_FLEX_FDE_REG_ENCODE (sframe_fre->ra_reg,
                                                sframe_fre->ra_deref_p,
                                                1 /* reg_p.  */);
-         data_size = get_udata_size_in_bytes (data);
-         if (data_size > max_offset_size)
-           max_offset_size = data_size;
+         unsigned ra_control_word_size = get_udata_size_in_bytes (data);
+         if (ra_control_word_size > max_dataword_size)
+           max_dataword_size = ra_control_word_size;
        }
 
       if (sframe_fre->fp_loc == SFRAME_FRE_ELEM_LOC_REG)
@@ -482,33 +482,32 @@ sframe_get_fre_offset_size (const struct sframe_row_entry *sframe_fre,
          data = SFRAME_V3_FLEX_FDE_REG_ENCODE (sframe_fre->fp_reg,
                                                sframe_fre->fp_deref_p,
                                                1 /* reg_p.  */);
-         data_size = get_udata_size_in_bytes (data);
-         if (data_size > max_offset_size)
-           max_offset_size = data_size;
+         unsigned fp_control_word_size = get_udata_size_in_bytes (data);
+         if (fp_control_word_size > max_dataword_size)
+           max_dataword_size = fp_control_word_size;
        }
     }
 
-  gas_assert (max_offset_size);
+  gas_assert (max_dataword_size);
 
-  switch (max_offset_size)
+  switch (max_dataword_size)
     {
     case 1:
-      fre_offset_size = SFRAME_FRE_OFFSET_1B;
+      fre_dataword_size = SFRAME_FRE_DATAWORD_1B;
       break;
     case 2:
-      fre_offset_size = SFRAME_FRE_OFFSET_2B;
+      fre_dataword_size = SFRAME_FRE_DATAWORD_2B;
       break;
     case 4:
-      fre_offset_size = SFRAME_FRE_OFFSET_4B;
+      fre_dataword_size = SFRAME_FRE_DATAWORD_4B;
       break;
     default:
-      /* Offset of size 8 bytes is not supported in SFrame format
-        version 1.  */
-      as_fatal (_("SFrame unsupported offset value\n"));
+      /* FRE data words of size 8 bytes is not supported in SFrame.  */
+      as_fatal (_("SFrame unsupported FRE data word size\n"));
       break;
     }
 
-  return fre_offset_size;
+  return fre_dataword_size;
 }
 
 /* Create a composite expression CEXP (for SFrame FRE start address) such that:
@@ -642,101 +641,101 @@ sframe_fde_free (struct sframe_func_entry *sframe_fde)
   XDELETE (sframe_fde);
 }
 
-/* Output the varlen data (SFrame FRE stack offsets) for SFrame FRE object
+/* Output the varlen data (SFrame FRE data words) for SFrame FRE object
    SFRAME_FRE of the SFrame FDE object SFRAME_FDE.  Each emitted entry is of
-   size FRE_OFFSET_SIZE.  Write out the offsets in order - CFA, RA, FP.  */
+   size FRE_DATAWORD_SIZE.  Write out the data words in order - CFA, RA, FP.  */
 
 static unsigned int
-output_sframe_row_entry_offsets (const struct sframe_func_entry *sframe_fde,
-                                const struct sframe_row_entry *sframe_fre,
-                                unsigned int fre_offset_size)
+output_sframe_row_entry_datawords (const struct sframe_func_entry *sframe_fde,
+                                  const struct sframe_row_entry *sframe_fre,
+                                  unsigned int fre_dataword_size)
 {
-  unsigned int fre_write_offsets = 0;
+  unsigned int fre_write_datawords = 0;
 
-  unsigned int idx = sframe_fre_offset_func_map_index (fre_offset_size);
-  gas_assert (idx < SFRAME_FRE_OFFSET_FUNC_MAP_INDEX_MAX);
+  unsigned int idx = sframe_fre_dataword_func_map_index (fre_dataword_size);
+  gas_assert (idx < SFRAME_FRE_DATAWORD_FUNC_MAP_INDEX_MAX);
 
   if (sframe_fde->fde_flex_p)
     {
       /* SFrame FDE of type SFRAME_FDE_TYPE_FLEX.  */
-      /* Output CFA related FRE offsets.  */
+      /* Output CFA related FRE data words.  */
       uint32_t reg = sframe_fre->cfa_base_reg;
       uint32_t reg_data
        = SFRAME_V3_FLEX_FDE_REG_ENCODE (reg, sframe_fre->cfa_deref_p,
                                         1 /* reg_p.  */);
       offsetT offset_data = sframe_fre->cfa_offset;
-      fre_offset_func_map[idx].out_func (reg_data);
-      fre_offset_func_map[idx].out_func (offset_data);
-      fre_write_offsets += 2;
+      dataword_func_map[idx].out_func (reg_data);
+      dataword_func_map[idx].out_func (offset_data);
+      fre_write_datawords += 2;
 
       bool reg_p = false;
       if (sframe_fre->ra_loc != SFRAME_FRE_ELEM_LOC_NONE)
        {
-         /* Output RA related FRE offsets.  */
+         /* Output RA related FRE data words.  */
          reg_p = sframe_fre->ra_loc == SFRAME_FRE_ELEM_LOC_REG;
          reg = reg_p ? sframe_fre->ra_reg : 0;
          reg_data = SFRAME_V3_FLEX_FDE_REG_ENCODE (reg,
                                                    sframe_fre->ra_deref_p,
                                                    reg_p);
          offset_data = sframe_fre->ra_offset;
-         fre_offset_func_map[idx].out_func (reg_data);
-         fre_offset_func_map[idx].out_func (offset_data);
-         fre_write_offsets += 2;
+         dataword_func_map[idx].out_func (reg_data);
+         dataword_func_map[idx].out_func (offset_data);
+         fre_write_datawords += 2;
        }
       else if (sframe_fre->fp_loc != SFRAME_FRE_ELEM_LOC_NONE)
        {
          /* If RA is not in REG/STACK, emit RA padding if there are more
-            offsets to follow.  Note that, emitting
+            data words to follow.  Note that, emitting
             SFRAME_FRE_RA_OFFSET_INVALID is equivalent to emitting
             SFRAME_V3_FLEX_FDE_REG_ENCODE (0, 0, 0).  */
-         fre_offset_func_map[idx].out_func (SFRAME_FRE_RA_OFFSET_INVALID);
-         fre_write_offsets += 1;
+         dataword_func_map[idx].out_func (SFRAME_FRE_RA_OFFSET_INVALID);
+         fre_write_datawords += 1;
        }
 
       if (sframe_fre->fp_loc != SFRAME_FRE_ELEM_LOC_NONE)
        {
-         /* Output FP related FRE offsets.  */
+         /* Output FP related FRE data words.  */
          reg_p = sframe_fre->fp_loc == SFRAME_FRE_ELEM_LOC_REG;
          reg = reg_p ? sframe_fre->fp_reg : 0;
          reg_data = SFRAME_V3_FLEX_FDE_REG_ENCODE (reg,
                                                    sframe_fre->fp_deref_p,
                                                    reg_p);
          offset_data = sframe_fre->fp_offset;
-         fre_offset_func_map[idx].out_func (reg_data);
-         fre_offset_func_map[idx].out_func (offset_data);
-         fre_write_offsets += 2;
+         dataword_func_map[idx].out_func (reg_data);
+         dataword_func_map[idx].out_func (offset_data);
+         fre_write_datawords += 2;
        }
     }
   else
     {
       /* SFrame FDE of type SFRAME_FDE_TYPE_DEFAULT.  */
-      /* Output CFA related FRE offsets.  */
-      fre_offset_func_map[idx].out_func (sframe_fre->cfa_offset);
-      fre_write_offsets++;
+      /* Output CFA related FRE data words.  */
+      dataword_func_map[idx].out_func (sframe_fre->cfa_offset);
+      fre_write_datawords++;
 
       if (sframe_ra_tracking_p ())
        {
          if (sframe_fre->ra_loc == SFRAME_FRE_ELEM_LOC_STACK)
            {
-             fre_offset_func_map[idx].out_func (sframe_fre->ra_offset);
-             fre_write_offsets++;
+             dataword_func_map[idx].out_func (sframe_fre->ra_offset);
+             fre_write_datawords++;
            }
          /* For s390x write padding RA offset, if FP without RA saved.  */
          else if (sframe_get_abi_arch () == SFRAME_ABI_S390X_ENDIAN_BIG
                   && sframe_fre->fp_loc == SFRAME_FRE_ELEM_LOC_STACK)
            {
-             fre_offset_func_map[idx].out_func (SFRAME_FRE_RA_OFFSET_INVALID);
-             fre_write_offsets++;
+             dataword_func_map[idx].out_func (SFRAME_FRE_RA_OFFSET_INVALID);
+             fre_write_datawords++;
            }
        }
       if (sframe_fre->fp_loc == SFRAME_FRE_ELEM_LOC_STACK)
        {
-         fre_offset_func_map[idx].out_func (sframe_fre->fp_offset);
-         fre_write_offsets++;
+         dataword_func_map[idx].out_func (sframe_fre->fp_offset);
+         fre_write_datawords++;
        }
     }
 
-  return fre_write_offsets;
+  return fre_write_datawords;
 }
 
 static void
@@ -744,16 +743,17 @@ output_sframe_row_entry (const struct sframe_func_entry *sframe_fde,
                         const struct sframe_row_entry *sframe_fre)
 {
   unsigned char fre_info;
-  unsigned int fre_num_offsets;
-  unsigned int fre_offset_size;
+  unsigned int fre_dataword_count;
+  unsigned int fre_dataword_size;
   unsigned int fre_base_reg;
   bool fre_mangled_ra_p;
   expressionS exp;
   unsigned int fre_addr_size;
 
-  unsigned int fre_write_offsets = 0;
+  unsigned int fre_write_datawords = 0;
   symbolS *fde_start_addr = get_dw_fde_start_addrS (sframe_fde->dw_fde);
   symbolS *fde_end_addr = get_dw_fde_end_addrS (sframe_fde->dw_fde);
+  bool flex_p = sframe_fde->fde_flex_p;
 
   fre_addr_size = 4; /* 4 bytes by default.   FIXME tie it to fre_type? */
 
@@ -777,44 +777,43 @@ output_sframe_row_entry (const struct sframe_func_entry *sframe_fde,
       emit_expr (&exp, fre_addr_size);
     }
 
-  /* Create the fre_info using the CFA base register, number of offsets and max
-     size of offset in this frame row entry.  Represent RA undefined as FRE
-     without any offsets and all FRE info word fields zeroed.  */
+  /* Create the fre_info using the CFA base register, number of data words and
+     max size of a data word in this FRE.  Represent RA undefined as FRE
+     without any data words and all FRE info word fields zeroed.  */
   if (sframe_fre->ra_undefined_p)
     {
       fre_base_reg = 0;
-      fre_num_offsets = 0;
-      fre_offset_size = 0;
+      fre_dataword_count = 0;
+      fre_dataword_size = 0;
       fre_mangled_ra_p = 0;
     }
   else
     {
       fre_base_reg = get_fre_base_reg_id (sframe_fre);
-      fre_num_offsets = get_fre_num_offsets (sframe_fre,
-                                            sframe_fde->fde_flex_p);
-      fre_offset_size = sframe_get_fre_offset_size (sframe_fre,
-                                                   sframe_fde->fde_flex_p);
+      fre_dataword_count = get_fre_dataword_count (sframe_fre, flex_p);
+      fre_dataword_size = sframe_get_fre_dataword_size (sframe_fre, flex_p);
       fre_mangled_ra_p = sframe_fre->mangled_ra_p;
     }
 
   /* Unused for flex FDE.  Set to zero.  */
-  if (sframe_fde->fde_flex_p)
+  if (flex_p)
     fre_base_reg = 0;
 
-  fre_info = sframe_set_fre_info (fre_base_reg, fre_num_offsets,
-                                 fre_offset_size, fre_mangled_ra_p);
+  fre_info = sframe_set_fre_info (fre_base_reg, fre_dataword_count,
+                                 fre_dataword_size, fre_mangled_ra_p);
   out_one (fre_info);
 
-  /* Represent RA undefined as FRE without any offsets.  */
+  /* Represent RA undefined as FRE without any data words.  */
   if (sframe_fre->ra_undefined_p)
     return;
 
-  fre_write_offsets = output_sframe_row_entry_offsets (sframe_fde, sframe_fre,
-                                                      fre_offset_size);
+  fre_write_datawords = output_sframe_row_entry_datawords (sframe_fde,
+                                                          sframe_fre,
+                                                          fre_dataword_size);
 
-  /* Check if the expected number offsets have been written out
+  /* Check if the expected number data words have been written out
      in this FRE.  */
-  gas_assert (fre_write_offsets == fre_num_offsets);
+  gas_assert (fre_write_datawords == fre_dataword_count);
 }
 
 static void
@@ -2164,10 +2163,10 @@ sframe_xlate_do_cfi_escape (struct sframe_xlate_ctx *xlate_ctx,
    and the unwind is complete.
 
    In SFrame, represent the use of the RA register with DW_CFA_undefined as
-   SFrame FRE without any offsets.  Stack tracers can use this as indication
-   that an outermost frame has been reached and the stack trace is complete.
-   The use of other registers of interest with  DW_CFA_undefined cannot be
-   represented in SFrame.  Therefore skip generating an SFrame FDE.
+   SFrame FRE without any trailing FRE data words.  Stack tracers can use this
+   as indication that an outermost frame has been reached and the stack trace
+   is complete.  The use of other registers of interest with  DW_CFA_undefined
+   cannot be represented in SFrame.  Therefore skip generating an SFrame FDE.
 
    Return SFRAME_XLATE_OK if success.  */
 
@@ -2185,7 +2184,7 @@ sframe_xlate_do_cfi_undefined (const struct sframe_xlate_ctx *xlate_ctx ATTRIBUT
   else if (cfi_insn->u.r == SFRAME_CFA_RA_REG)
     {
       /* Represent RA undefined (i.e. outermost frame) as FRE without any
-        offsets.  */
+        data words.  */
       struct sframe_row_entry *cur_fre = xlate_ctx->cur_fre;
 
       gas_assert (cur_fre);
index 2d47cc73ae886a8e424178603b00631400582eb3..8a824852bcd51266a8d8f1e24f791513d3bc1b8d 100644 (file)
@@ -356,6 +356,14 @@ typedef struct sframe_func_desc_attr_v3
 #define SFRAME_FRE_OFFSET_2B     1
 #define SFRAME_FRE_OFFSET_4B     2
 
+/* In SFrame V3, with the addition of flexible FDE, usage of term "offsets"
+   (for the varlen data trailing the SFrame FRE) is inappropriate.  Use the
+   terminology of "data word" instead.  A single SFrame FRE has all data words
+   of the same size.  Size of data words may vary across frame row entries.  */
+#define SFRAME_FRE_DATAWORD_1B     SFRAME_FRE_OFFSET_1B
+#define SFRAME_FRE_DATAWORD_2B     SFRAME_FRE_OFFSET_2B
+#define SFRAME_FRE_DATAWORD_4B     SFRAME_FRE_OFFSET_4B
+
 /* An SFrame Frame Row Entry can be SP or FP based.  */
 #define SFRAME_BASE_REG_FP     0
 #define SFRAME_BASE_REG_SP     1
@@ -378,14 +386,15 @@ typedef struct sframe_fre_info
 {
   /* Information about
      - 1 bit: base reg for CFA
-     - 4 bits: Number of offsets (N).  A value of upto 3 is allowed to track
-     all three of CFA, FP and RA (fixed implicit order).
-     - 2 bits: information about size of the offsets (S) in bytes.
-     Valid values are SFRAME_FRE_OFFSET_1B, SFRAME_FRE_OFFSET_2B,
-     SFRAME_FRE_OFFSET_4B
+     - 4 bits: Number of data words (N).  Typically for default FDE type, a
+     value of upto 3 suffices to track all three of CFA, FP and RA (fixed
+     implicit order).
+     - 2 bits: information about size of the data words (S) in bytes.
+     Valid values are SFRAME_FRE_DATAWORD_1B, SFRAME_FRE_DATAWORD_2B,
+     SFRAME_FRE_DATAWORD_4B.
      - 1 bit: Mangled RA state bit (aarch64 only).
      ----------------------------------------------------------------------------------
-     | Mangled-RA (aarch64) |  Size of offsets   |   Number of offsets    |   base_reg |
+     | Mangled-RA (aarch64) | Size of Data Words |  Number of Data Words  |   base_reg |
      | Unused (amd64, s390x)|                    |                        |            |
      ----------------------------------------------------------------------------------
      8                     7                    5                        1            0
@@ -411,6 +420,17 @@ typedef struct sframe_fre_info
 #define SFRAME_V1_FRE_MANGLED_RA_P(data)         (((data) >> 7) & 0x1)
 #define SFRAME_V2_FRE_RA_UNDEFINED_P(data)       (SFRAME_V1_FRE_OFFSET_COUNT (data) == 0)
 
+/* In SFrame V3, with the introduction of flexible FDE type
+   SFRAME_FDE_TYPE_FLEX, the variable-length data following SFrame FRE header
+   may contain unsigned Control Data Words or signed Offset Data Words.  These
+   are referred to as 'Data Words'.  Note that the usage of the term 'Word'
+   here is colloquial, the size of a data word is determined by applicable
+   bits.  */
+#define SFRAME_V3_FRE_DATAWORD_COUNT(data)     \
+  SFRAME_V1_FRE_OFFSET_COUNT (data)
+#define SFRAME_V3_FRE_DATAWORD_SIZE(data) \
+  SFRAME_V1_FRE_OFFSET_SIZE (data)
+
 /* SFrame Frame Row Entry definitions.
 
    Used for Default FDEs in AMD64, AARCH64, and s390x.