cl::desc("Display the ARM attributes section"));
cl::alias ARMAttributesShort("-a", cl::desc("Alias for --arm-attributes"),
cl::aliasopt(ARMAttributes));
+
+ // -mips-plt-got
+ cl::opt<bool>
+ MipsPLTGOT("mips-plt-got",
+ cl::desc("Display the MIPS GOT and PLT GOT sections"));
} // namespace opts
static int ReturnValue = EXIT_SUCCESS;
namespace llvm {
-bool error(error_code EC) {
+bool error(std::error_code EC) {
if (!EC)
return false;
} // namespace llvm
-
-static void reportError(StringRef Input, error_code EC) {
+static void reportError(StringRef Input, std::error_code EC) {
if (Input == "-")
Input = "<stdin>";
ReturnValue = EXIT_FAILURE;
}
+static bool isMipsArch(unsigned Arch) {
+ switch (Arch) {
+ case llvm::Triple::mips:
+ case llvm::Triple::mipsel:
+ case llvm::Triple::mips64:
+ case llvm::Triple::mips64el:
+ return true;
+ default:
+ return false;
+ }
+}
+
/// @brief Creates an format-specific object file dumper.
-static error_code createDumper(const ObjectFile *Obj, StreamWriter &Writer,
- std::unique_ptr<ObjDumper> &Result) {
+static std::error_code createDumper(const ObjectFile *Obj, StreamWriter &Writer,
+ std::unique_ptr<ObjDumper> &Result) {
if (!Obj)
return readobj_error::unsupported_file_format;
static void dumpObject(const ObjectFile *Obj) {
StreamWriter Writer(outs());
std::unique_ptr<ObjDumper> Dumper;
- if (error_code EC = createDumper(Obj, Writer, Dumper)) {
+ if (std::error_code EC = createDumper(Obj, Writer, Dumper)) {
reportError(Obj->getFileName(), EC);
return;
}
if (Obj->getArch() == llvm::Triple::arm && Obj->isELF())
if (opts::ARMAttributes)
Dumper->printAttributes();
+ if (isMipsArch(Obj->getArch()) && Obj->isELF())
+ if (opts::MipsPLTGOT)
+ Dumper->printMipsPLTGOT();
}
for (Archive::child_iterator ArcI = Arc->child_begin(),
ArcE = Arc->child_end();
ArcI != ArcE; ++ArcI) {
- std::unique_ptr<Binary> child;
- if (error_code EC = ArcI->getAsBinary(child)) {
+ ErrorOr<std::unique_ptr<Binary>> ChildOrErr = ArcI->getAsBinary();
+ if (std::error_code EC = ChildOrErr.getError()) {
// Ignore non-object files.
if (EC != object_error::invalid_file_type)
reportError(Arc->getFileName(), EC.message());
continue;
}
- if (ObjectFile *Obj = dyn_cast<ObjectFile>(child.get()))
+ if (ObjectFile *Obj = dyn_cast<ObjectFile>(&*ChildOrErr.get()))
dumpObject(Obj);
else
reportError(Arc->getFileName(), readobj_error::unrecognized_file_format);
// Attempt to open the binary.
ErrorOr<Binary *> BinaryOrErr = createBinary(File);
- if (error_code EC = BinaryOrErr.getError()) {
+ if (std::error_code EC = BinaryOrErr.getError()) {
reportError(File, EC);
return;
}