The gcc undefined sanitizer doesn't like the trick we use to calculate the (possibly) unaligned addresses to read. So calculate them by hand as unsigned char pointers.
https://sourceware.org/bugzilla/show_bug.cgi?id=28720 Signed-off-by: Mark Wielaard <m...@klomp.org> --- libdwfl/ChangeLog | 4 ++++ libdwfl/link_map.c | 11 +++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 73d8613c..149383ad 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,7 @@ +2021-12-23 Mark Wielaard <m...@klomp.org> + + * link_map.c (read_addrs): Calculate addr to read by hand. + 2021-12-23 Mark Wielaard <m...@klomp.org> * link_map.c (dwfl_link_map_report): Call memcpy and set in.d_buf to diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c index f57c5585..cd9c5042 100644 --- a/libdwfl/link_map.c +++ b/libdwfl/link_map.c @@ -270,26 +270,25 @@ read_addrs (struct memory_closure *closure, return true; } - Elf32_Addr (*a32)[n] = vaddr - (*read_vaddr) + (*buffer); - Elf64_Addr (*a64)[n] = (void *) a32; + unsigned char *addr = vaddr - (*read_vaddr) + (*buffer); if (elfclass == ELFCLASS32) { if (elfdata == ELFDATA2MSB) for (size_t i = 0; i < n; ++i) - addrs[i] = BE32 (read_4ubyte_unaligned_noncvt (&(*a32)[i])); + addrs[i] = BE32 (read_4ubyte_unaligned_noncvt (addr + i * 4)); else for (size_t i = 0; i < n; ++i) - addrs[i] = LE32 (read_4ubyte_unaligned_noncvt (&(*a32)[i])); + addrs[i] = LE32 (read_4ubyte_unaligned_noncvt (addr + i * 4)); } else { if (elfdata == ELFDATA2MSB) for (size_t i = 0; i < n; ++i) - addrs[i] = BE64 (read_8ubyte_unaligned_noncvt (&(*a64)[i])); + addrs[i] = BE64 (read_8ubyte_unaligned_noncvt (addr + i * 8)); else for (size_t i = 0; i < n; ++i) - addrs[i] = LE64 (read_8ubyte_unaligned_noncvt (&(*a64)[i])); + addrs[i] = LE64 (read_8ubyte_unaligned_noncvt (addr + i * 8)); } return false; -- 2.30.2