diff options
author | Mike Frysinger <vapier@gentoo.org> | 2016-01-03 17:22:48 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2016-01-03 17:22:48 -0500 |
commit | 579c7f16f20a531d47ef3cde14815ed0aa03f94e (patch) | |
tree | e9917212f902de776308db7a1a15a18c804a077e | |
parent | paxelf: switch low level elf helpers to unsigned ints (diff) | |
download | pax-utils-579c7f16f20a531d47ef3cde14815ed0aa03f94e.tar.gz pax-utils-579c7f16f20a531d47ef3cde14815ed0aa03f94e.tar.bz2 pax-utils-579c7f16f20a531d47ef3cde14815ed0aa03f94e.zip |
paxelf: add a helper for accessing e_flags
-rw-r--r-- | paxelf.c | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -108,6 +108,15 @@ const char *get_endian(elfobj *elf) } } +/* translate elf EF_ defines -- tricky as it's based on EM_ */ +static unsigned int get_eflags(elfobj *elf) +{ + if (elf->elf_class == ELFCLASS32) + return EGET(EHDR32(elf->ehdr)->e_flags); + else + return EGET(EHDR64(elf->ehdr)->e_flags); +} + static int arm_eabi_poker(elfobj *elf) { unsigned int emachine, eflags; @@ -115,16 +124,11 @@ static int arm_eabi_poker(elfobj *elf) if (ELFOSABI_NONE != elf->data[EI_OSABI]) return -1; - if (elf->elf_class == ELFCLASS32) { - emachine = EHDR32(elf->ehdr)->e_machine; - eflags = EHDR32(elf->ehdr)->e_flags; - } else { - emachine = EHDR64(elf->ehdr)->e_machine; - eflags = EHDR64(elf->ehdr)->e_flags; - } + emachine = get_emtype(elf); + eflags = get_eflags(elf); - if (EGET(emachine) == EM_ARM) - return EF_ARM_EABI_VERSION(EGET(eflags)) >> 24; + if (emachine == EM_ARM) + return EF_ARM_EABI_VERSION(eflags) >> 24; else return -1; } |