[08/12] bfd: linker: generate SFrame sections with version SFRAME_VERSION_2
Checks
Commit Message
The linker will generate the output SFrame sections in the
SFRAME_VERSION_2 format. If the input sections offered to the linker
are not all in the SFRAME_VERSION_2 format, the linker issues an error
to the user.
bfd/
* elf-sframe.c (_bfd_elf_merge_section_sframe): Generate an
output SFrame section with version SFRAME_VERSION_2. Also,
error out if the SFrame sections do not all have
SFRAME_VERSION_2.
* elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Generate SFrame
section for plt entries with version SFRAME_VERSION_2.
ld/testsuite/
* ld-aarch64/sframe-simple-1.d: Adjust for SFRAME_VERSION_2.
* ld-x86-64/sframe-plt-1.d: Likewise.
* ld-x86-64/sframe-simple-1.d: Likewise.
---
bfd/elf-sframe.c | 16 +++++++++++++++-
bfd/elfxx-x86.c | 2 +-
ld/testsuite/ld-aarch64/sframe-simple-1.d | 4 ++--
ld/testsuite/ld-x86-64/sframe-plt-1.d | 2 +-
ld/testsuite/ld-x86-64/sframe-simple-1.d | 4 ++--
5 files changed, 21 insertions(+), 7 deletions(-)
@@ -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. */
@@ -1883,7 +1883,7 @@ _bfd_x86_elf_create_sframe_plt (bfd *output_bfd,
break;
}
- *ectx = sframe_encode (SFRAME_VERSION_1,
+ *ectx = sframe_encode (SFRAME_VERSION_2,
0,
SFRAME_ABI_AMD64_ENDIAN_LITTLE,
SFRAME_CFA_FIXED_FP_INVALID,
@@ -3,14 +3,14 @@
#source: sframe-bar.s
#objdump: --sframe=.sframe
#ld: -shared
-#name: SFrame Simple link
+#name: SFrame simple link
.*: file format .*
Contents of the SFrame section .sframe:
Header :
- Version: SFRAME_VERSION_1
+ Version: SFRAME_VERSION_2
Flags: SFRAME_F_FDE_SORTED
Num FDEs: 2
Num FREs: 2
@@ -10,7 +10,7 @@
Contents of the SFrame section .sframe:
Header :
- Version: SFRAME_VERSION_1
+ Version: SFRAME_VERSION_2
Flags: SFRAME_F_FDE_SORTED
#...
@@ -3,14 +3,14 @@
#source: sframe-bar.s
#objdump: --sframe=.sframe
#ld: -shared
-#name: SFrame Simple link
+#name: SFrame simple link
.*: +file format .*
Contents of the SFrame section .sframe:
Header :
- Version: SFRAME_VERSION_1
+ Version: SFRAME_VERSION_2
Flags: SFRAME_F_FDE_SORTED
#...