[all-commits] [llvm/llvm-project] 04a2e1: DebugInfo/Symbolize: Retrieve filename from the pr...

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed Feb 10 09:47:35 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 04a2e12612f49e65a7dc14fa45f11f0632d427f2
      https://github.com/llvm/llvm-project/commit/04a2e12612f49e65a7dc14fa45f11f0632d427f2
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-02-10 (Wed, 10 Feb 2021)

  Changed paths:
    M llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
    M llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h
    A llvm/test/DebugInfo/Symbolize/ELF/symtab-file-conflict.s
    M llvm/test/DebugInfo/Symbolize/ELF/symtab-file.s
    A llvm/test/DebugInfo/Symbolize/ELF/symtab-file2.yaml
    M llvm/test/DebugInfo/Symbolize/ELF/symtab-ignored.s
    M llvm/test/DebugInfo/Symbolize/ELF/symtab-notype.s

  Log Message:
  -----------
  DebugInfo/Symbolize: Retrieve filename from the preceding STT_FILE for .symtab symbolization

The ELF spec says:

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

For a local symbol, the preceding STT_FILE symbol is almost always in the same
file[1]. GNU addr2line uses this heuristic to retrieve the filename associated
with a local symbol (e.g. internal linkage functions in C/C++).

GNU addr2line can assign STT_FILE filename to a non-local symbol, too, but the trick
only works if no regular symbol precede STT_FILE. This patch does not implement this corner case
(not useful for most executables which have more than one files).

In case of filename mismatch between .debug_line & .symtab, arbitrarily make .debug_line win.

[1]: LLD does not synthesize STT_FILE symbols
(https://bugs.llvm.org/show_bug.cgi?id=48023 see also
https://sourceware.org/bugzilla/show_bug.cgi?id=26822).  An assembly file
without `.file` directives can cause mis-attribution. This is an edge case.

Differential Revision: https://reviews.llvm.org/D95927




More information about the All-commits mailing list