This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: gas rearranging elf file symbols
- From: "Jan Beulich" <JBeulich at novell dot com>
- To: <amodra at bigpond dot net dot au>
- Cc: <binutils at sources dot redhat dot com>,<gdb at sources dot redhat dot com>
- Date: Wed, 20 Oct 2004 08:42:12 +0200
- Subject: Re: gas rearranging elf file symbols
This doesn't look correct to me. What I believe needs to be cut down is
the number of symbols resulting from (from the assembler's perspective)
consecutive # <line> <file> preprocessor-generated constructs (because
all of them except the last can only be meaningless except for
dependency determination). Explicit .file/.appfile directives should, in
my opinion, always be honoured. If you really want just a single file
symbol, then I'd still see a need to honor the first (or last)
.file/.appfile in preference over any preprocessor-generated ones. Jan
>>> Alan Modra <amodra@bigpond.net.au> 20.10.04 04:29:03 >>>
On Fri, Oct 08, 2004 at 03:59:29PM +0930, Alan Modra wrote:
> STT_FILE
> Conventionally, the symbol's name gives the name of the source
file
> associated with the object file. A file symbol has STB_LOCAL
> binding, its section index is SHN_ABS, and it precedes the other
> STB_LOCAL symbols for the file, if it is present.
>
> From that wording you could also infer that there should only be one
> file symbol, that of the main source file.
I'm inclined to implement this. gcc/gas seem to only emit one file
symbol for C source, so I think it reasonable to do the same for
assembly. The difference in number of symbols can be quite
significant,
for example glibc/io/write.o on powerpc-linux currently has 38 file
symbols (in a total of 49 symbols).
* config/obj-elf.c (elf_file_symbol): Only emit one file
symbol.
Any objections from gdb folks?
Index: gas/config/obj-elf.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-elf.c,v
retrieving revision 1.86
diff -u -p -r1.86 obj-elf.c
--- gas/config/obj-elf.c 8 Sep 2004 20:52:48 -0000 1.86
+++ gas/config/obj-elf.c 20 Oct 2004 02:23:13 -0000
@@ -238,19 +238,24 @@ elf_sec_sym_ok_for_reloc (asection *sec)
void
elf_file_symbol (const char *s)
{
- symbolS *sym;
+ if (symbol_rootP == NULL
+ || symbol_rootP->bsym == NULL
+ || (symbol_rootP->bsym->flags & BSF_FILE) == 0)
+ {
+ symbolS *sym;
- sym = symbol_new (s, absolute_section, 0, NULL);
- symbol_set_frag (sym, &zero_address_frag);
- symbol_get_bfdsym (sym)->flags |= BSF_FILE;
+ sym = symbol_new (s, absolute_section, 0, NULL);
+ symbol_set_frag (sym, &zero_address_frag);
+ symbol_get_bfdsym (sym)->flags |= BSF_FILE;
- if (symbol_rootP != sym)
- {
- symbol_remove (sym, &symbol_rootP, &symbol_lastP);
- symbol_insert (sym, symbol_rootP, &symbol_rootP,
&symbol_lastP);
+ if (symbol_rootP != sym)
+ {
+ symbol_remove (sym, &symbol_rootP, &symbol_lastP);
+ symbol_insert (sym, symbol_rootP, &symbol_rootP,
&symbol_lastP);
#ifdef DEBUG
- verify_symbol_chain (symbol_rootP, symbol_lastP);
+ verify_symbol_chain (symbol_rootP, symbol_lastP);
#endif
+ }
}
#ifdef NEED_ECOFF_DEBUG
--
Alan Modra
IBM OzLabs - Linux Technology Centre