From fd6d1651551d5a08b3cf0fcafed5e91a40b8e317 Mon Sep 17 00:00:00 2001 From: Jack Carter Date: Tue, 28 Aug 2012 19:24:49 +0000 Subject: [PATCH] Some of the instructions in the Mips instruction set are revision delimited. llvm-mc -disassemble access these through the -mattr option. llvm-objdump -disassemble had no such way to set the attribute so some instructions were just not recognized for disassembly. This patch accepts llvm-mc mechanism for specifying the attributes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162781 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Object/Mips/dext-test.elf-mips64r2 | Bin 0 -> 802 bytes test/Object/Mips/feature.test | 11 +++++++++++ tools/llvm-objdump/llvm-objdump.cpp | 17 ++++++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test/Object/Mips/dext-test.elf-mips64r2 create mode 100644 test/Object/Mips/feature.test diff --git a/test/Object/Mips/dext-test.elf-mips64r2 b/test/Object/Mips/dext-test.elf-mips64r2 new file mode 100644 index 0000000000000000000000000000000000000000..59dbaef69a2d666576382bb77c45f69afd4e622f GIT binary patch literal 802 zcmb<-^>JfjWMpQ50!9W721XbMiSB^QGc-7W*$xcs3@kv^515@jn`%IGvj&8A=4`5A z&?`x;C}Ge`DlTTwE6yk`DJn@!02AN5&ejY4(K}N&u*8y>m0LZP#Kn}=ZLKc9sJ)nXI zpnOpHumUm6|FCco1B#)$9i)W=DkufwAOUpyk)%+VAayJZAOE8WLOIM>QyRz}*n9#K t$8;el&@3S&b71}wfr<-2?ShH(LB(Nw7|oCZOs;x4Iba%0l!D1z1^~s~Cs+Ug literal 0 HcmV?d00001 diff --git a/test/Object/Mips/feature.test b/test/Object/Mips/feature.test new file mode 100644 index 00000000000..5e5c9f442de --- /dev/null +++ b/test/Object/Mips/feature.test @@ -0,0 +1,11 @@ +RUN: llvm-objdump -disassemble -triple mips64el -mattr +mips64r2 %p/dext-test.elf-mips64r2 \ +RUN: | FileCheck %s + +CHECK: Disassembly of section .text: +CHECK: .text: +CHECK: 0: 08 00 e0 03 jr $ra +CHECK: 4: 43 49 82 7c dext $2, $4, 5, 10 +CHECK: 8: 08 00 e0 03 jr $ra +CHECK: c: 83 28 82 7c dext $2, $4, 2, 6 +CHECK: 10: 08 00 e0 03 jr $ra +CHECK: 14: 43 09 82 7c dext $2, $4, 5, 2 diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp index b431c7638d7..13ea4e32958 100644 --- a/tools/llvm-objdump/llvm-objdump.cpp +++ b/tools/llvm-objdump/llvm-objdump.cpp @@ -94,6 +94,12 @@ static cl::alias SectionHeadersShorter("h", cl::desc("Alias for --section-headers"), cl::aliasopt(SectionHeaders)); +static cl::list +MAttrs("mattr", + cl::CommaSeparated, + cl::desc("Target specific attributes"), + cl::value_desc("a1,+a2,-a3,...")); + static StringRef ToolName; static bool error(error_code ec) { @@ -169,6 +175,15 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) { if (!TheTarget) return; + // Package up features to be passed to target/subtarget + std::string FeaturesStr; + if (MAttrs.size()) { + SubtargetFeatures Features; + for (unsigned i = 0; i != MAttrs.size(); ++i) + Features.AddFeature(MAttrs[i]); + FeaturesStr = Features.getString(); + } + error_code ec; for (section_iterator i = Obj->begin_sections(), e = Obj->end_sections(); @@ -233,7 +248,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) { } OwningPtr STI( - TheTarget->createMCSubtargetInfo(TripleName, "", "")); + TheTarget->createMCSubtargetInfo(TripleName, "", FeaturesStr)); if (!STI) { errs() << "error: no subtarget info for target " << TripleName << "\n"; -- 2.34.1