[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 20:02:35 PST 2020


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfac0622ae0a5: ELFAsmParser: Remove non-SHF_ALLOC or non-executable sections' lineā€¦ (authored by MaskRay).

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
@@ -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
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.305644.patch
Type: text/x-patch
Size: 1300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201117/2fd02398/attachment.bin>


More information about the llvm-commits mailing list