From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id E50C81384B4 for ; Sun, 3 Jan 2016 22:23:54 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5A786E07E6; Sun, 3 Jan 2016 22:23:54 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 00AAEE07E6 for ; Sun, 3 Jan 2016 22:23:53 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id EF1493406DD for ; Sun, 3 Jan 2016 22:23:52 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 629F4CF4 for ; Sun, 3 Jan 2016 22:23:50 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1451859768.579c7f16f20a531d47ef3cde14815ed0aa03f94e.vapier@gentoo> Subject: [gentoo-commits] proj/pax-utils:master commit in: / X-VCS-Repository: proj/pax-utils X-VCS-Files: paxelf.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 579c7f16f20a531d47ef3cde14815ed0aa03f94e X-VCS-Branch: master Date: Sun, 3 Jan 2016 22:23:50 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: d8fd50ed-3ad7-4ab3-8e0b-cc82a7a725c2 X-Archives-Hash: b6abbf0e58aed028906d514970e35d4e commit: 579c7f16f20a531d47ef3cde14815ed0aa03f94e Author: Mike Frysinger gentoo org> AuthorDate: Sun Jan 3 22:22:48 2016 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Sun Jan 3 22:22:48 2016 +0000 URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=579c7f16 paxelf: add a helper for accessing e_flags paxelf.c | 22 +++++++++++++--------- 1 file 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; }