[llvm-bugs] [Bug 41124] New: llvm-symbolizer shows incorrect source line info if --gc-sections used

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 18 04:59:10 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41124

            Bug ID: 41124
           Summary: llvm-symbolizer shows incorrect source line info if
                    --gc-sections used
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: llvm-symbolizer
          Assignee: unassignedbugs at nondot.org
          Reporter: a.v.lapshin at mail.ru
                CC: llvm-bugs at lists.llvm.org

llvm-symbolizer shows incorrect source line info if --gc-sections used:

$ cat not_used.cpp
void foo () {
    __asm__(".rept 3300000; nop; .endr");
}
$ cat main.cpp
int main(void) {
   return 0;
}
$ clang++ -gdwarf-5 -O not_used.cpp -c
$ clang++ -gdwarf-5 -O main.cpp -c
$ clang++ -gdwarf-5 -O not_used.o main.o -fuse-ld=lld -Wl,--gc-sections -o
res.out
$ llvm-symbolizer -obj=res.out 0x2010f0
main
/home/avl/bugs/gc_debuginfo/not_used.cpp:2:5

Note: llvm-symbolizer reported wrong source file - not_used.cpp !!!

The reason for the failure is that linker while removing not used
sections(-Wl,--gc-sections) keeps debug info for not used code :

llvm-dwarfdump -a res.out

0x0000000c: DW_TAG_compile_unit
              DW_AT_producer    ("clang version 9.0.0) 
              DW_AT_language    (DW_LANG_C_plus_plus)
              DW_AT_name        ("not_used.cpp")
              DW_AT_str_offsets_base    (0x00000008)
              DW_AT_stmt_list   (0x00000000)
              DW_AT_addr_base   (0x00000008)
              DW_AT_low_pc      (0x0000000000000000)   <<<<<<<<<<<<<<<<<<<<<<
              DW_AT_high_pc     (0x0000000000325aa1)   <<<<<<<<<<<<<<<<<<<<<<

0x0000003c: DW_TAG_compile_unit
              DW_AT_producer    ("clang version 9.0.0)
              DW_AT_language    (DW_LANG_C_plus_plus)
              DW_AT_name        ("main.cpp")
              DW_AT_str_offsets_base    (0x00000024)
              DW_AT_stmt_list   (0x00000075)
              DW_AT_addr_base   (0x00000018)
              DW_AT_low_pc      (0x00000000002010f0)   <<<<<<<<<<<<<<<<<<<<<<
              DW_AT_high_pc     (0x00000000002010f3)   <<<<<<<<<<<<<<<<<<<<<<

Note compilation units from debug info have overlapping address ranges. 

I have a fix for that problem.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190318/88d39d5f/attachment.html>


More information about the llvm-bugs mailing list