[PATCH] D59553: llvm-symbolizer shows incorrect source line info if --gc-sections used
Alexey Lapshin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 19 13:34:56 PDT 2019
avl added a comment.
> What do other linkers (gold and gnu binutils, for instance) do in this case?
they(gnu binutils ld/gold) behave the same way as lld before this patch :
gcc -g main.cpp -c
gcc -g not_used.cpp -c
gcc -g not_used.o main.o -Wl,--gc-sections -o gcc.out
addr2line -e gcc.out 0x5fa
/home/avl/bugs/gc_debuginfo/not_used.cpp:2 <<<<<< source file and line shown incorrectly
gcc -g not_used.o main.o -o gcc.out
addr2line -e gcc.out 0x3260a1
/home/avl/bugs/gc_debuginfo/main.cpp:1
>> llvm-symbolizer should be adjusted to cope with that
It looks like llvm-symbolizer could not handle that.
Probably there could be used some heuristic, but generally
it does not have information which compile unit is correct :
0x0000000b: DW_TAG_compile_unit
DW_AT_producer ("GNU C++14 7.3.0 -mtune=generic -march=x86-6
4 -g -fstack-protector-strong")
DW_AT_language (DW_LANG_C_plus_plus)
DW_AT_name ("not_used.cpp")
DW_AT_comp_dir ("/home/avl/bugs/gc_debuginfo")
DW_AT_low_pc (0x0000000000000000)
DW_AT_high_pc (0x0000000000325aa7)
DW_AT_stmt_list (0x00000000)
0x00000056: DW_TAG_compile_unit
DW_AT_producer ("GNU C++14 7.3.0 -mtune=generic -march=x86-64 -g -fstack-protector-strong")
DW_AT_language (DW_LANG_C_plus_plus)
DW_AT_name ("main.cpp")
DW_AT_comp_dir ("/home/avl/bugs/gc_debuginfo")
DW_AT_low_pc (0x00000000000005fa)
DW_AT_high_pc (0x0000000000000605)
DW_AT_stmt_list (0x00000045)
What could be taken into account to select "main.cpp" instead of "not_used.cpp" for 0x5fa ?
At the same time linker has relocations which points to deleted section.
So linker could use this information to set not matching address range for these compile units :
0x0000000b: DW_TAG_compile_unit
DW_AT_producer ("GNU C++14 7.3.0 -mtune=generic -march=x86-6
4 -g -fstack-protector-strong")
DW_AT_language (DW_LANG_C_plus_plus)
DW_AT_name ("not_used.cpp")
DW_AT_comp_dir ("/home/avl/bugs/gc_debuginfo")
DW_AT_low_pc (0x0000000000203019)
DW_AT_high_pc (0x0000000000528ac0)
DW_AT_stmt_list (0x00000000)
0x00000056: DW_TAG_compile_unit
DW_AT_producer ("GNU C++14 7.3.0 -mtune=generic -march=x86-64 -g -fstack-protector-strong")
DW_AT_language (DW_LANG_C_plus_plus)
DW_AT_name ("main.cpp")
DW_AT_comp_dir ("/home/avl/bugs/gc_debuginfo")
DW_AT_low_pc (0x00000000002010e7)
DW_AT_high_pc (0x00000000002010f2)
DW_AT_stmt_list (0x00000045)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59553/new/
https://reviews.llvm.org/D59553
More information about the llvm-commits
mailing list