[RFC 10/28] [SFrame-V3] include: libsframe: bfd: gas: testsuite: support for signed 64-bit offset in SFrame FDE

Jens Remus jremus@linux.ibm.com
Fri Dec 19 16:14:18 GMT 2025


On 12/9/2025 10:07 AM, Indu Bhagat wrote:
> This change enables support text > 2 GiB in SFrame format.
> 
> Each SFrame FDE needs to hold information about the start PC of the
> function it pertains to.  Currently, the field 'sfde_func_start_address'
> in SFrame FDE is encoded as a 32-bit offset to the start PC of the
> function from the field itself.
> 
> In SFrame V2, this offset was a signed 32-bit offset.  The signedness
> gives the flexibility of having .sframe ELF section before or after the
> .text* sections.  But the size of 32-bit puts the limitation that
> .sframe togther with the .text* sections must fit the 2 GiB range.
> 
> Currently, if the linker sees the offset not representable as 32-bit
> signed offset, it issues an error (not seen in the wild, simulated by
> forcing a function to align via an '.align  2147483648' directive):
> 
>   test.o:(.sframe+0x1c): relocation truncated to fit: R_X86_64_PC32 against `.text'
>   make: *** [Makefile:7: all] Error 1
> 
> ATM, EH Frame also suffers with the same issue.
> 
> Moving forward, some cloud applications have been shown to be nearing
> 1.5 GiB threshold.  Extending the offset to int64_t now seems to be good
> choice to make now for future-proof'ing the sections.
> 
> The use of int64_t offset is done for all SFrame V3 sections.  This
> bump from int32_t to int64_t should not lead to an increase in the size
> of SFrame sections, because of the following additional changes to the
> SFrame FDE specification:
>   - Reduce the type of sfde_func_num_fres (from uint32_t to uint16_t)
>   - Remove the 2 bytes of padding (sfde_func_padding2). These served the
>     two-fold purpose of keeping FDE data aligned _and_ unused space for
>     future needs.
> 
> Now that the offset is int64_t, start using the
> sframe_decoder_get_funcdesc_v3 () instead of
> sframe_decoder_get_funcdesc_v2 () in GNU ld.
> 
> This patch changes the offset type in the SFrame FDE definition to an
> int64_t.  No further changes in gas are necessary because the code
> already accounts for writing out as per the size of the member of the
> struct:
> 
>   emit_expr (&exp, sizeof_member (sframe_func_desc_entry,
>                                   sfde_func_start_address));
> 
> bfd/
> 	* elf-sframe.c (sframe_read_value): Signed offset for start PC
> 	is 8-bytes now.
> 	(_bfd_elf_merge_section_sframe): Likewise.
> 	* elf64-s390.c (_bfd_s390_elf_create_sframe_plt): Use V3 API.
> 	(elf_s390_finish_dynamic_sections): Signed offset for start PC
> 	is 8-bytes now.
> 	* elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Use V3 API.
> 	(_bfd_x86_elf_finish_dynamic_sections): Signed offset for start
> 	PC is 8-bytes now.
> libsframe/
> 	* sframe-dump.c (dump_sframe_func_with_fres): Use int64_t.
> 	* sframe.c (sframe_decoder_get_secrel_func_start_addr): Likewise.
> 	(sframe_fre_check_range_p): Likewise.
> 	(sframe_find_fre): Likewise.
> 	(sframe_encoder_add_funcdesc): Likewise.
> 	(sframe_encoder_write_fde): Write out int64_t now.
> libsframe/testsuite/
> 	* libsframe.decode/DATA2: Regenerate the data file.
> 	* libsframe.encode/encode-1.c: Use int64_t for start pc offset.
> 	* libsframe.find/findfre-1.c: Likewise.
> 	* libsframe.find/findfunc-1.c: Likewise.
> 	* libsframe.find/plt-findfre-1.c: Likewise.
> 	* libsframe.find/plt-findfre-2.c: Likewise.
> include/
> 	* sframe-api.h (sframe_find_fre): Update arg type to int64_t.
> 	(sframe_encoder_add_funcdesc): Likewise.
> 	* sframe.h: Change data type to int64_t.
> ---
>  bfd/elf-sframe.c                              |  22 +++++----
>  bfd/elf64-s390.c                              |   6 +--
>  bfd/elfxx-x86.c                               |  10 ++--
>  include/sframe-api.h                          |   4 +-
>  include/sframe.h                              |   2 +-
>  libsframe/sframe-dump.c                       |  32 +++++++++----
>  libsframe/sframe.c                            |  20 ++++----
>  libsframe/testsuite/libsframe.decode/DATA2    | Bin 90 -> 98 bytes
>  .../testsuite/libsframe.encode/encode-1.c     |  22 ++++-----
>  .../testsuite/libsframe.find/findfre-1.c      |  34 +++++++-------
>  .../testsuite/libsframe.find/findfunc-1.c     |  44 +++++++++---------
>  .../testsuite/libsframe.find/plt-findfre-1.c  |  20 ++++----
>  .../testsuite/libsframe.find/plt-findfre-2.c  |  28 +++++------
>  13 files changed, 130 insertions(+), 114 deletions(-)

Reviewed-by: Jens Remus <jremus@linux.ibm.com>

Regards,
Jens
-- 
Jens Remus
Linux on Z Development (D3303)
+49-7031-16-1128 Office
jremus@de.ibm.com

IBM

IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Böblingen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/



More information about the Binutils mailing list