]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/elf-sframe.c
sframe: bfd: gas: ld: format bump to SFrame version 2
[thirdparty/binutils-gdb.git] / bfd / elf-sframe.c
index 013a892e08a40b1c1face56aa15f6fdb2e342df6..1b38768ec719b7984f0452b3374d8c8961ce8838 100644 (file)
@@ -328,6 +328,8 @@ _bfd_elf_merge_section_sframe (bfd *abfd,
   uint8_t sfd_ctx_abi_arch;
   int8_t sfd_ctx_fixed_fp_offset;
   int8_t sfd_ctx_fixed_ra_offset;
+  uint8_t dctx_version;
+  uint8_t ectx_version;
   int encerr = 0;
 
   struct elf_link_hash_table *htab;
@@ -361,7 +363,7 @@ _bfd_elf_merge_section_sframe (bfd *abfd,
       if (!sfd_ctx_abi_arch)
        return false;
 
-      htab->sfe_info.sfe_ctx = sframe_encode (SFRAME_VERSION_1,
+      htab->sfe_info.sfe_ctx = sframe_encode (SFRAME_VERSION_2,
                                              0, /* SFrame flags.  */
                                              sfd_ctx_abi_arch,
                                              sfd_ctx_fixed_fp_offset,
@@ -400,6 +402,18 @@ _bfd_elf_merge_section_sframe (bfd *abfd,
       return false;
     }
 
+  /* Check that all .sframe sections being linked have the same version.  */
+  dctx_version = sframe_decoder_get_version (sfd_ctx);
+  ectx_version = sframe_encoder_get_version (sfe_ctx);
+  if (dctx_version != SFRAME_VERSION_2 || dctx_version != ectx_version)
+    {
+      _bfd_error_handler
+       (_("input SFrame sections with different format versions prevent"
+         " .sframe generation"));
+      return false;
+    }
+
+
   /* Iterate over the function descriptor entries and the FREs of the
      function from the decoder context.  Add each of them to the encoder
      context, if suitable.  */
@@ -411,16 +425,18 @@ _bfd_elf_merge_section_sframe (bfd *abfd,
   for (i = 0; i < num_fidx; i++)
     {
       unsigned int num_fres = 0;
-      int32_t func_start_address;
+      int32_t func_start_addr;
       bfd_vma address;
       uint32_t func_size = 0;
       unsigned char func_info = 0;
       unsigned int r_offset = 0;
       bool pltn_reloc_by_hand = false;
       unsigned int pltn_r_offset = 0;
+      uint8_t rep_block_size = 0;
 
-      if (!sframe_decoder_get_funcdesc (sfd_ctx, i, &num_fres, &func_size,
-                                       &func_start_address, &func_info))
+      if (!sframe_decoder_get_funcdesc_v2 (sfd_ctx, i, &num_fres, &func_size,
+                                          &func_start_addr, &func_info,
+                                          &rep_block_size))
        {
          /* If function belongs to a deleted section, skip editing the
             function descriptor entry.  */
@@ -471,13 +487,13 @@ _bfd_elf_merge_section_sframe (bfd *abfd,
              /* FIXME For testing only. Cleanup later.  */
              // address += (sec->output_section->vma);
 
-             func_start_address = address;
+             func_start_addr = address;
            }
 
          /* Update the encoder context with updated content.  */
-         int err = sframe_encoder_add_funcdesc (sfe_ctx, func_start_address,
-                                                func_size, func_info,
-                                                num_fres);
+         int err = sframe_encoder_add_funcdesc_v2 (sfe_ctx, func_start_addr,
+                                                   func_size, func_info,
+                                                   rep_block_size, num_fres);
          cur_fidx++;
          BFD_ASSERT (!err);
        }