summaryrefslogtreecommitdiffstats
path: root/libdwfl
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2021-12-24 02:01:32 +0100
committerMark Wielaard <mark@klomp.org>2022-01-04 00:36:52 +0100
commit9f70a762ab88ceebb8a48a7c9c3ce39ff7f205af (patch)
treedf754f137ff272259fce7f453c5e06639e7b9707 /libdwfl
parentlibdwfl: Call xlatetom on aligned buffers in dwfl_link_map_report (diff)
downloadelfutils-9f70a762ab88ceebb8a48a7c9c3ce39ff7f205af.tar.gz
elfutils-9f70a762ab88ceebb8a48a7c9c3ce39ff7f205af.tar.bz2
elfutils-9f70a762ab88ceebb8a48a7c9c3ce39ff7f205af.tar.xz
libdwfl: Calculate addr to read by hand in link_map.c read_addrs.
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>
Diffstat (limited to 'libdwfl')
-rw-r--r--libdwfl/ChangeLog4
-rw-r--r--libdwfl/link_map.c11
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,5 +1,9 @@
12021-12-23 Mark Wielaard <mark@klomp.org> 12021-12-23 Mark Wielaard <mark@klomp.org>
2 2
3 * link_map.c (read_addrs): Calculate addr to read by hand.
4
52021-12-23 Mark Wielaard <mark@klomp.org>
6
3 * link_map.c (dwfl_link_map_report): Call memcpy and set in.d_buf to 7 * link_map.c (dwfl_link_map_report): Call memcpy and set in.d_buf to
4 out.d_buf before calling xlatetom for unaligned buffers. 8 out.d_buf before calling xlatetom for unaligned buffers.
5 9
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,
270 return true; 270 return true;
271 } 271 }
272 272
273 Elf32_Addr (*a32)[n] = vaddr - (*read_vaddr) + (*buffer); 273 unsigned char *addr = vaddr - (*read_vaddr) + (*buffer);
274 Elf64_Addr (*a64)[n] = (void *) a32;
275 274
276 if (elfclass == ELFCLASS32) 275 if (elfclass == ELFCLASS32)
277 { 276 {
278 if (elfdata == ELFDATA2MSB) 277 if (elfdata == ELFDATA2MSB)
279 for (size_t i = 0; i < n; ++i) 278 for (size_t i = 0; i < n; ++i)
280 addrs[i] = BE32 (read_4ubyte_unaligned_noncvt (&(*a32)[i])); 279 addrs[i] = BE32 (read_4ubyte_unaligned_noncvt (addr + i * 4));
281 else 280 else
282 for (size_t i = 0; i < n; ++i) 281 for (size_t i = 0; i < n; ++i)
283 addrs[i] = LE32 (read_4ubyte_unaligned_noncvt (&(*a32)[i])); 282 addrs[i] = LE32 (read_4ubyte_unaligned_noncvt (addr + i * 4));
284 } 283 }
285 else 284 else
286 { 285 {
287 if (elfdata == ELFDATA2MSB) 286 if (elfdata == ELFDATA2MSB)
288 for (size_t i = 0; i < n; ++i) 287 for (size_t i = 0; i < n; ++i)
289 addrs[i] = BE64 (read_8ubyte_unaligned_noncvt (&(*a64)[i])); 288 addrs[i] = BE64 (read_8ubyte_unaligned_noncvt (addr + i * 8));
290 else 289 else
291 for (size_t i = 0; i < n; ++i) 290 for (size_t i = 0; i < n; ++i)
292 addrs[i] = LE64 (read_8ubyte_unaligned_noncvt (&(*a64)[i])); 291 addrs[i] = LE64 (read_8ubyte_unaligned_noncvt (addr + i * 8));
293 } 292 }
294 293
295 return false; 294 return false;