libsframe misaligned uint32_t

Indu Bhagat indu.bhagat@oracle.com
Wed Jan 21 07:26:26 GMT 2026


On 1/20/26 3:32 PM, Alan Modra wrote:
> I saw asan complaints about misaligned loads and stores when taking a
> quick look at pr33810 before Jens' patch was applied.  They have
> disappeared now, but it looks to me like a FRE can start on any
> address boundary and there is no padding or suchlike to align the
> FRE fields.
> 
> 	* sframe.c (flip_fre_stack_offsets): Let the compiler know
> 	that integers may be misaligned.
> 
> Indu, is this OK to apply?
> 

Yes.  Thanks!

> diff --git a/libsframe/sframe.c b/libsframe/sframe.c
> index 3f76629665c..e915d363ca2 100644
> --- a/libsframe/sframe.c
> +++ b/libsframe/sframe.c
> @@ -402,21 +402,21 @@ flip_fre_start_address (void *addr, uint32_t fre_type)
>   }
>   
>   static void
> -flip_fre_stack_offsets (char *offsets, uint8_t offset_size, uint8_t offset_cnt)
> +flip_fre_stack_offsets (void *offsets, uint8_t offset_size, uint8_t offset_cnt)
>   {
>     int j;
>   
>     if (offset_size == SFRAME_FRE_OFFSET_2B)
>       {
> -      uint16_t *ust = (uint16_t *)offsets;
> -      for (j = offset_cnt; j > 0; ust++, j--)
> -	swap_thing (*ust);
> +      struct { uint16_t x; } ATTRIBUTE_PACKED *p = offsets;
> +      for (j = offset_cnt; j > 0; p++, j--)
> +	swap_thing (p->x);
>       }
>     else if (offset_size == SFRAME_FRE_OFFSET_4B)
>       {
> -      uint32_t *uit = (uint32_t *)offsets;
> -      for (j = offset_cnt; j > 0; uit++, j--)
> -	swap_thing (*uit);
> +      struct { uint32_t x; } ATTRIBUTE_PACKED *p = offsets;
> +      for (j = offset_cnt; j > 0; p++, j--)
> +	swap_thing (p->x);
>       }
>   }
>   
> 



More information about the Binutils mailing list