
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
28 lines
509 B
ArmAsm
28 lines
509 B
ArmAsm
# REQUIRES: x86-registered-target
|
|
## When locating a local symbol, we can obtain the filename according to the
|
|
## preceding STT_FILE symbol.
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
|
|
# RUN: llvm-symbolizer --obj=%t 0 1 2 | FileCheck %s
|
|
|
|
# CHECK: local1
|
|
# CHECK-NEXT: 1.c:0:0
|
|
# CHECK-EMPTY:
|
|
# CHECK-NEXT: local2
|
|
# CHECK-NEXT: 2.c:0:0
|
|
# CHECK-EMPTY:
|
|
# CHECK-NEXT: local3
|
|
# CHECK-NEXT: 3.c:0:0
|
|
# CHECK-EMPTY:
|
|
|
|
.file "1.c"
|
|
local1:
|
|
nop
|
|
|
|
.file "2.c"
|
|
local2:
|
|
nop
|
|
|
|
.file "3.c"
|
|
local3:
|
|
nop
|