diff options
Diffstat (limited to 'libdwfl/dwfl_segment_report_module.c')
-rw-r--r-- | libdwfl/dwfl_segment_report_module.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index a6d6be85..7f756392 100644 --- a/libdwfl/dwfl_segment_report_module.c +++ b/libdwfl/dwfl_segment_report_module.c | |||
@@ -367,6 +367,20 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, | |||
367 | e_ident = ((const unsigned char *) buffer); | 367 | e_ident = ((const unsigned char *) buffer); |
368 | ei_class = e_ident[EI_CLASS]; | 368 | ei_class = e_ident[EI_CLASS]; |
369 | ei_data = e_ident[EI_DATA]; | 369 | ei_data = e_ident[EI_DATA]; |
370 | /* buffer may be unaligned, in which case xlatetom would not work. | ||
371 | xlatetom does work when the in and out d_buf are equal (but not | ||
372 | for any other overlap). */ | ||
373 | size_t ehdr_align = (ei_class == ELFCLASS32 | ||
374 | ? __alignof__ (Elf32_Ehdr) | ||
375 | : __alignof__ (Elf64_Ehdr)); | ||
376 | if (((uintptr_t) buffer & (ehdr_align - 1)) != 0) | ||
377 | { | ||
378 | memcpy (&ehdr, buffer, | ||
379 | (ei_class == ELFCLASS32 | ||
380 | ? sizeof (Elf32_Ehdr) | ||
381 | : sizeof (Elf64_Ehdr))); | ||
382 | xlatefrom.d_buf = &ehdr; | ||
383 | } | ||
370 | switch (ei_class) | 384 | switch (ei_class) |
371 | { | 385 | { |
372 | case ELFCLASS32: | 386 | case ELFCLASS32: |