[ARM] Enable objdump to construct triple for ARM
Now that The ARMAttributeParser has been moved into the library, it has been modified so that it can parse the attributes without printing them and stores them in a map. ELFObjectFile now queries the attributes to fill out the architecture details of a provided triple for 'arm' and 'thumb' targets. llvm-objdump uses this new functionality. Differential Revision: https://reviews.llvm.org/D28281 llvm-svn: 291898
This commit is contained in:
@@ -357,7 +357,16 @@ static const Target *getTarget(const ObjectFile *Obj = nullptr) {
|
||||
llvm::Triple TheTriple("unknown-unknown-unknown");
|
||||
if (TripleName.empty()) {
|
||||
if (Obj) {
|
||||
TheTriple.setArch(Triple::ArchType(Obj->getArch()));
|
||||
auto Arch = Obj->getArch();
|
||||
TheTriple.setArch(Triple::ArchType(Arch));
|
||||
|
||||
// For ARM targets, try to use the build attributes to build determine
|
||||
// the build target. Target features are also added, but later during
|
||||
// disassembly.
|
||||
if (Arch == Triple::arm || Arch == Triple::armeb) {
|
||||
Obj->setARMSubArch(TheTriple);
|
||||
}
|
||||
|
||||
// TheTriple defaults to ELF, and COFF doesn't have an environment:
|
||||
// the best we can do here is indicate that it is mach-o.
|
||||
if (Obj->isMachO())
|
||||
@@ -369,8 +378,16 @@ static const Target *getTarget(const ObjectFile *Obj = nullptr) {
|
||||
TheTriple.setTriple("thumbv7-windows");
|
||||
}
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
TheTriple.setTriple(Triple::normalize(TripleName));
|
||||
// Use the triple, but also try to combine with ARM build attributes.
|
||||
if (Obj) {
|
||||
auto Arch = Obj->getArch();
|
||||
if (Arch == Triple::arm || Arch == Triple::armeb) {
|
||||
Obj->setARMSubArch(TheTriple);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the target specific parser.
|
||||
std::string Error;
|
||||
|
||||
Reference in New Issue
Block a user