aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2016-01-03 17:22:48 -0500
committerMike Frysinger <vapier@gentoo.org>2016-01-03 17:22:48 -0500
commit579c7f16f20a531d47ef3cde14815ed0aa03f94e (patch)
treee9917212f902de776308db7a1a15a18c804a077e
parentpaxelf: switch low level elf helpers to unsigned ints (diff)
downloadpax-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.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/paxelf.c b/paxelf.c
index ff385c5..a353e57 100644
--- a/paxelf.c
+++ b/paxelf.c
@@ -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;
}