[PATCH] D148386: [MCParser] Reject processor-specific section flags not known by the current target
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 14 16:06:22 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa4ad6a3b2db0: [MCParser] Reject processor-specific section flags not known by the current… (authored by MaskRay).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148386/new/
https://reviews.llvm.org/D148386
Files:
llvm/lib/MC/MCParser/ELFAsmParser.cpp
llvm/test/MC/ELF/section-flags-unknown.s
Index: llvm/test/MC/ELF/section-flags-unknown.s
===================================================================
--- /dev/null
+++ llvm/test/MC/ELF/section-flags-unknown.s
@@ -0,0 +1,14 @@
+## Some section flags are processor-specific. Reject them for other targets.
+# RUN: not llvm-mc -triple=x86_64 %s -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error:
+
+# CHECK: {{.*}}.s:[[# @LINE+1]]:34: error: unknown flag
+.section XCORE_SHF_CP_SECTION,"c", at progbits
+
+# CHECK: {{.*}}.s:[[# @LINE+1]]:34: error: unknown flag
+.section XCORE_SHF_CP_SECTION,"d", at progbits
+
+# CHECK: {{.*}}.s:[[# @LINE+1]]:27: error: unknown flag
+.section SHF_HEX_GPREL,"s", at progbits
+
+# CHECK: {{.*}}.s:[[# @LINE+1]]:30: error: unknown flag
+.section SHF_ARM_PURECODE,"y", at progbits
Index: llvm/lib/MC/MCParser/ELFAsmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -317,15 +317,23 @@
flags |= ELF::SHF_TLS;
break;
case 'c':
+ if (TT.getArch() != Triple::xcore)
+ return -1U;
flags |= ELF::XCORE_SHF_CP_SECTION;
break;
case 'd':
+ if (TT.getArch() != Triple::xcore)
+ return -1U;
flags |= ELF::XCORE_SHF_DP_SECTION;
break;
case 'y':
+ if (!(TT.isARM() || TT.isThumb()))
+ return -1U;
flags |= ELF::SHF_ARM_PURECODE;
break;
case 's':
+ if (TT.getArch() != Triple::hexagon)
+ return -1U;
flags |= ELF::SHF_HEX_GPREL;
break;
case 'G':
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148386.513785.patch
Type: text/x-patch
Size: 1583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230414/c574f575/attachment.bin>
More information about the llvm-commits
mailing list