]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
libsframe misaligned uint32_t
authorAlan Modra <amodra@gmail.com>
Mon, 19 Jan 2026 22:13:25 +0000 (08:43 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 21 Jan 2026 07:17:03 +0000 (17:47 +1030)
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.

libsframe/sframe.c

index 3f76629665cbdd82ad18becd42f97c5591366217..e915d363ca220eee859c0e09b6ea289112a4c19f 100644 (file)
@@ -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);
     }
 }