This is the mail archive of the binutils@sourceware.org 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: Patch: Fix elf_find_function () on a corner case


On Wed, Nov 23, 2005 at 01:15:16AM +0800, Jie Zhang wrote:
> files. The best thing it can do is not output misleading (wrong)
> source file information.

I agree with this.  However, I believe the reason for convoluted logic
here is that it was written to handle the case where we have multiple
file symbols in one source.  This used to happen with 
    # <number> <filename>
lines inserted into assembly source until I changed ELF flavours of gas
to only emit a file symbol for the first such line.  Typically, you
would see these lines if using the C preprocessor on some generated
assembler.  Here's an example of such a file from glibc:

File: access.o

Symbol table '.symtab' contains 18 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000000     0 FILE    LOCAL  DEFAULT  ABS <stdin>
     2: 00000000     0 FILE    LOCAL  DEFAULT  ABS /usr/src/packages/BUILD/kernel-headers/asm/unistd.h
     3: 00000000     0 FILE    LOCAL  DEFAULT  ABS /usr/src/packages/BUILD/kernel-headers/asm-ppc/unistd.h
     4: 00000000     0 FILE    LOCAL  DEFAULT  ABS /usr/src/packages/BUILD/kernel-headers/asm/unistd.h
     5: 00000000     0 FILE    LOCAL  DEFAULT  ABS <stdin>
     6: 00000000     0 FILE    LOCAL  DEFAULT  ABS <command line>
     7: 00000000     0 FILE    LOCAL  DEFAULT  ABS /usr/src/packages/BUILD/glibc-2.3/cc/config.h
     8: 00000000     0 FILE    LOCAL  DEFAULT  ABS <command line>
     9: 00000000     0 FILE    LOCAL  DEFAULT  ABS <built-in>
    10: 00000000     0 FILE    LOCAL  DEFAULT  ABS <stdin>
    11: 00000000     0 SECTION LOCAL  DEFAULT    1
    12: 00000000     0 SECTION LOCAL  DEFAULT    3
    13: 00000000     0 SECTION LOCAL  DEFAULT    4
    14: 00000000     0 SECTION LOCAL  DEFAULT    5
    15: 00000000    16 FUNC    GLOBAL DEFAULT    1 __access
    16: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __syscall_error
    17: 00000000    16 FUNC    WEAK   DEFAULT    1 access

This was from source piped to gcc, so there wasn't a real file to
report.  Instead gcc emitted a <stdin> file symbol.  Note that the file
symbols are in reverse order, which is why it generally works to
continue consuming file symbols in elf_find_function.  The last one
would be the main source file name.

You might think that because gas no longer emits more than one symbol
for # <number> <file> lines that we could dispense with this logic, but
that would be wrong on two counts.  Firstly, you can still get multiple
file symbols if multiple .file pseudo ops are given, and secondly, you
might be using gdb/objdump/whatever on older object files like the one
I show above.

So I'm rejecting the patch as it is.  You might be able to do something
reasonable with ld -r output by noticing that section symbols precede
file symbols for ld -r.

-- 
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]