This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gas rearranging elf file symbols


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]