From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10099 invoked by alias); 20 Oct 2004 06:41:54 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 10087 invoked from network); 20 Oct 2004 06:41:52 -0000 Received: from unknown (HELO emea1-mh.id2.novell.com) (195.33.99.129) by sourceware.org with SMTP; 20 Oct 2004 06:41:52 -0000 Received: from EMEA1-MTA by emea1-mh.id2.novell.com with Novell_GroupWise; Wed, 20 Oct 2004 07:41:51 +0200 Message-Id: Date: Wed, 20 Oct 2004 06:41:00 -0000 From: "Jan Beulich" To: Cc: , Subject: Re: gas rearranging elf file symbols Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-SW-Source: 2004-10/txt/msg00322.txt.bz2 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 # 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 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