public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@bigpond.net.au>
To: Jan Beulich <JBeulich@novell.com>
Cc: binutils@sources.redhat.com
Subject: Re: gas rearranging elf file symbols
Date: Fri, 08 Oct 2004 05:53:00 -0000	[thread overview]
Message-ID: <20041008055319.GM12632@bubble.modra.org> (raw)
In-Reply-To: <s163bb63.036@emea1-mh.id2.novell.com>

On Wed, Oct 06, 2004 at 10:31:30AM +0200, Jan Beulich wrote:
> After enabling elf_find_function to actually report a filename if any
> can be found, it became immediately obvious that gas prevents this from
> being fully functional. This is because gas (a) emits all the file
> symbols (resulting from # <line> "<filename>", .file, or .appfile) in a
> block and (b) inverts the sequence in which they were encountered. With
> this, associating a local symbol with its (pseudo-)source file name is
> impossible.
> 
> Is anyone able to explain why this works the way it does currently?

I'm not sure why the file symbols are reversed, but it looks to be
intentional.  See config/obj-elf.c:elf_file_symbol.  This has the effect
of putting the sym for the main source file last, which then is the one
that always matches in elf_find_function.  As you say, that might not be
the correct file.  You can't do better for globals of course, since
global symbols are placed after local symbols, losing any association
you might infer from the symbol ordering.

While looking at this, I noticed that all file syms starting with ".."
were being dropped.

	* syms.c (bfd_is_local_label): Return false for file symbols.

Index: bfd/syms.c
===================================================================
RCS file: /cvs/src/src/bfd/syms.c,v
retrieving revision 1.37
diff -u -p -r1.37 syms.c
--- bfd/syms.c	5 Oct 2004 11:12:56 -0000	1.37
+++ bfd/syms.c	8 Oct 2004 05:52:23 -0000
@@ -355,7 +355,7 @@ bfd_is_local_label (bfd *abfd, asymbol *
   /* The BSF_SECTION_SYM check is needed for IA-64, where every label that
      starts with '.' is local.  This would accidentally catch section names
      if we didn't reject them here.  */
-  if ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_SECTION_SYM)) != 0)
+  if ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_FILE | BSF_SECTION_SYM)) != 0)
     return FALSE;
   if (sym->name == NULL)
     return FALSE;

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

  reply	other threads:[~2004-10-08  5:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-06  8:31 Jan Beulich
2004-10-08  5:53 ` Alan Modra [this message]
2004-10-08  6:29   ` Alan Modra
2004-10-20  2:29     ` Alan Modra
2004-10-08  7:18 Jan Beulich
2004-10-20  6:41 Jan Beulich
2004-10-20 23:48 ` Alan Modra
2004-11-10  3:24   ` Alan Modra

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=20041008055319.GM12632@bubble.modra.org \
    --to=amodra@bigpond.net.au \
    --cc=JBeulich@novell.com \
    --cc=binutils@sources.redhat.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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).