[PATCH v2 01/11] sframe: Ignore section padding when converting endianness
Indu Bhagat
indu.bhagat@oracle.com
Mon Jun 2 17:33:37 GMT 2025
On 5/27/25 4:07 AM, Jens Remus wrote:
> The .sframe section may have a trailing padding due to the architecture-
> specific default section alignment. Do not treat this padding as error
> when converting between target and host endianness.
>
> While at it reuse the determined SFrame section header size.
>
> libsframe/
> * sframe.c (flip_sframe): Ignore .sframe section padding. Reuse
> SFrame header size.
>
> Reported-by: Indu Bhagat <indu.bhagat@oracle.com>
> Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Indu Bhagat <indu.bhagat@oracle.com>
> ---
>
> Notes (jremus):
> This can be observed when building Binutils with SFrame s390 support on
> x86-64 for s390x using configure option "--target=s390x-ibm-linux-gnu"
> and running the GAS test suite.
>
I would move this comment to the commit log itself, as it sheds light on
how to reproduce the issue and that the testcase is already present.
Thanks
> libsframe/sframe.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/libsframe/sframe.c b/libsframe/sframe.c
> index 950a6846f042..b18ea773b8b5 100644
> --- a/libsframe/sframe.c
> +++ b/libsframe/sframe.c
> @@ -498,7 +498,7 @@ flip_sframe (char *frame_buf, size_t buf_size, uint32_t to_foreign)
> fre_offset = fdep->sfde_func_start_fre_off;
> }
>
> - fp = frame_buf + sframe_get_hdr_size (ihp) + ihp->sfh_freoff;
> + fp = frame_buf + hdrsz + ihp->sfh_freoff;
> fp += fre_offset;
> for (; j < prev_frep_index + num_fres; j++)
> {
> @@ -513,8 +513,12 @@ flip_sframe (char *frame_buf, size_t buf_size, uint32_t to_foreign)
> prev_frep_index = j;
> }
> /* All FDEs and FREs must have been endian flipped by now. */
> - if ((j != ihp->sfh_num_fres) || (bytes_flipped != (buf_size - hdrsz)))
> + if ((j != ihp->sfh_num_fres) || (bytes_flipped > (buf_size - hdrsz)))
> goto bad;
> + /* Optional trailing section padding. */
> + for (fp = frame_buf + hdrsz + bytes_flipped; fp < frame_buf + buf_size; fp++)
> + if (*fp != '\0')
> + goto bad;
>
> /* Success. */
> return 0;
More information about the Binutils
mailing list