This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB 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 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


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