summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp53
1 files changed, 52 insertions, 1 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 1152a154b4d..c3886475aa3 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -17,9 +17,11 @@
//===----------------------------------------------------------------------===//
#include "llvm-objdump.h"
+#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/CodeGen/FaultMaps.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDisassembler.h"
@@ -153,6 +155,9 @@ cl::opt<bool>
llvm::PrintImmHex("print-imm-hex",
cl::desc("Use hex format for immediate values"));
+cl::opt<bool> PrintFaultMaps("fault-map-section",
+ cl::desc("Display contents of faultmap section"));
+
static StringRef ToolName;
static int ReturnValue = EXIT_SUCCESS;
@@ -1226,6 +1231,49 @@ void llvm::printWeakBindTable(const ObjectFile *o) {
}
}
+static void printFaultMaps(const ObjectFile *Obj) {
+ const char *FaultMapSectionName = nullptr;
+
+ if (isa<ELFObjectFileBase>(Obj)) {
+ FaultMapSectionName = ".llvm_faultmaps";
+ } else if (isa<MachOObjectFile>(Obj)) {
+ FaultMapSectionName = "__llvm_faultmaps";
+ } else {
+ errs() << "This operation is only currently supported "
+ "for ELF and Mach-O executable files.\n";
+ return;
+ }
+
+ Optional<object::SectionRef> FaultMapSection;
+
+ for (auto Sec : Obj->sections()) {
+ StringRef Name;
+ Sec.getName(Name);
+ if (Name == FaultMapSectionName) {
+ FaultMapSection = Sec;
+ break;
+ }
+ }
+
+ outs() << "FaultMap table:\n";
+
+ if (!FaultMapSection.hasValue()) {
+ outs() << "<not found>\n";
+ return;
+ }
+
+ StringRef FaultMapContents;
+ if (error(FaultMapSection.getValue().getContents(FaultMapContents))) {
+ errs() << "Could not read the " << FaultMapContents << " section!\n";
+ return;
+ }
+
+ FaultMapParser FMP(FaultMapContents.bytes_begin(),
+ FaultMapContents.bytes_end());
+
+ outs() << FMP;
+}
+
static void printPrivateFileHeader(const ObjectFile *o) {
if (o->isELF()) {
printELFFileHeader(o);
@@ -1265,6 +1313,8 @@ static void DumpObject(const ObjectFile *o) {
printLazyBindTable(o);
if (WeakBind)
printWeakBindTable(o);
+ if (PrintFaultMaps)
+ printFaultMaps(o);
}
/// @brief Dump each object file in \a a;
@@ -1362,7 +1412,8 @@ int main(int argc, char **argv) {
&& !(DylibsUsed && MachOOpt)
&& !(DylibId && MachOOpt)
&& !(ObjcMetaData && MachOOpt)
- && !(DumpSections.size() != 0 && MachOOpt)) {
+ && !(DumpSections.size() != 0 && MachOOpt)
+ && !PrintFaultMaps) {
cl::PrintHelpMessage();
return 2;
}
OpenPOWER on IntegriCloud