[PATCH] D73999: [MC][ELF] Error changed sh_type, sh_flags or sh_entsize
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 19 20:49:26 PST 2020
MaskRay updated this revision to Diff 245572.
MaskRay retitled this revision from "[MC][ELF] Warn changed section type or flags" to "[MC][ELF] Error changed sh_type, sh_flags or sh_entsize".
MaskRay edited the summary of this revision.
MaskRay removed a subscriber: psmith.
MaskRay added a comment.
Change warnings to errors
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73999/new/
https://reviews.llvm.org/D73999
Files:
llvm/lib/MC/MCParser/ELFAsmParser.cpp
llvm/test/MC/ELF/exclude-debug-dwo.s
llvm/test/MC/ELF/section-flags-changed.s
llvm/test/MC/ELF/section-type-changed.s
Index: llvm/test/MC/ELF/section-type-changed.s
===================================================================
--- /dev/null
+++ llvm/test/MC/ELF/section-type-changed.s
@@ -0,0 +1,11 @@
+# RUN: not llvm-mc -filetype=obj -triple=x86_64 %s -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error:
+
+.section .foo,"a", at progbits
+
+# CHECK: {{.*}}.s:[[# @LINE+1]]:1: error: changed section type for .foo
+.section .foo,"a", at init_array
+
+# CHECK: {{.*}}.s:[[# @LINE+1]]:1: error: changed section type for .foo
+.pushsection .foo,"a", at nobits
+
+.pushsection .foo,"a", at progbits
Index: llvm/test/MC/ELF/section-flags-changed.s
===================================================================
--- /dev/null
+++ llvm/test/MC/ELF/section-flags-changed.s
@@ -0,0 +1,12 @@
+# RUN: not llvm-mc -filetype=obj -triple=x86_64 %s -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error:
+
+foo:
+.section .foo,"ax", at progbits
+
+# CHECK: {{.*}}.s:[[# @LINE+1]]:1: error: changed section flags for .foo
+.section .foo,"awx", at progbits
+
+# CHECK: {{.*}}.s:[[# @LINE+1]]:1: error: changed section flags for .foo
+.pushsection .foo,"a", at progbits
+
+.pushsection .foo,"ax", at progbits
Index: llvm/test/MC/ELF/exclude-debug-dwo.s
===================================================================
--- llvm/test/MC/ELF/exclude-debug-dwo.s
+++ llvm/test/MC/ELF/exclude-debug-dwo.s
@@ -10,23 +10,23 @@
# CHECK: .debug_loc.dwo {{.*}} E
# CHECK: .debug_str_offsets.dwo {{.*}} E
-.section .debug_info.dwo
+.section .debug_info.dwo,"e"
nop
-.section .debug_types.dwo
+.section .debug_types.dwo,"e"
nop
-.section .debug_abbrev.dwo
+.section .debug_abbrev.dwo,"e"
nop
-.section .debug_str.dwo
+.section .debug_str.dwo,"MSe", at progbits,1
nop
-.section .debug_line.dwo
+.section .debug_line.dwo,"e"
nop
-.section .debug_loc.dwo
+.section .debug_loc.dwo,"e"
nop
-.section .debug_str_offsets.dwo
+.section .debug_str_offsets.dwo,"e"
nop
Index: llvm/lib/MC/MCParser/ELFAsmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -634,9 +634,15 @@
}
}
- MCSection *ELFSection = getContext().getELFSection(
+ MCSectionELF *ELFSection = getContext().getELFSection(
SectionName, Type, Flags, Size, GroupName, UniqueID, LinkedToSym);
getStreamer().SwitchSection(ELFSection, Subsection);
+ if (ELFSection->getType() != Type)
+ Error(loc, "changed section type for " + SectionName);
+ if (ELFSection->getFlags() != Flags)
+ Error(loc, "changed section flags for " + SectionName);
+ if (ELFSection->getEntrySize() != Size)
+ Error(loc, "changed section entsize for " + SectionName);
if (getContext().getGenDwarfForAssembly()) {
bool InsertResult = getContext().addGenDwarfSection(ELFSection);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73999.245572.patch
Type: text/x-patch
Size: 2847 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200220/5d106d4e/attachment.bin>
More information about the llvm-commits
mailing list