libdwfl: Calculate addr to read by hand in link_map.c read_addrs.
Commit Message
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 <mark@klomp.org>
---
libdwfl/ChangeLog | 4 ++++
libdwfl/link_map.c | 11 +++++------
2 files changed, 9 insertions(+), 6 deletions(-)
Comments
On Fri, Dec 24, 2021 at 02:06:08AM +0100, Mark Wielaard wrote:
> 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
Pushed
@@ -1,3 +1,7 @@
+2021-12-23 Mark Wielaard <mark@klomp.org>
+
+ * link_map.c (read_addrs): Calculate addr to read by hand.
+
2021-12-23 Mark Wielaard <mark@klomp.org>
* link_map.c (dwfl_link_map_report): Call memcpy and set in.d_buf to
@@ -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;