[PATCH] D59553: [LLD][ELF][DebugInfo] llvm-symbolizer shows incorrect source line info if --gc-sections used
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 9 01:57:33 PDT 2019
MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.
lld sets x86_64 image base to 0x200000.
A .debug_info associated with a non-discarded section has DW_AT_low_pc > 0x200000
A .debug_info associated with a discarded section has DW_AT_low_pc = 0. If its size is larger than 0x200000 => DW_AT_high_pc > image_base => the two debug info entries overlap => llvm-symbolizer locates a DIE that's not what the user expects => unexpected filename (`not_used.cpp`)
If you make `".rept 2000000; nop; .endr"` larger, you'll notice bfd linked executable has the same problem (its image base is 0x400000).
> InputSection.cpp:833
> Target->relocateOne(BufLoc, Type, SignExtend64<Bits>(Sym.getVA(Addend)));
I think the current handling in lld is quite good, no need to special case on `if (!Sym.getOutputSection())`.
After patching in this commit, `DW_AT_low_pc` becomes -1 but `llvm-symbolizer` is still puzzled.
% llvm-symbolizer -obj res.out 0x2010f0
__libc_csu_init
??:0:0 #########
The relevant code is in DWARFDebugAranges.cpp. I think the right fix is to improves the heuristics, rather than change lld. I can take a stab.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59553/new/
https://reviews.llvm.org/D59553
More information about the llvm-commits
mailing list