1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00
llvm-mirror/test/DebugInfo/Symbolize/ELF/symtab-ignored.s
Fangrui Song 16779dce78 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
2021-02-10 09:47:10 -08:00

21 lines
432 B
ArmAsm

# REQUIRES: x86-registered-target
## Ignore STT_SECTION and STT_TLS symbols for .symtab symbolization.
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
# RUN: llvm-symbolizer --obj=%t 0 | FileCheck %s
# CHECK: b
# CHECK-NEXT: 1.c:0:0
# CHECK-EMPTY:
.file "1.c"
.section a,"a",@progbits
b:
.reloc ., R_X86_64_NONE, a
.section c,"a",@progbits
.reloc ., R_X86_64_NONE, c
.section .tbss,"awT",@nobits
.globl tls
tls: