mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
Fix a bugs with using some Mach-O command line flags like "-arch armv7m".
The Mach-O command line flag like "-arch armv7m" does not match the arch name part of its llvm Triple which is "thumbv7m-apple-darwin”. I think the best way to fix this is to have llvm::object::MachOObjectFile::getArchTriple() optionally return the name of the Mach-O arch flag that would be used with -arch that matches the CPUType and CPUSubType. Then change llvm::object::MachOUniversalBinary::ObjectForArch::getArchTypeName() to use that and change it to getArchFlagName() as the type name is really part of the Triple and the -arch flag name is a Mach-O thing for a specific Triple with a specific Mcpu value. rdar://29663637 llvm-svn: 290001
This commit is contained in:
parent
4078aeb252
commit
5bbb04ae53
@ -413,7 +413,8 @@ public:
|
||||
|
||||
static Triple::ArchType getArch(uint32_t CPUType);
|
||||
static Triple getArchTriple(uint32_t CPUType, uint32_t CPUSubType,
|
||||
const char **McpuDefault = nullptr);
|
||||
const char **McpuDefault = nullptr,
|
||||
const char **ArchFlag = nullptr);
|
||||
static bool isValidArch(StringRef ArchFlag);
|
||||
static Triple getHostArch();
|
||||
|
||||
|
@ -89,16 +89,24 @@ public:
|
||||
else // Parent->getMagic() == MachO::FAT_MAGIC_64
|
||||
return Header64.reserved;
|
||||
}
|
||||
std::string getArchTypeName() const {
|
||||
std::string getArchFlagName() const {
|
||||
const char *McpuDefault, *ArchFlag;
|
||||
if (Parent->getMagic() == MachO::FAT_MAGIC) {
|
||||
Triple T =
|
||||
MachOObjectFile::getArchTriple(Header.cputype, Header.cpusubtype);
|
||||
return T.getArchName();
|
||||
MachOObjectFile::getArchTriple(Header.cputype, Header.cpusubtype,
|
||||
&McpuDefault, &ArchFlag);
|
||||
} else { // Parent->getMagic() == MachO::FAT_MAGIC_64
|
||||
Triple T =
|
||||
MachOObjectFile::getArchTriple(Header64.cputype,
|
||||
Header64.cpusubtype);
|
||||
return T.getArchName();
|
||||
Header64.cpusubtype,
|
||||
&McpuDefault, &ArchFlag);
|
||||
}
|
||||
if (ArchFlag) {
|
||||
std::string ArchFlagName(ArchFlag);
|
||||
return ArchFlagName;
|
||||
} else {
|
||||
std::string ArchFlagName("");
|
||||
return ArchFlagName;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2318,14 +2318,19 @@ Triple::ArchType MachOObjectFile::getArch(uint32_t CPUType) {
|
||||
}
|
||||
|
||||
Triple MachOObjectFile::getArchTriple(uint32_t CPUType, uint32_t CPUSubType,
|
||||
const char **McpuDefault) {
|
||||
const char **McpuDefault,
|
||||
const char **ArchFlag) {
|
||||
if (McpuDefault)
|
||||
*McpuDefault = nullptr;
|
||||
if (ArchFlag)
|
||||
*ArchFlag = nullptr;
|
||||
|
||||
switch (CPUType) {
|
||||
case MachO::CPU_TYPE_I386:
|
||||
switch (CPUSubType & ~MachO::CPU_SUBTYPE_MASK) {
|
||||
case MachO::CPU_SUBTYPE_I386_ALL:
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "i386";
|
||||
return Triple("i386-apple-darwin");
|
||||
default:
|
||||
return Triple();
|
||||
@ -2333,8 +2338,12 @@ Triple MachOObjectFile::getArchTriple(uint32_t CPUType, uint32_t CPUSubType,
|
||||
case MachO::CPU_TYPE_X86_64:
|
||||
switch (CPUSubType & ~MachO::CPU_SUBTYPE_MASK) {
|
||||
case MachO::CPU_SUBTYPE_X86_64_ALL:
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "x86_64";
|
||||
return Triple("x86_64-apple-darwin");
|
||||
case MachO::CPU_SUBTYPE_X86_64_H:
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "x86_64h";
|
||||
return Triple("x86_64h-apple-darwin");
|
||||
default:
|
||||
return Triple();
|
||||
@ -2342,30 +2351,50 @@ Triple MachOObjectFile::getArchTriple(uint32_t CPUType, uint32_t CPUSubType,
|
||||
case MachO::CPU_TYPE_ARM:
|
||||
switch (CPUSubType & ~MachO::CPU_SUBTYPE_MASK) {
|
||||
case MachO::CPU_SUBTYPE_ARM_V4T:
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "armv4t";
|
||||
return Triple("armv4t-apple-darwin");
|
||||
case MachO::CPU_SUBTYPE_ARM_V5TEJ:
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "armv5e";
|
||||
return Triple("armv5e-apple-darwin");
|
||||
case MachO::CPU_SUBTYPE_ARM_XSCALE:
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "xscale";
|
||||
return Triple("xscale-apple-darwin");
|
||||
case MachO::CPU_SUBTYPE_ARM_V6:
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "armv6";
|
||||
return Triple("armv6-apple-darwin");
|
||||
case MachO::CPU_SUBTYPE_ARM_V6M:
|
||||
if (McpuDefault)
|
||||
*McpuDefault = "cortex-m0";
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "armv6m";
|
||||
return Triple("armv6m-apple-darwin");
|
||||
case MachO::CPU_SUBTYPE_ARM_V7:
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "armv7";
|
||||
return Triple("armv7-apple-darwin");
|
||||
case MachO::CPU_SUBTYPE_ARM_V7EM:
|
||||
if (McpuDefault)
|
||||
*McpuDefault = "cortex-m4";
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "armv7em";
|
||||
return Triple("thumbv7em-apple-darwin");
|
||||
case MachO::CPU_SUBTYPE_ARM_V7K:
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "armv7k";
|
||||
return Triple("armv7k-apple-darwin");
|
||||
case MachO::CPU_SUBTYPE_ARM_V7M:
|
||||
if (McpuDefault)
|
||||
*McpuDefault = "cortex-m3";
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "armv7m";
|
||||
return Triple("thumbv7m-apple-darwin");
|
||||
case MachO::CPU_SUBTYPE_ARM_V7S:
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "armv7s";
|
||||
return Triple("armv7s-apple-darwin");
|
||||
default:
|
||||
return Triple();
|
||||
@ -2373,6 +2402,8 @@ Triple MachOObjectFile::getArchTriple(uint32_t CPUType, uint32_t CPUSubType,
|
||||
case MachO::CPU_TYPE_ARM64:
|
||||
switch (CPUSubType & ~MachO::CPU_SUBTYPE_MASK) {
|
||||
case MachO::CPU_SUBTYPE_ARM64_ALL:
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "arm64";
|
||||
return Triple("arm64-apple-darwin");
|
||||
default:
|
||||
return Triple();
|
||||
@ -2380,6 +2411,8 @@ Triple MachOObjectFile::getArchTriple(uint32_t CPUType, uint32_t CPUSubType,
|
||||
case MachO::CPU_TYPE_POWERPC:
|
||||
switch (CPUSubType & ~MachO::CPU_SUBTYPE_MASK) {
|
||||
case MachO::CPU_SUBTYPE_POWERPC_ALL:
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "ppc";
|
||||
return Triple("ppc-apple-darwin");
|
||||
default:
|
||||
return Triple();
|
||||
@ -2387,6 +2420,8 @@ Triple MachOObjectFile::getArchTriple(uint32_t CPUType, uint32_t CPUSubType,
|
||||
case MachO::CPU_TYPE_POWERPC64:
|
||||
switch (CPUSubType & ~MachO::CPU_SUBTYPE_MASK) {
|
||||
case MachO::CPU_SUBTYPE_POWERPC_ALL:
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "ppc64";
|
||||
return Triple("ppc64-apple-darwin");
|
||||
default:
|
||||
return Triple();
|
||||
|
@ -219,7 +219,7 @@ MachOUniversalBinary::getObjectForArch(StringRef ArchName) const {
|
||||
object_error::arch_not_found);
|
||||
|
||||
for (auto &Obj : objects())
|
||||
if (Obj.getArchTypeName() == ArchName)
|
||||
if (Obj.getArchFlagName() == ArchName)
|
||||
return Obj.getAsObjectFile();
|
||||
return make_error<GenericBinaryError>("fat file does not "
|
||||
"contain " +
|
||||
|
BIN
test/tools/llvm-objdump/ARM/Inputs/fat-armv7m.o
Normal file
BIN
test/tools/llvm-objdump/ARM/Inputs/fat-armv7m.o
Normal file
Binary file not shown.
5
test/tools/llvm-objdump/ARM/macho-arch-armv7m-flag.test
Normal file
5
test/tools/llvm-objdump/ARM/macho-arch-armv7m-flag.test
Normal file
@ -0,0 +1,5 @@
|
||||
@ RUN: llvm-objdump -macho -d -arch armv7m %p/Inputs/fat-armv7m.o | FileCheck %s
|
||||
@ CHECK: fat-armv7m.o:
|
||||
@ CHECK: (__TEXT,__text) section
|
||||
@ CHECK: foo:
|
||||
@ CHECK: 00 bf nop
|
@ -1,8 +1,8 @@
|
||||
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=x86_64 | FileCheck --check-prefix=X86_64 %s
|
||||
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=x86_64h | FileCheck --check-prefix=X86_64H %s
|
||||
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=armv7 | FileCheck --check-prefix=ARMV7 %s
|
||||
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=thumbv7em | FileCheck --check-prefix=ARMV7EM %s
|
||||
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=thumbv7m | FileCheck --check-prefix=ARMV7M %s
|
||||
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=armv7em | FileCheck --check-prefix=ARMV7EM %s
|
||||
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=armv7m | FileCheck --check-prefix=ARMV7M %s
|
||||
|
||||
X86_64: x86_64_function
|
||||
X86_64H: x86_64h_function
|
||||
|
@ -112,7 +112,7 @@ static void DumpInput(StringRef Filename) {
|
||||
auto MachOOrErr = ObjForArch.getAsObjectFile();
|
||||
error(Filename, errorToErrorCode(MachOOrErr.takeError()));
|
||||
DumpObjectFile(**MachOOrErr,
|
||||
Filename + " (" + ObjForArch.getArchTypeName() + ")");
|
||||
Filename + " (" + ObjForArch.getArchFlagName() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1148,7 +1148,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
||||
for (MachOUniversalBinary::object_iterator I = UB->begin_objects(),
|
||||
E = UB->end_objects();
|
||||
I != E; ++I) {
|
||||
if (ArchFlags[i] == I->getArchTypeName()) {
|
||||
if (ArchFlags[i] == I->getArchFlagName()) {
|
||||
ArchFound = true;
|
||||
Expected<std::unique_ptr<ObjectFile>> ObjOrErr =
|
||||
I->getAsObjectFile();
|
||||
@ -1160,10 +1160,10 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
||||
ObjectFile &Obj = *ObjOrErr.get();
|
||||
if (ArchFlags.size() > 1) {
|
||||
if (PrintFileName)
|
||||
ArchitectureName = I->getArchTypeName();
|
||||
ArchitectureName = I->getArchFlagName();
|
||||
else
|
||||
outs() << "\n" << Obj.getFileName() << " (for architecture "
|
||||
<< I->getArchTypeName() << ")"
|
||||
<< I->getArchFlagName() << ")"
|
||||
<< ":\n";
|
||||
}
|
||||
dumpSymbolNamesFromObject(Obj, false, ArchiveName,
|
||||
@ -1171,7 +1171,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
||||
} else if (auto E = isNotObjectErrorInvalidFileType(
|
||||
ObjOrErr.takeError())) {
|
||||
error(std::move(E), Filename, ArchFlags.size() > 1 ?
|
||||
StringRef(I->getArchTypeName()) : StringRef());
|
||||
StringRef(I->getArchFlagName()) : StringRef());
|
||||
continue;
|
||||
} else if (Expected<std::unique_ptr<Archive>> AOrErr =
|
||||
I->getAsArchive()) {
|
||||
@ -1184,7 +1184,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
||||
if (auto E = isNotObjectErrorInvalidFileType(
|
||||
ChildOrErr.takeError())) {
|
||||
error(std::move(E), Filename, C, ArchFlags.size() > 1 ?
|
||||
StringRef(I->getArchTypeName()) : StringRef());
|
||||
StringRef(I->getArchFlagName()) : StringRef());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -1193,12 +1193,12 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
||||
if (PrintFileName) {
|
||||
ArchiveName = A->getFileName();
|
||||
if (ArchFlags.size() > 1)
|
||||
ArchitectureName = I->getArchTypeName();
|
||||
ArchitectureName = I->getArchFlagName();
|
||||
} else {
|
||||
outs() << "\n" << A->getFileName();
|
||||
outs() << "(" << O->getFileName() << ")";
|
||||
if (ArchFlags.size() > 1) {
|
||||
outs() << " (for architecture " << I->getArchTypeName()
|
||||
outs() << " (for architecture " << I->getArchFlagName()
|
||||
<< ")";
|
||||
}
|
||||
outs() << ":\n";
|
||||
@ -1212,7 +1212,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
||||
} else {
|
||||
consumeError(AOrErr.takeError());
|
||||
error(Filename + " for architecture " +
|
||||
StringRef(I->getArchTypeName()) +
|
||||
StringRef(I->getArchFlagName()) +
|
||||
" is not a Mach-O file or an archive file",
|
||||
"Mach-O universal file");
|
||||
}
|
||||
@ -1233,7 +1233,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
||||
for (MachOUniversalBinary::object_iterator I = UB->begin_objects(),
|
||||
E = UB->end_objects();
|
||||
I != E; ++I) {
|
||||
if (HostArchName == I->getArchTypeName()) {
|
||||
if (HostArchName == I->getArchFlagName()) {
|
||||
Expected<std::unique_ptr<ObjectFile>> ObjOrErr = I->getAsObjectFile();
|
||||
std::string ArchiveName;
|
||||
ArchiveName.clear();
|
||||
@ -1273,7 +1273,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
||||
} else {
|
||||
consumeError(AOrErr.takeError());
|
||||
error(Filename + " for architecture " +
|
||||
StringRef(I->getArchTypeName()) +
|
||||
StringRef(I->getArchFlagName()) +
|
||||
" is not a Mach-O file or an archive file",
|
||||
"Mach-O universal file");
|
||||
}
|
||||
@ -1296,20 +1296,20 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
||||
ObjectFile &Obj = *ObjOrErr.get();
|
||||
if (PrintFileName) {
|
||||
if (isa<MachOObjectFile>(Obj) && moreThanOneArch)
|
||||
ArchitectureName = I->getArchTypeName();
|
||||
ArchitectureName = I->getArchFlagName();
|
||||
} else {
|
||||
if (moreThanOneArch)
|
||||
outs() << "\n";
|
||||
outs() << Obj.getFileName();
|
||||
if (isa<MachOObjectFile>(Obj) && moreThanOneArch)
|
||||
outs() << " (for architecture " << I->getArchTypeName() << ")";
|
||||
outs() << " (for architecture " << I->getArchFlagName() << ")";
|
||||
outs() << ":\n";
|
||||
}
|
||||
dumpSymbolNamesFromObject(Obj, false, ArchiveName, ArchitectureName);
|
||||
} else if (auto E = isNotObjectErrorInvalidFileType(
|
||||
ObjOrErr.takeError())) {
|
||||
error(std::move(E), Filename, moreThanOneArch ?
|
||||
StringRef(I->getArchTypeName()) : StringRef());
|
||||
StringRef(I->getArchFlagName()) : StringRef());
|
||||
continue;
|
||||
} else if (Expected<std::unique_ptr<Archive>> AOrErr =
|
||||
I->getAsArchive()) {
|
||||
@ -1329,13 +1329,13 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
||||
if (PrintFileName) {
|
||||
ArchiveName = A->getFileName();
|
||||
if (isa<MachOObjectFile>(O) && moreThanOneArch)
|
||||
ArchitectureName = I->getArchTypeName();
|
||||
ArchitectureName = I->getArchFlagName();
|
||||
} else {
|
||||
outs() << "\n" << A->getFileName();
|
||||
if (isa<MachOObjectFile>(O)) {
|
||||
outs() << "(" << O->getFileName() << ")";
|
||||
if (moreThanOneArch)
|
||||
outs() << " (for architecture " << I->getArchTypeName()
|
||||
outs() << " (for architecture " << I->getArchFlagName()
|
||||
<< ")";
|
||||
} else
|
||||
outs() << ":" << O->getFileName();
|
||||
@ -1349,7 +1349,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
||||
} else {
|
||||
consumeError(AOrErr.takeError());
|
||||
error(Filename + " for architecture " +
|
||||
StringRef(I->getArchTypeName()) +
|
||||
StringRef(I->getArchFlagName()) +
|
||||
" is not a Mach-O file or an archive file",
|
||||
"Mach-O universal file");
|
||||
}
|
||||
|
@ -1162,15 +1162,19 @@ static bool checkMachOAndArchFlags(ObjectFile *O, StringRef Filename) {
|
||||
MachO::mach_header H;
|
||||
MachO::mach_header_64 H_64;
|
||||
Triple T;
|
||||
const char *McpuDefault, *ArchFlag;
|
||||
if (MachO->is64Bit()) {
|
||||
H_64 = MachO->MachOObjectFile::getHeader64();
|
||||
T = MachOObjectFile::getArchTriple(H_64.cputype, H_64.cpusubtype);
|
||||
T = MachOObjectFile::getArchTriple(H_64.cputype, H_64.cpusubtype,
|
||||
&McpuDefault, &ArchFlag);
|
||||
} else {
|
||||
H = MachO->MachOObjectFile::getHeader();
|
||||
T = MachOObjectFile::getArchTriple(H.cputype, H.cpusubtype);
|
||||
T = MachOObjectFile::getArchTriple(H.cputype, H.cpusubtype,
|
||||
&McpuDefault, &ArchFlag);
|
||||
}
|
||||
const std::string ArchFlagName(ArchFlag);
|
||||
if (none_of(ArchFlags, [&](const std::string &Name) {
|
||||
return Name == T.getArchName();
|
||||
return Name == ArchFlagName;
|
||||
})) {
|
||||
errs() << "llvm-objdump: " + Filename + ": No architecture specified.\n";
|
||||
return false;
|
||||
@ -1419,7 +1423,7 @@ static void printMachOUniversalHeaders(const object::MachOUniversalBinary *UB,
|
||||
}
|
||||
}
|
||||
if (verbose) {
|
||||
outs() << OFA.getArchTypeName() << "\n";
|
||||
outs() << OFA.getArchFlagName() << "\n";
|
||||
printCPUType(cputype, cpusubtype & ~MachO::CPU_SUBTYPE_MASK);
|
||||
} else {
|
||||
outs() << i << "\n";
|
||||
@ -1603,13 +1607,13 @@ void llvm::ParseInputMachO(StringRef Filename) {
|
||||
for (MachOUniversalBinary::object_iterator I = UB->begin_objects(),
|
||||
E = UB->end_objects();
|
||||
I != E; ++I) {
|
||||
if (ArchFlags[i] == I->getArchTypeName()) {
|
||||
if (ArchFlags[i] == I->getArchFlagName()) {
|
||||
ArchFound = true;
|
||||
Expected<std::unique_ptr<ObjectFile>> ObjOrErr =
|
||||
I->getAsObjectFile();
|
||||
std::string ArchitectureName = "";
|
||||
if (ArchFlags.size() > 1)
|
||||
ArchitectureName = I->getArchTypeName();
|
||||
ArchitectureName = I->getArchFlagName();
|
||||
if (ObjOrErr) {
|
||||
ObjectFile &O = *ObjOrErr.get();
|
||||
if (MachOObjectFile *MachOOF = dyn_cast<MachOObjectFile>(&O))
|
||||
@ -1646,7 +1650,7 @@ void llvm::ParseInputMachO(StringRef Filename) {
|
||||
} else {
|
||||
consumeError(AOrErr.takeError());
|
||||
error("Mach-O universal file: " + Filename + " for " +
|
||||
"architecture " + StringRef(I->getArchTypeName()) +
|
||||
"architecture " + StringRef(I->getArchFlagName()) +
|
||||
" is not a Mach-O file or an archive file");
|
||||
}
|
||||
}
|
||||
@ -1666,7 +1670,7 @@ void llvm::ParseInputMachO(StringRef Filename) {
|
||||
E = UB->end_objects();
|
||||
I != E; ++I) {
|
||||
if (MachOObjectFile::getHostArch().getArchName() ==
|
||||
I->getArchTypeName()) {
|
||||
I->getArchFlagName()) {
|
||||
Expected<std::unique_ptr<ObjectFile>> ObjOrErr = I->getAsObjectFile();
|
||||
std::string ArchiveName;
|
||||
ArchiveName.clear();
|
||||
@ -1702,7 +1706,7 @@ void llvm::ParseInputMachO(StringRef Filename) {
|
||||
} else {
|
||||
consumeError(AOrErr.takeError());
|
||||
error("Mach-O universal file: " + Filename + " for architecture " +
|
||||
StringRef(I->getArchTypeName()) +
|
||||
StringRef(I->getArchFlagName()) +
|
||||
" is not a Mach-O file or an archive file");
|
||||
}
|
||||
return;
|
||||
@ -1718,7 +1722,7 @@ void llvm::ParseInputMachO(StringRef Filename) {
|
||||
Expected<std::unique_ptr<ObjectFile>> ObjOrErr = I->getAsObjectFile();
|
||||
std::string ArchitectureName = "";
|
||||
if (moreThanOneArch)
|
||||
ArchitectureName = I->getArchTypeName();
|
||||
ArchitectureName = I->getArchFlagName();
|
||||
if (ObjOrErr) {
|
||||
ObjectFile &Obj = *ObjOrErr.get();
|
||||
if (MachOObjectFile *MachOOF = dyn_cast<MachOObjectFile>(&Obj))
|
||||
@ -1757,7 +1761,7 @@ void llvm::ParseInputMachO(StringRef Filename) {
|
||||
} else {
|
||||
consumeError(AOrErr.takeError());
|
||||
error("Mach-O universal file: " + Filename + " for architecture " +
|
||||
StringRef(I->getArchTypeName()) +
|
||||
StringRef(I->getArchFlagName()) +
|
||||
" is not a Mach-O file or an archive file");
|
||||
}
|
||||
}
|
||||
|
@ -580,7 +580,7 @@ static void printFileSectionSizes(StringRef file) {
|
||||
for (MachOUniversalBinary::object_iterator I = UB->begin_objects(),
|
||||
E = UB->end_objects();
|
||||
I != E; ++I) {
|
||||
if (ArchFlags[i] == I->getArchTypeName()) {
|
||||
if (ArchFlags[i] == I->getArchFlagName()) {
|
||||
ArchFound = true;
|
||||
Expected<std::unique_ptr<ObjectFile>> UO = I->getAsObjectFile();
|
||||
if (UO) {
|
||||
@ -591,20 +591,20 @@ static void printFileSectionSizes(StringRef file) {
|
||||
else if (MachO && OutputFormat == darwin) {
|
||||
if (MoreThanOneFile || ArchFlags.size() > 1)
|
||||
outs() << o->getFileName() << " (for architecture "
|
||||
<< I->getArchTypeName() << "): \n";
|
||||
<< I->getArchFlagName() << "): \n";
|
||||
}
|
||||
printObjectSectionSizes(o);
|
||||
if (OutputFormat == berkeley) {
|
||||
if (!MachO || MoreThanOneFile || ArchFlags.size() > 1)
|
||||
outs() << o->getFileName() << " (for architecture "
|
||||
<< I->getArchTypeName() << ")";
|
||||
<< I->getArchFlagName() << ")";
|
||||
outs() << "\n";
|
||||
}
|
||||
}
|
||||
} else if (auto E = isNotObjectErrorInvalidFileType(
|
||||
UO.takeError())) {
|
||||
error(std::move(E), file, ArchFlags.size() > 1 ?
|
||||
StringRef(I->getArchTypeName()) : StringRef());
|
||||
StringRef(I->getArchFlagName()) : StringRef());
|
||||
return;
|
||||
} else if (Expected<std::unique_ptr<Archive>> AOrErr =
|
||||
I->getAsArchive()) {
|
||||
@ -619,7 +619,7 @@ static void printFileSectionSizes(StringRef file) {
|
||||
ChildOrErr.takeError()))
|
||||
error(std::move(E), UA->getFileName(), C,
|
||||
ArchFlags.size() > 1 ?
|
||||
StringRef(I->getArchTypeName()) : StringRef());
|
||||
StringRef(I->getArchFlagName()) : StringRef());
|
||||
continue;
|
||||
}
|
||||
if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) {
|
||||
@ -630,7 +630,7 @@ static void printFileSectionSizes(StringRef file) {
|
||||
else if (MachO && OutputFormat == darwin)
|
||||
outs() << UA->getFileName() << "(" << o->getFileName()
|
||||
<< ")"
|
||||
<< " (for architecture " << I->getArchTypeName()
|
||||
<< " (for architecture " << I->getArchFlagName()
|
||||
<< "):\n";
|
||||
printObjectSectionSizes(o);
|
||||
if (OutputFormat == berkeley) {
|
||||
@ -638,7 +638,7 @@ static void printFileSectionSizes(StringRef file) {
|
||||
outs() << UA->getFileName() << "(" << o->getFileName()
|
||||
<< ")";
|
||||
if (ArchFlags.size() > 1)
|
||||
outs() << " (for architecture " << I->getArchTypeName()
|
||||
outs() << " (for architecture " << I->getArchFlagName()
|
||||
<< ")";
|
||||
outs() << "\n";
|
||||
} else
|
||||
@ -652,7 +652,7 @@ static void printFileSectionSizes(StringRef file) {
|
||||
} else {
|
||||
consumeError(AOrErr.takeError());
|
||||
error("Mach-O universal file: " + file + " for architecture " +
|
||||
StringRef(I->getArchTypeName()) +
|
||||
StringRef(I->getArchFlagName()) +
|
||||
" is not a Mach-O file or an archive file");
|
||||
}
|
||||
}
|
||||
@ -672,7 +672,7 @@ static void printFileSectionSizes(StringRef file) {
|
||||
for (MachOUniversalBinary::object_iterator I = UB->begin_objects(),
|
||||
E = UB->end_objects();
|
||||
I != E; ++I) {
|
||||
if (HostArchName == I->getArchTypeName()) {
|
||||
if (HostArchName == I->getArchFlagName()) {
|
||||
Expected<std::unique_ptr<ObjectFile>> UO = I->getAsObjectFile();
|
||||
if (UO) {
|
||||
if (ObjectFile *o = dyn_cast<ObjectFile>(&*UO.get())) {
|
||||
@ -682,13 +682,13 @@ static void printFileSectionSizes(StringRef file) {
|
||||
else if (MachO && OutputFormat == darwin) {
|
||||
if (MoreThanOneFile)
|
||||
outs() << o->getFileName() << " (for architecture "
|
||||
<< I->getArchTypeName() << "):\n";
|
||||
<< I->getArchFlagName() << "):\n";
|
||||
}
|
||||
printObjectSectionSizes(o);
|
||||
if (OutputFormat == berkeley) {
|
||||
if (!MachO || MoreThanOneFile)
|
||||
outs() << o->getFileName() << " (for architecture "
|
||||
<< I->getArchTypeName() << ")";
|
||||
<< I->getArchFlagName() << ")";
|
||||
outs() << "\n";
|
||||
}
|
||||
}
|
||||
@ -716,7 +716,7 @@ static void printFileSectionSizes(StringRef file) {
|
||||
<< "):\n";
|
||||
else if (MachO && OutputFormat == darwin)
|
||||
outs() << UA->getFileName() << "(" << o->getFileName() << ")"
|
||||
<< " (for architecture " << I->getArchTypeName()
|
||||
<< " (for architecture " << I->getArchFlagName()
|
||||
<< "):\n";
|
||||
printObjectSectionSizes(o);
|
||||
if (OutputFormat == berkeley) {
|
||||
@ -734,7 +734,7 @@ static void printFileSectionSizes(StringRef file) {
|
||||
} else {
|
||||
consumeError(AOrErr.takeError());
|
||||
error("Mach-O universal file: " + file + " for architecture " +
|
||||
StringRef(I->getArchTypeName()) +
|
||||
StringRef(I->getArchFlagName()) +
|
||||
" is not a Mach-O file or an archive file");
|
||||
}
|
||||
return;
|
||||
@ -756,20 +756,20 @@ static void printFileSectionSizes(StringRef file) {
|
||||
else if (MachO && OutputFormat == darwin) {
|
||||
if (MoreThanOneFile || MoreThanOneArch)
|
||||
outs() << o->getFileName() << " (for architecture "
|
||||
<< I->getArchTypeName() << "):";
|
||||
<< I->getArchFlagName() << "):";
|
||||
outs() << "\n";
|
||||
}
|
||||
printObjectSectionSizes(o);
|
||||
if (OutputFormat == berkeley) {
|
||||
if (!MachO || MoreThanOneFile || MoreThanOneArch)
|
||||
outs() << o->getFileName() << " (for architecture "
|
||||
<< I->getArchTypeName() << ")";
|
||||
<< I->getArchFlagName() << ")";
|
||||
outs() << "\n";
|
||||
}
|
||||
}
|
||||
} else if (auto E = isNotObjectErrorInvalidFileType(UO.takeError())) {
|
||||
error(std::move(E), file, MoreThanOneArch ?
|
||||
StringRef(I->getArchTypeName()) : StringRef());
|
||||
StringRef(I->getArchFlagName()) : StringRef());
|
||||
return;
|
||||
} else if (Expected<std::unique_ptr<Archive>> AOrErr =
|
||||
I->getAsArchive()) {
|
||||
@ -782,7 +782,7 @@ static void printFileSectionSizes(StringRef file) {
|
||||
if (auto E = isNotObjectErrorInvalidFileType(
|
||||
ChildOrErr.takeError()))
|
||||
error(std::move(E), UA->getFileName(), C, MoreThanOneArch ?
|
||||
StringRef(I->getArchTypeName()) : StringRef());
|
||||
StringRef(I->getArchFlagName()) : StringRef());
|
||||
continue;
|
||||
}
|
||||
if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) {
|
||||
@ -792,12 +792,12 @@ static void printFileSectionSizes(StringRef file) {
|
||||
<< "):\n";
|
||||
else if (MachO && OutputFormat == darwin)
|
||||
outs() << UA->getFileName() << "(" << o->getFileName() << ")"
|
||||
<< " (for architecture " << I->getArchTypeName() << "):\n";
|
||||
<< " (for architecture " << I->getArchFlagName() << "):\n";
|
||||
printObjectSectionSizes(o);
|
||||
if (OutputFormat == berkeley) {
|
||||
if (MachO)
|
||||
outs() << UA->getFileName() << "(" << o->getFileName() << ")"
|
||||
<< " (for architecture " << I->getArchTypeName()
|
||||
<< " (for architecture " << I->getArchFlagName()
|
||||
<< ")\n";
|
||||
else
|
||||
outs() << o->getFileName() << " (ex " << UA->getFileName()
|
||||
@ -810,7 +810,7 @@ static void printFileSectionSizes(StringRef file) {
|
||||
} else {
|
||||
consumeError(AOrErr.takeError());
|
||||
error("Mach-O universal file: " + file + " for architecture " +
|
||||
StringRef(I->getArchTypeName()) +
|
||||
StringRef(I->getArchFlagName()) +
|
||||
" is not a Mach-O file or an archive file");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user