2021-12-23 Mark Wielaard <mark@klomp.org>
+ * link_map.c (dwfl_link_map_report): Call memcpy and set in.d_buf to
+ out.d_buf before calling xlatetom for unaligned buffers.
+
+2021-12-23 Mark Wielaard <mark@klomp.org>
+
* core-file.c (dwfl_elf_phdr_memory_callback): Check start <
elf->maximum_size and end - start < minread.
return false;
}
}
+ bool is32 = (elfclass == ELFCLASS32);
+ size_t phdr_align = (is32
+ ? __alignof__ (Elf32_Phdr)
+ : __alignof__ (Elf64_Phdr));
+ if (!in_from_exec
+ && ((uintptr_t) in.d_buf & (phdr_align - 1)) != 0)
+ {
+ memcpy (out.d_buf, in.d_buf, in.d_size);
+ in.d_buf = out.d_buf;
+ }
if (likely ((elfclass == ELFCLASS32
? elf32_xlatetom : elf64_xlatetom)
(&out, &in, elfdata) != NULL))
{
- bool is32 = (elfclass == ELFCLASS32);
for (size_t i = 0; i < phnum; ++i)
{
GElf_Word type = (is32
};
if (in.d_size > out.d_size)
in.d_size = out.d_size;
+ size_t dyn_align = (elfclass == ELFCLASS32
+ ? __alignof__ (Elf32_Dyn)
+ : __alignof__ (Elf64_Dyn));
+ if (((uintptr_t) in.d_buf & (dyn_align - 1)) != 0)
+ {
+ memcpy (out.d_buf, in.d_buf, in.d_size);
+ in.d_buf = out.d_buf;
+ }
if (likely ((elfclass == ELFCLASS32
? elf32_xlatetom : elf64_xlatetom)
(&out, &in, elfdata) != NULL))