diff options
author | Indu Bhagat <indu.bhagat@oracle.com> | 2022-12-15 13:12:01 -0800 |
---|---|---|
committer | Indu Bhagat <indu.bhagat@oracle.com> | 2022-12-15 13:12:01 -0800 |
commit | 8c078abdc23238c2193136bf0edbf1d910615679 (patch) | |
tree | f5d1ccc4a9b1608341b950d79999b7c1e56ea735 /include | |
parent | 69de431392408c2fe25227908612e2bfe7b05036 (diff) | |
download | fsf-binutils-gdb-8c078abdc23238c2193136bf0edbf1d910615679.zip fsf-binutils-gdb-8c078abdc23238c2193136bf0edbf1d910615679.tar.gz fsf-binutils-gdb-8c078abdc23238c2193136bf0edbf1d910615679.tar.bz2 |
libsframe asan: avoid generating misaligned loads
There are two places where unaligned loads were seen on aarch64:
- #1. access to the SFrame FRE stack offsets in the in-memory
representation/abstraction provided by libsframe.
- #2. access to the SFrame FRE start address in the on-disk representation
of the frame row entry.
For #1, we can fix this by reordering the struct members of
sframe_frame_row_entry in libsframe/sframe-api.h.
For #2, we need to default to using memcpy instead, and copy out the bytes
to a location for output.
SFrame format is an unaligned on-disk format. As such, there are other blobs
of memory in the on-disk SFrame FRE that are on not on their natural
boundaries. But that does not pose further problems yet, because the users
are provided access to the on-disk SFrame FRE data via libsframe's
sframe_frame_row_entry, the latter has its' struct members aligned on their
respective natural boundaries (and initialized using memcpy).
PR 29856 libsframe asan: load misaligned at sframe.c:516
ChangeLog:
PR libsframe/29856
* bfd/elf64-x86-64.c: Adjust as the struct members have been
reordered.
* libsframe/sframe.c (sframe_decode_fre_start_address): Use
memcpy to perform 16-bit/32-bit reads.
* libsframe/testsuite/libsframe.encode/encode-1.c: Adjust as the
struct members have been reordered.
include/ChangeLog:
PR libsframe/29856
* sframe-api.h: Reorder fre_offsets for natural alignment.
Diffstat (limited to 'include')
-rw-r--r-- | include/sframe-api.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/sframe-api.h b/include/sframe-api.h index 0a86389..c9db39e 100644 --- a/include/sframe-api.h +++ b/include/sframe-api.h @@ -34,13 +34,17 @@ typedef struct sframe_encoder_ctx sframe_encoder_ctx; /* User interfacing SFrame Row Entry. An abstraction provided by libsframe so the consumer is decoupled from - the binary format representation of the same. */ + the binary format representation of the same. + + The members are best ordered such that they are aligned at their natural + boundaries. This helps avoid usage of undesirable misaligned memory + accesses. See PR libsframe/29856. */ typedef struct sframe_frame_row_entry { uint32_t fre_start_addr; - unsigned char fre_info; unsigned char fre_offsets[MAX_OFFSET_BYTES]; + unsigned char fre_info; } sframe_frame_row_entry; #define SFRAME_ERR ((int) -1) |