summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2017-03-10 08:22:13 +0000
committerSimon Atanasyan <simon@atanasyan.com>2017-03-10 08:22:13 +0000
commit2953224d644236783d4f2487b9777803cc5e7111 (patch)
treedd1f56d630d0105c311ed91ad8a45afbfc401dc2 /llvm/lib
parent0c93ceb5d85b6fdfd96f8fa08b08eb11e8c4d921 (diff)
downloadbcm5719-llvm-2953224d644236783d4f2487b9777803cc5e7111.tar.gz
bcm5719-llvm-2953224d644236783d4f2487b9777803cc5e7111.zip
[MC] Accept a numeric value as an ELF section header's type
GAS supports specification of section header's type using a numeric value [1]. This patch brings the same functionality to LLVM. That allows to setup some target-specific section types belong to the SHT_LOPROC - SHT_HIPROC range. If we attempt to print unknown section type, MCSectionELF class shows an error message. It's better than print sole '@' sign without any section type name. In case of MIPS, example of such section's type is SHT_MIPS_DWARF. Without the patch we will have to implement some workarounds in probably not-MIPS-specific part of code base to convert SHT_MIPS_DWARF to the @progbits while printing assembly and to assign SHT_MIPS_DWARF for @progbits sections named .debug_* if we encounter such section in an input assembly. [1] https://sourceware.org/binutils/docs/as/Section.html Differential Revision: https://reviews.llvm.org/D29719 llvm-svn: 297446
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/MCParser/ELFAsmParser.cpp7
-rw-r--r--llvm/lib/MC/MCSectionELF.cpp4
2 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index fff081f0445..8838f16d60a 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -395,7 +395,10 @@ bool ELFAsmParser::maybeParseSectionType(StringRef &TypeName) {
return TokError("expected '@<type>', '%<type>' or \"<type>\"");
if (!L.is(AsmToken::String))
Lex();
- if (getParser().parseIdentifier(TypeName))
+ if (L.is(AsmToken::Integer)) {
+ TypeName = getTok().getString();
+ Lex();
+ } else if (getParser().parseIdentifier(TypeName))
return TokError("expected identifier in directive");
return false;
}
@@ -580,7 +583,7 @@ EndStmt:
Type = ELF::SHT_NOTE;
else if (TypeName == "unwind")
Type = ELF::SHT_X86_64_UNWIND;
- else
+ else if (TypeName.getAsInteger(0, Type))
return TokError("unknown section type");
}
diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp
index fdd9239a0f1..c73fafe151b 100644
--- a/llvm/lib/MC/MCSectionELF.cpp
+++ b/llvm/lib/MC/MCSectionELF.cpp
@@ -12,6 +12,7 @@
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCSectionELF.h"
#include "llvm/Support/ELF.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
@@ -140,6 +141,9 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
OS << "progbits";
else if (Type == ELF::SHT_X86_64_UNWIND)
OS << "unwind";
+ else
+ report_fatal_error("unsupported type 0x" + Twine::utohexstr(Type) +
+ " for section " + getSectionName());
if (EntrySize) {
assert(Flags & ELF::SHF_MERGE);
OpenPOWER on IntegriCloud