[llvm] fac0622 - ELFAsmParser: Remove non-SHF_ALLOC or non-executable sections' line info/address ranges contribution for -g
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 16 20:02:31 PST 2020
Author: Fangrui Song
Date: 2020-11-16T20:02:25-08:00
New Revision: fac0622ae0a59659a5969a137a724008547be697
URL: https://github.com/llvm/llvm-project/commit/fac0622ae0a59659a5969a137a724008547be697
DIFF: https://github.com/llvm/llvm-project/commit/fac0622ae0a59659a5969a137a724008547be697.diff
LOG: ELFAsmParser: Remove non-SHF_ALLOC or non-executable sections' line info/address ranges contribution for -g
I filed the issue https://sourceware.org/bugzilla/show_bug.cgi?id=26850 ,
which was acknowledged and fixed in GNU binutils 2.36
This patch adds the similar behavior to MC.
Reviewed By: #debug-info, dblaikie
Differential Revision: https://reviews.llvm.org/D91505
Added:
Modified:
llvm/lib/MC/MCParser/ELFAsmParser.cpp
llvm/test/MC/ARM/dwarf-asm-multiple-sections.s
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index 440d3a38191c..78fee5ad87a3 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -659,7 +659,9 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
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)
diff --git a/llvm/test/MC/ARM/dwarf-asm-multiple-sections.s b/llvm/test/MC/ARM/dwarf-asm-multiple-sections.s
index abe75070eb95..72115cc02a33 100644
--- a/llvm/test/MC/ARM/dwarf-asm-multiple-sections.s
+++ b/llvm/test/MC/ARM/dwarf-asm-multiple-sections.s
@@ -20,6 +20,16 @@ a:
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
More information about the llvm-commits
mailing list