[PATCH] D91505: ELFAsmParser: Remove non-executable sections' line info/address ranges contribution for -g

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 15 10:32:11 PST 2020


MaskRay created this revision.
MaskRay added reviewers: debug-info, dblaikie.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
MaskRay requested review of this revision.

The new behavior seems reasonable and matches GNU as 2.36 https://sourceware.org/bugzilla/show_bug.cgi?id=26850


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91505

Files:
  llvm/lib/MC/MCParser/ELFAsmParser.cpp
  llvm/test/MC/ARM/dwarf-asm-multiple-sections.s


Index: llvm/test/MC/ARM/dwarf-asm-multiple-sections.s
===================================================================
--- llvm/test/MC/ARM/dwarf-asm-multiple-sections.s
+++ llvm/test/MC/ARM/dwarf-asm-multiple-sections.s
@@ -4,11 +4,11 @@
 // RUN: llvm-objdump -r %t | FileCheck --check-prefixes=RELOC,RELOC5 %s
 // RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 4 -fdebug-compilation-dir=/tmp
 // RUN: llvm-dwarfdump -v %t | FileCheck -check-prefixes=DWARF,DWARF34,DWARF4 %s
-// RUN: llvm-dwarfdump --debug-line %t | FileCheck -check-prefix DWARF-DL -check-prefix DWARF-DL-4 -DDWVER=4 -DDWFILE=1 %s
+// RUN: llvm-dwarfdump --debug-line %t | FileCheck --check-prefixes=DWARF-DL,DWARF-DL-3 -DDWVER=4 -DDWFILE=1 %s
 // RUN: llvm-objdump -r %t | FileCheck --check-prefixes=RELOC,RELOC34,RELOC4 %s
 // RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 3 -fdebug-compilation-dir=/tmp
 // RUN: llvm-dwarfdump -v %t | FileCheck --check-prefixes=DWARF,DWARF34,DWARF3 %s
-// RUN: llvm-dwarfdump --debug-line %t | FileCheck -check-prefix DWARF-DL -DDWVER=3 -DDWFILE=1 %s
+// RUN: llvm-dwarfdump --debug-line %t | FileCheck --check-prefixes=DWARF-DL,DWARF-DL-3 -DDWVER=3 -DDWFILE=1 %s
 // RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 2 2>&1 | FileCheck -check-prefix VERSION %s
 // RUN: not llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 1 2>&1 | FileCheck -check-prefix DWARF1 %s
 // RUN: not llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 6 2>&1 | FileCheck -check-prefix DWARF6 %s
@@ -20,6 +20,11 @@
 b:
   mov r1, r1
 
+// Non-executable sections do not contribute address ranges.
+  .section .rodata, "a"
+c:
+  mov r2, r2
+
 // DWARF: .debug_abbrev contents:
 // DWARF: Abbrev table for offset: 0x00000000
 // DWARF: [1] DW_TAG_compile_unit DW_CHILDREN_yes
@@ -47,11 +52,14 @@
 // DWARF: 0x{{[0-9a-f]+}}:   DW_TAG_label [2]
 // DWARF-NEXT: DW_AT_name [DW_FORM_string]     ("b")
 
+// DWARF-NOT: DW_TAG_label
+
 
 // DWARF: .debug_aranges contents:
 // DWARF-NEXT: Address Range Header: length = 0x00000024, format = DWARF32, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x04, seg_size = 0x00
 // DWARF-NEXT: [0x00000000, 0x00000004)
 // DWARF-NEXT: [0x00000000, 0x00000004)
+// DWARF-EMPTY:
 
 
 // DWARF-DL: .debug_line contents:
@@ -64,10 +72,11 @@
 // DWARF-DL-5-NEXT: 0x0000000000000004     17      0      0   0   0  is_stmt end_sequence
 // DWARF-DL-5-NEXT: 0x0000000000000000     21      0      0   0   0  is_stmt
 // DWARF-DL-5-NEXT: 0x0000000000000004     21      0      0   0   0  is_stmt end_sequence
-// DWARF-DL-4:      0x0000000000000000     17      0      1   0   0  is_stmt
-// DWARF-DL-4-NEXT: 0x0000000000000004     17      0      1   0   0  is_stmt end_sequence
-// DWARF-DL-4-NEXT: 0x0000000000000000     21      0      1   0   0  is_stmt
-// DWARF-DL-4-NEXT: 0x0000000000000004     21      0      1   0   0  is_stmt end_sequence
+// DWARF-DL-3:      0x0000000000000000     17      0      1   0   0  is_stmt
+// DWARF-DL-3-NEXT: 0x0000000000000004     17      0      1   0   0  is_stmt end_sequence
+// DWARF-DL-3-NEXT: 0x0000000000000000     21      0      1   0   0  is_stmt
+// DWARF-DL-3-NEXT: 0x0000000000000004     21      0      1   0   0  is_stmt end_sequence
+// DWARF-DL-EMPTY:
 
 
 // DWARF34:      .debug_ranges contents:
Index: llvm/lib/MC/MCParser/ELFAsmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -659,7 +659,8 @@
     Error(loc, "changed section entsize for " + SectionName +
                    ", expected: " + Twine(Section->getEntrySize()));
 
-  if (getContext().getGenDwarfForAssembly()) {
+  if (getContext().getGenDwarfForAssembly() &&
+      (Section->getFlags() & ELF::SHF_EXECINSTR)) {
     bool InsertResult = getContext().addGenDwarfSection(Section);
     if (InsertResult) {
       if (getContext().getDwarfVersion() <= 2)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91505.305378.patch
Type: text/x-patch
Size: 4075 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201115/29646fca/attachment.bin>


More information about the llvm-commits mailing list