From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: [PATCH] Build process uses script to add CFI directives to x86 asm
Date: Mon, 18 May 2015 15:34:40 +0200 [thread overview]
Message-ID: <20150518133440.GE11258@port70.net> (raw)
In-Reply-To: <1431784471-24517-1-git-send-email-alexinbeijing@gmail.com>
* Alex Dowad <alexinbeijing@gmail.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 ="
next prev parent reply other threads:[~2015-05-18 13:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-16 13:54 Alex Dowad
2015-05-18 13:34 ` Szabolcs Nagy [this message]
2015-05-18 15:52 ` Rich Felker
2015-05-19 9:31 Alex Dowad
2015-05-19 11:16 ` u-wsnj
2015-05-19 11:43 ` Szabolcs Nagy
2015-05-19 16:22 Alex Dowad
2015-05-20 17:08 Alex Dowad
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150518133440.GE11258@port70.net \
--to=nsz@port70.net \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).