[PATCH 4/5] libsframe: make flip_header version aware
Jens Remus
jremus@linux.ibm.com
Fri Oct 17 11:00:14 GMT 2025
Hello Indu!
On 10/17/2025 9:05 AM, Indu Bhagat via Binutils wrote:
> Future versions of the format may have alternative representation of an
> FDE. As the format evolves, endian flipping will need to be version
> aware.
>
> flip_header now takes the SFrame version as argument. Currently unused,
> this argument will be used later when we introduce SFrame V3.
>
> SFrame encoder, at the momemnt, writes the SFrame data in the most recent
> format version by default.
>
> libsframe/
> * sframe.c (flip_header): Make version aware.
> (sframe_decode): Adjust usage of flup_header.
> (sframe_encoder_write): Likewise.
> diff --git a/libsframe/sframe.c b/libsframe/sframe.c
> +static int
> +flip_header (char *buf, uint8_t ver ATTRIBUTE_UNUSED)
flip_header (char *buf, size_t size, uint8_t ver ATTRIBUTE_UNUSED)
Btw. how is passing VER into the helper expected to work? Wouldn't it
only be known in advance when encoding. How would it work for decoding?
> +{
> + /* SFrame header binary format has remained the same in SFRAME_VERSION_1,
> + SFRAME_VERSION_2. */
> + sframe_header *sfh = (sframe_header *) buf;
if (size < sizeof (sframe_header))
return SFRAME_ERR;
Or SFRAME_ERR_BUF_INVAL or the like.
> + swap_thing (sfh->sfh_preamble.sfp_magic);
> + swap_thing (sfh->sfh_preamble.sfp_version);
> + swap_thing (sfh->sfh_preamble.sfp_flags);
> + swap_thing (sfh->sfh_abi_arch);
> + swap_thing (sfh->sfh_cfa_fixed_fp_offset);
> + swap_thing (sfh->sfh_cfa_fixed_ra_offset);
> + swap_thing (sfh->sfh_auxhdr_len);
> + swap_thing (sfh->sfh_num_fdes);
> + swap_thing (sfh->sfh_num_fres);
> + swap_thing (sfh->sfh_fre_len);
> + swap_thing (sfh->sfh_fdeoff);
> + swap_thing (sfh->sfh_freoff);
> +
> + /* Alert for missing functionatlity. Auxiliary header, if present, needs to
> + flipped based on per abi/arch semantics. */
> + if (sfh->sfh_auxhdr_len)
> + return SFRAME_ERR;
> +
> + return 0;
> }
Thanks and 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