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 938411382C5 for ; Fri, 16 Apr 2021 19:03:39 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DE957E07D8; Fri, 16 Apr 2021 19:03:38 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 949C4E07D8 for ; Fri, 16 Apr 2021 19:03:38 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id ABC5C340BB9 for ; Fri, 16 Apr 2021 19:03:37 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 677C95D2 for ; Fri, 16 Apr 2021 19:03:36 +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: <1618592401.1f3572f01249e929feb26309fed5c2ce7d932a86.vapier@gentoo> Subject: [gentoo-commits] proj/pax-utils:master commit in: / X-VCS-Repository: proj/pax-utils X-VCS-Files: .gitignore Makefile paxldso.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 1f3572f01249e929feb26309fed5c2ce7d932a86 X-VCS-Branch: master Date: Fri, 16 Apr 2021 19:03:36 +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-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 878af77c-6cd1-41bd-931a-c36078dc738a X-Archives-Hash: 2513c86ba2ba727df2f117fe248351aa commit: 1f3572f01249e929feb26309fed5c2ce7d932a86 Author: Mike Frysinger chromium org> AuthorDate: Fri Apr 16 17:00:01 2021 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Fri Apr 16 17:00:01 2021 +0000 URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=1f3572f0 build: support debugging/testing object internals Add a hack so we can build individual objects as standalone programs. This way we can more easily poke internal static funcs to aid in the overall debugging/development process. Bug: https://bugs.gentoo.org/739014 Signed-off-by: Mike Frysinger gentoo.org> .gitignore | 3 +++ Makefile | 20 +++++++++++++++----- paxldso.c | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 6e0a530..33f051f 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,9 @@ stamp-h1 /dumpelf /lddtree +/paxelf +/paxldso +/paxmacho /pspax /scanelf /scanmacho diff --git a/Makefile b/Makefile index c906311..8a54faf 100644 --- a/Makefile +++ b/Makefile @@ -67,19 +67,26 @@ endif override CPPFLAGS += -DVCSID='"$(VCSID)"' #################################################################### -ELF_TARGETS = scanelf dumpelf $(shell echo | $(CC) -dM -E - | grep -q __svr4__ || echo pspax) +ELF_TARGETS = scanelf dumpelf $(shell $(CC) -dM -E - .depend clean: - -rm -f $(OBJS) $(TARGETS) + -rm -f $(OBJS) $(TARGETS) $(OBJS_TARGETS) distclean: clean -rm -f *~ core *.o diff --git a/paxldso.c b/paxldso.c index 2d8ddea..d89210d 100644 --- a/paxldso.c +++ b/paxldso.c @@ -371,3 +371,21 @@ void paxldso_cleanup(void) #endif const char * ldcache_path = "/etc/ld.so.cache"; + +#ifdef MAIN + +const char argv0[] = "paxldso"; + +int main(int argc, char *argv[]) +{ + elfobj *elf = readelf(argv[0]); + for (int i = 1; i < argc; ++i) { + const char *search = argv[i]; + const char *lib = ldso_cache_lookup_lib(elf, search); + printf("%s -> %s\n", search, lib); + } + unreadelf(elf); + paxldso_cleanup(); +} + +#endif