From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 13318139085 for ; Tue, 24 Jan 2017 06:50:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 47766E0DE1; Tue, 24 Jan 2017 06:50:12 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 15FA7234010 for ; Tue, 24 Jan 2017 06:50:12 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 378CD3416B6 for ; Tue, 24 Jan 2017 06:50:10 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id CAF2C2D58 for ; Tue, 24 Jan 2017 06:50:08 +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: <1485225761.248f21bc40c850b470b6128de00a3437587f9293.vapier@gentoo> Subject: [gentoo-commits] proj/pax-utils:master commit in: / X-VCS-Repository: proj/pax-utils X-VCS-Files: scanelf.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 248f21bc40c850b470b6128de00a3437587f9293 X-VCS-Branch: master Date: Tue, 24 Jan 2017 06:50:08 +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: 0bfbf5ed-77ce-4365-8f41-863ef9abb182 X-Archives-Hash: 0c16b9696e15f3384abee1bf769c00e4 commit: 248f21bc40c850b470b6128de00a3437587f9293 Author: Mike Frysinger gentoo org> AuthorDate: Tue Jan 24 02:42:41 2017 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Tue Jan 24 02:42:41 2017 +0000 URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=248f21bc scanelf: switch all string table lookups to scanelf_file_get_symtabs We don't care about the .strtab-vs-.dynstr, but we do want to fall back to tables that can only be found via dynamic tags and program headers. scanelf.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/scanelf.c b/scanelf.c index ceec26d..9695276 100644 --- a/scanelf.c +++ b/scanelf.c @@ -767,16 +767,16 @@ static void rpath_security_checks(elfobj *elf, char *item, const char *dt_type) static void scanelf_file_rpath(elfobj *elf, char *found_rpath, char **ret, size_t *ret_len) { char *rpath, *runpath, **r; - void *strtbl_void; + void *symtab_void, *strtab_void; if (!show_rpath) return; - strtbl_void = elf_findsecbyname(elf, ".dynstr"); + scanelf_file_get_symtabs(elf, &symtab_void, &strtab_void); rpath = runpath = NULL; #define SHOW_RPATH(B) \ Elf ## B ## _Dyn *dyn; \ - Elf ## B ## _Shdr *strtbl = SHDR ## B (strtbl_void); \ + Elf ## B ## _Shdr *strtab = SHDR ## B (strtab_void); \ Elf ## B ## _Off offset; \ Elf ## B ## _Xword word; \ \ @@ -791,7 +791,7 @@ static void scanelf_file_rpath(elfobj *elf, char *found_rpath, char **ret, size_ continue; \ } \ /* Verify the memory is somewhat sane */ \ - offset = EGET(strtbl->sh_offset) + EGET(dyn->d_un.d_ptr); \ + offset = EGET(strtab->sh_offset) + EGET(dyn->d_un.d_ptr); \ if (offset < (Elf ## B ## _Off)elf->len) { \ if (*r) warn("ELF has multiple %s's !?", get_elfdtype(word)); \ *r = elf->data + offset; \ @@ -873,7 +873,7 @@ static void scanelf_file_rpath(elfobj *elf, char *found_rpath, char **ret, size_ } \ } \ } - if (elf->phdr && strtbl_void) + if (elf->phdr && strtab_void) SCANELF_ELF_SIZED(SHOW_RPATH); if (be_wewy_wewy_quiet) return; @@ -913,7 +913,7 @@ static char *lookup_config_lib(const char *fname) static const char *scanelf_file_needed_lib(elfobj *elf, char *found_needed, char *found_lib, int op, char **ret, size_t *ret_len) { char *needed; - void *strtbl_void; + void *symtab_void, *strtab_void; char *p; /* @@ -923,17 +923,17 @@ static const char *scanelf_file_needed_lib(elfobj *elf, char *found_needed, char if ((op == 0 && !show_needed) || (op == 1 && !find_lib)) return NULL; - strtbl_void = elf_findsecbyname(elf, ".dynstr"); + scanelf_file_get_symtabs(elf, &symtab_void, &strtab_void); #define SHOW_NEEDED(B) \ Elf ## B ## _Dyn *dyn; \ - Elf ## B ## _Shdr *strtbl = SHDR ## B (strtbl_void); \ + Elf ## B ## _Shdr *strtab = SHDR ## B (strtab_void); \ size_t matched = 0; \ \ /* Walk all the dynamic tags to find NEEDED entries */ \ scanelf_dt_for_each(B, elf, dyn) { \ if (EGET(dyn->d_tag) == DT_NEEDED) { \ - Elf ## B ## _Off offset = EGET(strtbl->sh_offset) + EGET(dyn->d_un.d_ptr); \ + Elf ## B ## _Off offset = EGET(strtab->sh_offset) + EGET(dyn->d_un.d_ptr); \ if (offset >= (Elf ## B ## _Off)elf->len) \ continue; \ needed = elf->data + offset; \ @@ -971,7 +971,7 @@ static const char *scanelf_file_needed_lib(elfobj *elf, char *found_needed, char } \ } \ } - if (elf->phdr && strtbl_void) { + if (elf->phdr && strtab_void) { SCANELF_ELF_SIZED(SHOW_NEEDED); if (op == 0 && !*found_needed && be_verbose) warn("ELF lacks DT_NEEDED sections: %s", elf->filename); @@ -987,7 +987,7 @@ static char *scanelf_file_interp(elfobj *elf, char *found_interp) if (elf->phdr) { /* Walk all the program headers to find the PT_INTERP */ -#define SHOW_PT_INTERP(B) \ +#define GET_PT_INTERP(B) \ size_t i; \ Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \ @@ -997,16 +997,16 @@ static char *scanelf_file_interp(elfobj *elf, char *found_interp) break; \ } \ } - SCANELF_ELF_SIZED(SHOW_PT_INTERP); + SCANELF_ELF_SIZED(GET_PT_INTERP); } else if (elf->shdr) { /* Use the section headers to find it */ - void *strtbl_void = elf_findsecbyname(elf, ".interp"); + void *section = elf_findsecbyname(elf, ".interp"); -#define SHOW_INTERP(B) \ - Elf ## B ## _Shdr *strtbl = SHDR ## B (strtbl_void); \ - offset = EGET(strtbl->sh_offset); - if (strtbl_void) - SCANELF_ELF_SIZED(SHOW_INTERP); +#define GET_INTERP(B) \ + Elf ## B ## _Shdr *shdr = SHDR ## B (section); \ + offset = EGET(shdr->sh_offset); + if (section) + SCANELF_ELF_SIZED(GET_INTERP); } /* Validate the pointer even if we don't use it in output */ @@ -1059,16 +1059,16 @@ static const char *scanelf_file_bind(elfobj *elf, char *found_bind) static char *scanelf_file_soname(elfobj *elf, char *found_soname) { char *soname; - void *strtbl_void; + void *symtab_void, *strtab_void; if (!show_soname) return NULL; - strtbl_void = elf_findsecbyname(elf, ".dynstr"); + scanelf_file_get_symtabs(elf, &symtab_void, &strtab_void); #define SHOW_SONAME(B) \ Elf ## B ## _Dyn *dyn; \ Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ - Elf ## B ## _Shdr *strtbl = SHDR ## B (strtbl_void); \ + Elf ## B ## _Shdr *strtab = SHDR ## B (strtab_void); \ \ /* only look for soname in shared objects */ \ if (EGET(ehdr->e_type) != ET_DYN) \ @@ -1076,7 +1076,7 @@ static char *scanelf_file_soname(elfobj *elf, char *found_soname) \ scanelf_dt_for_each(B, elf, dyn) { \ if (EGET(dyn->d_tag) == DT_SONAME) { \ - Elf ## B ## _Off offset = EGET(strtbl->sh_offset) + EGET(dyn->d_un.d_ptr); \ + Elf ## B ## _Off offset = EGET(strtab->sh_offset) + EGET(dyn->d_un.d_ptr); \ if (offset >= (Elf ## B ## _Off)elf->len) \ continue; \ soname = elf->data + offset; \ @@ -1084,7 +1084,7 @@ static char *scanelf_file_soname(elfobj *elf, char *found_soname) return (be_wewy_wewy_quiet ? NULL : soname); \ } \ } - if (elf->phdr && strtbl_void) + if (elf->phdr && strtab_void) SCANELF_ELF_SIZED(SHOW_SONAME); return NULL;