summaryrefslogtreecommitdiffstats
path: root/libdwfl
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2021-12-20 01:39:21 +0100
committerMark Wielaard <mark@klomp.org>2021-12-20 01:44:49 +0100
commit8f8c78cc885d83f999f952dfaa2c2e4595b38f83 (patch)
tree84cfab670ef1ecb1ed0a569af3ac26ea274f0e0d /libdwfl
parentlibdwfl: Handle unaligned Phdr in dwfl_segment_report_module (diff)
downloadelfutils-8f8c78cc885d83f999f952dfaa2c2e4595b38f83.tar.gz
elfutils-8f8c78cc885d83f999f952dfaa2c2e4595b38f83.tar.bz2
elfutils-8f8c78cc885d83f999f952dfaa2c2e4595b38f83.tar.xz
libdwfl: Handle unaligned Nhdr in dwfl_segment_report_module
The xlate functions only handle correctly aligned buffers. But they do handle src == dest. So if the source buffer isn't aligned correctly just copy it first into the destination (which is already correctly aligned). https://sourceware.org/bugzilla/show_bug.cgi?id=28715 Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdwfl')
-rw-r--r--libdwfl/ChangeLog5
-rw-r--r--libdwfl/dwfl_segment_report_module.c12
2 files changed, 17 insertions, 0 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index ac0fbe0f..6015f6b7 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,6 +1,11 @@
12021-12-19 Mark Wielaard <mark@klomp.org> 12021-12-19 Mark Wielaard <mark@klomp.org>
2 2
3 * dwfl_segment_report_module.c (dwfl_segment_report_module): Copy 3 * dwfl_segment_report_module.c (dwfl_segment_report_module): Copy
4 data and set xlatefrom.d_buf to notes when data is not aligned.
5
62021-12-19 Mark Wielaard <mark@klomp.org>
7
8 * dwfl_segment_report_module.c (dwfl_segment_report_module): Copy
4 ph_buffer and set xlatefrom.d_buf to phdrsp when ph_buffer is not 9 ph_buffer and set xlatefrom.d_buf to phdrsp when ph_buffer is not
5 aligned. 10 aligned.
6 11
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index de190e90..72c85070 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -573,6 +573,18 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
573 xlatefrom.d_size = filesz; 573 xlatefrom.d_size = filesz;
574 xlateto.d_buf = notes; 574 xlateto.d_buf = notes;
575 xlateto.d_size = filesz; 575 xlateto.d_size = filesz;
576
577 /* data may be unaligned, in which case xlatetom would not work.
578 xlatetom does work when the in and out d_buf are equal (but not
579 for any other overlap). */
580 if ((uintptr_t) data != (align == 8
581 ? NOTE_ALIGN8 ((uintptr_t) data)
582 : NOTE_ALIGN4 ((uintptr_t) data)))
583 {
584 memcpy (notes, data, filesz);
585 xlatefrom.d_buf = notes;
586 }
587
576 if (elf32_xlatetom (&xlateto, &xlatefrom, xencoding) == NULL) 588 if (elf32_xlatetom (&xlateto, &xlatefrom, xencoding) == NULL)
577 { 589 {
578 free (notes); 590 free (notes);