diff options
| author | Mark Wielaard <[email protected]> | 2015-06-04 16:25:37 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2015-06-09 22:50:31 +0200 |
| commit | ede1d9d8aa4b04810e1ee04fcec9386e63f48d77 (patch) | |
| tree | a756cc1fed073f06a4c8671486cfa093d44a3132 /libelf/elf_getdata.c | |
| parent | 9a9f7f6667ae156c8fb8e1290d855d8b8e893461 (diff) | |
libelf: Make sure elf_getdata_rawchunk returns aligned data.
elf_getdata_rawchunk might return an unaligned buffer for the requested
ELF data type. Make sure the data is also correctly aligned when using
an mmapped file. Also add some missing alignments for ELF data types
for __libelf_type_align (the missing types could also make elf_getdata
to return unaligned data).
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libelf/elf_getdata.c')
| -rw-r--r-- | libelf/elf_getdata.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libelf/elf_getdata.c b/libelf/elf_getdata.c index 1a4981ef..770e0355 100644 --- a/libelf/elf_getdata.c +++ b/libelf/elf_getdata.c @@ -83,8 +83,15 @@ const uint_fast8_t __libelf_type_aligns[EV_NUM - 1][ELFCLASSNUM - 1][ELF_T_NUM] # define TYPE_ALIGNS(Bits) \ { \ [ELF_T_ADDR] = __alignof__ (ElfW2(Bits,Addr)), \ + [ELF_T_EHDR] = __alignof__ (ElfW2(Bits,Ehdr)), \ [ELF_T_HALF] = __alignof__ (ElfW2(Bits,Half)), \ + [ELF_T_OFF] = __alignof__ (ElfW2(Bits,Off)), \ + [ELF_T_PHDR] = __alignof__ (ElfW2(Bits,Phdr)), \ + [ELF_T_SHDR] = __alignof__ (ElfW2(Bits,Shdr)), \ + [ELF_T_SWORD] = __alignof__ (ElfW2(Bits,Sword)), \ [ELF_T_WORD] = __alignof__ (ElfW2(Bits,Word)), \ + [ELF_T_XWORD] = __alignof__ (ElfW2(Bits,Xword)), \ + [ELF_T_SXWORD] = __alignof__ (ElfW2(Bits,Sxword)), \ [ELF_T_SYM] = __alignof__ (ElfW2(Bits,Sym)), \ [ELF_T_SYMINFO] = __alignof__ (ElfW2(Bits,Syminfo)), \ [ELF_T_REL] = __alignof__ (ElfW2(Bits,Rel)), \ @@ -97,6 +104,8 @@ const uint_fast8_t __libelf_type_aligns[EV_NUM - 1][ELFCLASSNUM - 1][ELF_T_NUM] [ELF_T_MOVE] = __alignof__ (ElfW2(Bits,Move)), \ [ELF_T_LIB] = __alignof__ (ElfW2(Bits,Lib)), \ [ELF_T_NHDR] = __alignof__ (ElfW2(Bits,Nhdr)), \ + [ELF_T_GNUHASH] = __alignof__ (Elf32_Word), \ + [ELF_T_AUXV] = __alignof__ (ElfW2(Bits,auxv_t)), \ } [EV_CURRENT - 1] = { |
