[PATCH] D91505: ELFAsmParser: Remove non-SHF_ALLOC or non-executable sections' line info/address ranges contribution for -g
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 16 16:41:42 PST 2020
MaskRay updated this revision to Diff 305625.
MaskRay marked an inline comment as done.
MaskRay retitled this revision from "ELFAsmParser: Remove non-executable sections' line info/address ranges contribution for -g" to "ELFAsmParser: Remove non-SHF_ALLOC or non-executable sections' line info/address ranges contribution for -g".
MaskRay edited the summary of this revision.
MaskRay added a comment.
> Does this LLVM patch include the same generalization discussed in the GNU Binutils bug ( https://sourceware.org/bugzilla/show_bug.cgi?id=26850#c2 ) regarding non-loaded sections?
Thanks for spotting this! (I struggled whether SHF_EXECINSTR should imply SHF_ALLOC)
Since neither GNU as nor MC disallows "x", I assume it is meaningful and check the SHF_ALLOC flag.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91505/new/
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,16 @@
b:
mov r1, r1
+// Non-executable sections do not contribute address ranges.
+ .section .rodata, "a"
+c:
+ mov r2, r2
+
+// Non-SHF_ALLOC sections do not contribute address ranges.
+ .section nonalloc, "x"
+d:
+ mov r3, r3
+
// DWARF: .debug_abbrev contents:
// DWARF: Abbrev table for offset: 0x00000000
// DWARF: [1] DW_TAG_compile_unit DW_CHILDREN_yes
@@ -47,11 +57,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 +77,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,9 @@
Error(loc, "changed section entsize for " + SectionName +
", expected: " + Twine(Section->getEntrySize()));
- if (getContext().getGenDwarfForAssembly()) {
+ if (getContext().getGenDwarfForAssembly() &&
+ (Section->getFlags() & ELF::SHF_ALLOC) &&
+ (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.305625.patch
Type: text/x-patch
Size: 4231 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201117/b391756d/attachment-0001.bin>
More information about the llvm-commits
mailing list