mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Alex Dowad <alexinbeijing@gmail.com>
To: musl@lists.openwall.com
Subject: Re: [PATCH v3] Build process uses script to add CFI directives to x86 asm
Date: Fri, 15 May 2015 19:31:32 +0200	[thread overview]
Message-ID: <20150515173132.GA18390@alex-ThinkPad-L530> (raw)

Dear Szabolcs Nagy (and other interested parties),

> you can use
> 
>  .file "foo.s"

Thanks for the idea! Unfortunately, implementing it has proved very troublesome.

The GAS documentation does refer to ".file <source file>". There's just a tiny little
problem with it -- it doesn't actually work for the desired purpose. It does
register <source file> as a dependency, so it will be included in the dependency
file which is written out if you invoke GAS with the --MD option. But that's about it.

If you look at asm generated by GCC, it includes a ".file <source file>" line at the
top, but it *also* includes a ".file <number> <source file>" line. Which actually
sets the "source file" in the debugging info! (Yay!) Subsequent ".loc" directives
use the source file number when identifying source lines.

So we just use ".file <number> <source file>" and everybody is happy, right? Yes?
Good? Right?

Wrong.

Allow me to quote gas/dwarf2dbg.c:596-598 from the binutils repo:

  /* A .file directive implies compiler generated debug information is
     being supplied.  Turn off gas generated debug info.  */
  debug_type = DEBUG_NONE;

Snap.

Normally, GAS automatically generates debug info on source line numbers, and a few
other basic things. As soon as you use a ".file <number> <source file>" directive,
all that automatic debugging output is shut off, and you have to use explicit
assembler directives for *everything*.

I guess this makes sense, because if the "source file" is a completely
different file from the input asm file, the automatically generated line number
info will be completely wrong.

What a pain! Well, I guess I'll just have to use my own, explicit ".loc" directives.

> i think passing down the build command that way is not ok

It does seem like a hack -- but I'm not sure what a better way to do it is.

(I'm not a "real" shell programmer, if you hadn't noticed yet. I just fake it using
some combination of Stack Overflow and manpages.)

> i think
>
> pushl $123
> push $123
>
> are different

'push %eax' and 'pushl %eax' assemble to exactly the same machine code. Likewise,
'push $1' and 'pushl $1' assemble just the same.

Interestingly, 'pushl %ax' assembles to 'push %eax', 'push %ax' is just 'push %ax'.

> set LC_ALL=C because you depend on collation order
> in the awk script

Please see if I did this right in the v4.

> add new lines at the end

Done.

Thanks for other enhancements to the awk script (I will credit you in the commit log
message).

Kind regards, AD


             reply	other threads:[~2015-05-15 17:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-15 17:31 Alex Dowad [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-05-13 17:54 Alex Dowad
2015-05-13 19:22 ` Szabolcs Nagy
2015-05-14  2:57   ` Rich Felker
2015-05-14 10:25     ` Szabolcs Nagy

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=20150515173132.GA18390@alex-ThinkPad-L530 \
    --to=alexinbeijing@gmail.com \
    --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).