[all-commits] [llvm/llvm-project] b169e7: [ELF] Improve undefined symbol message w/ DW_TAG_v...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Fri Nov 3 13:53:49 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: b169e7feddce44dd48cf76018860f2168e1e8d0f
https://github.com/llvm/llvm-project/commit/b169e7feddce44dd48cf76018860f2168e1e8d0f
Author: Fangrui Song <i at maskray.me>
Date: 2023-11-03 (Fri, 03 Nov 2023)
Changed paths:
M lld/ELF/Relocations.cpp
M lld/test/ELF/Inputs/undef-debug.s
A lld/test/ELF/Inputs/undef-debug2.s
M lld/test/ELF/undef.s
Log Message:
-----------
[ELF] Improve undefined symbol message w/ DW_TAG_variable of the enclosing symbol but w/o line number information (#70854)
The undefined symbol message suggests the source line when line number
information is available (see https://reviews.llvm.org/D31481).
When the undefined symbol is from a global variable, we won't get the
line information.
```
extern int undef;
namespace ns {
int *var[] = {
&undef
};
// DW_TAG_variable(DW_AT_decl_file/DW_AT_decl_line) is available while
// line number information is unavailable.
}
ld.lld: error: undefined symbol: undef
>>> referenced by undef-debug2.cc
>>> undef-debug2.o:(ns::var)
```
This patch utilizes `getEnclosingSymbol` to locate `var` and find
DW_TAG_variable for `var`:
```
ld.lld: error: undefined symbol: undef
>>> referenced by undef-debug2.cc:3 (/tmp/c/undef-debug2.cc:3)
>>> undef-debug2.o:(ns::var)
```
More information about the All-commits
mailing list