If the Elf file was mmapped and of the same endianness we can use the
phdr table directly when correctly aligned, or if ALLOW_UNALIGNED. If
the Elf file was mmapped and of different endianness then we convert
the phdrs directly when the mmapped headers were correctly aligned, or
if ALLOWED_UNALIGNED, otherwise we made a copy first. It is unlikely
these tables are unaligned in a proper Elf file, so drop the
ALLOW_UNALIGNED condition.
* libelf/elf32_getphdr.c (getphdr_wrlock): Drop the
ALLOW_UNALIGNED condition.
Signed-off-by: Mark Wielaard <[email protected]>
---
libelf/elf32_getphdr.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/libelf/elf32_getphdr.c b/libelf/elf32_getphdr.c
index e41c660daf54..e9828b46f97b 100644
--- a/libelf/elf32_getphdr.c
+++ b/libelf/elf32_getphdr.c
@@ -103,9 +103,8 @@ __elfw2(LIBELFBITS,getphdr_wrlock) (Elf *elf)
void *file_phdr = ((char *) elf->map_address
+ elf->start_offset + ehdr->e_phoff);
if (ehdr->e_ident[EI_DATA] == MY_ELFDATA
- && (ALLOW_UNALIGNED
- || ((uintptr_t) file_phdr
- & (__alignof__ (ElfW2(LIBELFBITS,Phdr)) - 1)) == 0))
+ && ((uintptr_t) file_phdr
+ & (__alignof__ (ElfW2(LIBELFBITS,Phdr)) - 1)) == 0)
/* Simply use the mapped data. */
elf->state.ELFW(elf,LIBELFBITS).phdr = file_phdr;
else
@@ -129,16 +128,12 @@ __elfw2(LIBELFBITS,getphdr_wrlock) (Elf *elf)
byte order. */
if (ehdr->e_ident[EI_DATA] == MY_ELFDATA)
- {
- assert (! ALLOW_UNALIGNED);
- memcpy (phdr, file_phdr, size);
- }
+ memcpy (phdr, file_phdr, size);
else
{
- bool copy = ! (ALLOW_UNALIGNED
- || ((uintptr_t) file_phdr
- & (__alignof__ (ElfW2(LIBELFBITS,Phdr))
- - 1)) == 0);
+ bool copy = ((uintptr_t) file_phdr
+ & (__alignof__ (ElfW2(LIBELFBITS,Phdr)) - 1
+ != 0));
if (! copy)
notcvt = file_phdr;
else
--
2.56.1