Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/pax-utils:master commit in: /
Date: Sun, 03 Jan 2016 22:23:54
Message-Id: 1451859768.579c7f16f20a531d47ef3cde14815ed0aa03f94e.vapier@gentoo
1 commit: 579c7f16f20a531d47ef3cde14815ed0aa03f94e
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jan 3 22:22:48 2016 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Sun Jan 3 22:22:48 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=579c7f16
7
8 paxelf: add a helper for accessing e_flags
9
10 paxelf.c | 22 +++++++++++++---------
11 1 file changed, 13 insertions(+), 9 deletions(-)
12
13 diff --git a/paxelf.c b/paxelf.c
14 index ff385c5..a353e57 100644
15 --- a/paxelf.c
16 +++ b/paxelf.c
17 @@ -108,6 +108,15 @@ const char *get_endian(elfobj *elf)
18 }
19 }
20
21 +/* translate elf EF_ defines -- tricky as it's based on EM_ */
22 +static unsigned int get_eflags(elfobj *elf)
23 +{
24 + if (elf->elf_class == ELFCLASS32)
25 + return EGET(EHDR32(elf->ehdr)->e_flags);
26 + else
27 + return EGET(EHDR64(elf->ehdr)->e_flags);
28 +}
29 +
30 static int arm_eabi_poker(elfobj *elf)
31 {
32 unsigned int emachine, eflags;
33 @@ -115,16 +124,11 @@ static int arm_eabi_poker(elfobj *elf)
34 if (ELFOSABI_NONE != elf->data[EI_OSABI])
35 return -1;
36
37 - if (elf->elf_class == ELFCLASS32) {
38 - emachine = EHDR32(elf->ehdr)->e_machine;
39 - eflags = EHDR32(elf->ehdr)->e_flags;
40 - } else {
41 - emachine = EHDR64(elf->ehdr)->e_machine;
42 - eflags = EHDR64(elf->ehdr)->e_flags;
43 - }
44 + emachine = get_emtype(elf);
45 + eflags = get_eflags(elf);
46
47 - if (EGET(emachine) == EM_ARM)
48 - return EF_ARM_EABI_VERSION(EGET(eflags)) >> 24;
49 + if (emachine == EM_ARM)
50 + return EF_ARM_EABI_VERSION(eflags) >> 24;
51 else
52 return -1;
53 }