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 EDE2113908F for ; Tue, 24 Jan 2017 20:39:51 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1005521C095; Tue, 24 Jan 2017 20:39:51 +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 CCE4A21C095 for ; Tue, 24 Jan 2017 20:39:50 +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 B849A34102B for ; Tue, 24 Jan 2017 20:39:49 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 243562E15 for ; Tue, 24 Jan 2017 20:39:48 +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: <1485289346.6a73ea4e32cc6ff6d1814048368b7b75da626565.vapier@gentoo> Subject: [gentoo-commits] proj/pax-utils:master commit in: / X-VCS-Repository: proj/pax-utils X-VCS-Files: TODO scanelf.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 6a73ea4e32cc6ff6d1814048368b7b75da626565 X-VCS-Branch: master Date: Tue, 24 Jan 2017 20:39:48 +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: a84c45a1-923d-4021-bfd0-c7f5118f9d77 X-Archives-Hash: 2a2066098e1df4769903b9e63da3402e commit: 6a73ea4e32cc6ff6d1814048368b7b75da626565 Author: Mike Frysinger gentoo org> AuthorDate: Tue Jan 24 20:22:26 2017 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Tue Jan 24 20:22:26 2017 +0000 URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=6a73ea4e scanelf: revert back to looking at .dynstr directly The rpath/needed/soname strings are only listed in .dynstr, so trying to locate them in .strtab fails. Which means using the lookup helper breaks behavior on non-stripped files. TODO | 4 ++++ scanelf.c | 27 +++++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index be2d0a2..ded1158 100644 --- a/TODO +++ b/TODO @@ -30,3 +30,7 @@ allow digging into ARM_ATTRIBUTES (.ARM.attributes) sections - need info on the section layout - figure out how to integrate cleanly (target-independent driller) http://sourceware.org/binutils/docs/as/GNU-Object-Attributes.html + +scanelf should look at the dynamic table for rpath/needed/soname entries instead +of requiring section headers and looking up by section names. need to implement +support for GNU_HASH first though so we can get the string table sizes. diff --git a/scanelf.c b/scanelf.c index 9695276..79ce59c 100644 --- a/scanelf.c +++ b/scanelf.c @@ -767,11 +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 *symtab_void, *strtab_void; + void *strtab_void; if (!show_rpath) return; - scanelf_file_get_symtabs(elf, &symtab_void, &strtab_void); + /* + * TODO: Switch to the string table found via dynamic tags. + * Note: We can't use scanelf_file_get_symtabs as these strings are + * *only* found in dynstr and not in .strtab. + */ + strtab_void = elf_findsecbyname(elf, ".dynstr"); rpath = runpath = NULL; #define SHOW_RPATH(B) \ @@ -913,7 +918,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 *symtab_void, *strtab_void; + void *strtab_void; char *p; /* @@ -923,7 +928,12 @@ static const char *scanelf_file_needed_lib(elfobj *elf, char *found_needed, char if ((op == 0 && !show_needed) || (op == 1 && !find_lib)) return NULL; - scanelf_file_get_symtabs(elf, &symtab_void, &strtab_void); + /* + * TODO: Switch to the string table found via dynamic tags. + * Note: We can't use scanelf_file_get_symtabs as these strings are + * *only* found in dynstr and not in .strtab. + */ + strtab_void = elf_findsecbyname(elf, ".dynstr"); #define SHOW_NEEDED(B) \ Elf ## B ## _Dyn *dyn; \ @@ -1059,11 +1069,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 *symtab_void, *strtab_void; + void *strtab_void; if (!show_soname) return NULL; - scanelf_file_get_symtabs(elf, &symtab_void, &strtab_void); + /* + * TODO: Switch to the string table found via dynamic tags. + * Note: We can't use scanelf_file_get_symtabs as these strings are + * *only* found in dynstr and not in .strtab. + */ + strtab_void = elf_findsecbyname(elf, ".dynstr"); #define SHOW_SONAME(B) \ Elf ## B ## _Dyn *dyn; \