From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7630 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] First prototype of script which adds CFI directives to x86 asm Date: Tue, 12 May 2015 18:52:13 -0400 Message-ID: <20150512225212.GX17573@brightrain.aerifal.cx> References: <1431466124-2848-1-git-send-email-alexinbeijing@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1431471150 20970 80.91.229.3 (12 May 2015 22:52:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 12 May 2015 22:52:30 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7642-gllmg-musl=m.gmane.org@lists.openwall.com Wed May 13 00:52:30 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1YsJ2L-0001TM-J6 for gllmg-musl@m.gmane.org; Wed, 13 May 2015 00:52:29 +0200 Original-Received: (qmail 30152 invoked by uid 550); 12 May 2015 22:52:27 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 30130 invoked from network); 12 May 2015 22:52:27 -0000 Content-Disposition: inline In-Reply-To: <1431466124-2848-1-git-send-email-alexinbeijing@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:7630 Archived-At: On Tue, May 12, 2015 at 11:28:44PM +0200, Alex Dowad wrote: > Some functions implemented in asm need to use EBP for purposes other than acting > as a frame pointer. (Notably, it is used for the 6th argument to syscalls with > 6 arguments.) Without frame pointers, GDB can only show backtraces if it gets > CFI information from a .debug_frame or .eh_frame ELF section. Thanks! Some quick initial review, without testing/reviewing script contents in detail: > Makefile | 4 ++ > tools/add-cfi.awk.i386 | 152 +++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 156 insertions(+) > create mode 100644 tools/add-cfi.awk.i386 > > diff --git a/Makefile b/Makefile > index 6559295..f7335aa 100644 > --- a/Makefile > +++ b/Makefile > @@ -118,7 +118,11 @@ $(foreach s,$(wildcard src/*/$(ARCH)*/*.s),$(eval $(call mkasmdep,$(s)))) > $(CC) $(CFLAGS_ALL_STATIC) -c -o $@ $(dir $<)$(shell cat $<) > > %.o: $(ARCH)/%.s > +ifeq ($(ARCH),i386) > + awk -f tools/add-cfi.awk.i386 $< | $(CC) $(CFLAGS_ALL_STATIC) -x assembler -c -o $@ - > +else > $(CC) $(CFLAGS_ALL_STATIC) -c -o $@ $< > +endif Here I'd like to see the arch passed to the script, and the script acting as a nop for archs it doesn't support, rather than a conditional in the makefile. Also if we're using -x assembler and input from stdin, configure will need to check for these and fall back to no cfi generation if they don't work. Possibly these could be combined by using a tools/aswrap.sh with the piping (or temp file, which wouldn't need special compiler-driver support) logic in it and the logic for calling a different awk script per arch or none at all, if you prefer to keep them as separate awk scripts. Rich