Date: Mon, 18 May 2015 15:34:40 +0200 From: Szabolcs Nagy <nsz@...t70.net> To: musl@...ts.openwall.com Subject: Re: [PATCH] Build process uses script to add CFI directives to x86 asm * Alex Dowad <alexinbeijing@...il.com> [2015-05-16 15:54:31 +0200]: > > configure script now checks whether debugging is enabled, whether the assembler > understands CFI directives, whether it understands '-x assembler', and whether > there the AWK script is present for the current arch. > > aswrap.sh is gone -- the problem is that the arguments it wants (and the order it > wants them in) is different from $(CC). So it's hard to use an AS_CMD variable > as suggested by RF to run whichever command is appropriate. > > Suggestions from shell/Makefile scripting wizards on how to do this better > are appreciated! > it is possible to parse the options but not trivial may be have the arguments in an order that's good for the wrapper > The processed asm now contains .file and .loc directives, so when you debug it in > GDB, it will show you the original source file, and highlight the correct lines. > nice > I haven't tested with busybox awk yet, just with GNU awk. If there are no further > issues with the code, I will do that next. > i see one issue: \s, \w may not be supported (eg mawk does not have them nor [[:space:]] char classes) > > Makefile | 10 ++- > configure | 13 ++++ > tools/add-cfi.awk.i386 | 207 +++++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 229 insertions(+), 1 deletion(-) > create mode 100644 tools/add-cfi.awk.i386 > > diff --git a/Makefile b/Makefile > index 6559295..6f17cc7 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 ($(ADD_CFI),yes) > + LC_ALL=C awk -f tools/add-cfi.awk.$(ARCH) $< | $(CC) $(CFLAGS_ALL_STATIC) -x assembler -c -o $@ - > +else > $(CC) $(CFLAGS_ALL_STATIC) -c -o $@ $< > +endif > this may work, with a reasonably simple aswrap script: %.o: $(ARCH)/%.s $(ASWRAP) $(ARCH) $< $(CC) $(CFLAGS_ALL_STATIC) -c -o $@ i don't know which approach is less ugly. the %.sub rules should be handled too.. > diff --git a/configure b/configure > index 143dc92..72349a2 100755 > --- a/configure > +++ b/configure > @@ -317,6 +317,18 @@ tryflag CFLAGS_MEMOPS -fno-tree-loop-distribute-patterns > test "$debug" = yes && CFLAGS_AUTO=-g > > # > +# Preprocess asm files to add extra debugging information if debug is > +# enabled, our assembler supports the needed directives, and the > +# preprocessing script has been written for our architecture. > +# > +if (test "$debug" = yes) && > + (test -f "tools/add-cfi.awk.$ARCH") && > + (echo ".cfi_startproc\n.cfi_endproc" | $CC -x assembler -c -o /dev/null -) > +then > + ADD_CFI=yes > +fi > + else ADD_CFI=no (otherwise an ADD_CFI env var may influence configure behaviour) > +# > # Possibly add a -O option to CFLAGS and select modules to optimize with > # -O3 based on the status of --enable-optimize and provided CFLAGS. > # > @@ -570,6 +582,7 @@ LDFLAGS = $LDFLAGS_AUTO $LDFLAGS > CROSS_COMPILE = $CROSS_COMPILE > LIBCC = $LIBCC > OPTIMIZE_GLOBS = $OPTIMIZE_GLOBS > +ADD_CFI = $ADD_CFI > EOF > test "x$static" = xno && echo "STATIC_LIBS =" > test "x$shared" = xno && echo "SHARED_LIBS ="
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.