[PATCH] D95927: DebugInfo/Symbolize: Retrieve filename from the preceding STT_FILE for .symtab symbolization

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 2 22:40:34 PST 2021


MaskRay created this revision.
MaskRay added reviewers: dblaikie, jhenderson.
Herald added subscribers: hiraditya, emaste.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95927

Files:
  llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
  llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h
  llvm/test/DebugInfo/Symbolize/ELF/symtab-file.yaml
  llvm/test/DebugInfo/Symbolize/ELF/symtab-notype.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95927.321009.patch
Type: text/x-patch
Size: 10861 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210203/f48b8f82/attachment.bin>


More information about the llvm-commits mailing list