mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
Add a warning when the llvm-nm -print-size flag is used on a Mach-O file as
Mach-O files don’t have size information about the symbols in the object file format unlike ELF. Also add the part of the fix to llvm-nm that was missed with r290001 so -arch armv7m works. rdar://25681018 llvm-svn: 293099
This commit is contained in:
parent
784e95d893
commit
791a549fbd
BIN
test/tools/llvm-nm/ARM/Inputs/print-size.macho-armv7m
Normal file
BIN
test/tools/llvm-nm/ARM/Inputs/print-size.macho-armv7m
Normal file
Binary file not shown.
2
test/tools/llvm-nm/ARM/lit.local.cfg
Normal file
2
test/tools/llvm-nm/ARM/lit.local.cfg
Normal file
@ -0,0 +1,2 @@
|
||||
if not 'ARM' in config.root.targets:
|
||||
config.unsupported = True
|
3
test/tools/llvm-nm/ARM/macho-print-size.test
Normal file
3
test/tools/llvm-nm/ARM/macho-print-size.test
Normal file
@ -0,0 +1,3 @@
|
||||
@ RUN: llvm-nm -print-size -arch armv7m %p/Inputs/print-size.macho-armv7m 2>&1 | FileCheck %s
|
||||
|
||||
@ CHECK: llvm-nm: warning sizes with -print-size for Mach-O files are always zero.
|
@ -129,6 +129,7 @@ cl::opt<bool> PrintSize("print-size",
|
||||
cl::desc("Show symbol size instead of address"));
|
||||
cl::alias PrintSizeS("S", cl::desc("Alias for --print-size"),
|
||||
cl::aliasopt(PrintSize), cl::Grouping);
|
||||
bool MachOPrintSizeWarning = false;
|
||||
|
||||
cl::opt<bool> SizeSort("size-sort", cl::desc("Sort symbols by size"));
|
||||
|
||||
@ -1057,15 +1058,19 @@ static bool checkMachOAndArchFlags(SymbolicFile *O, std::string &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;
|
||||
})) {
|
||||
error("No architecture specified", Filename);
|
||||
return false;
|
||||
@ -1120,6 +1125,11 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
||||
continue;
|
||||
}
|
||||
if (SymbolicFile *O = dyn_cast<SymbolicFile>(&*ChildOrErr.get())) {
|
||||
if (!MachOPrintSizeWarning && PrintSize && isa<MachOObjectFile>(O)) {
|
||||
errs() << ToolName << ": warning sizes with -print-size for Mach-O "
|
||||
"files are always zero.\n";
|
||||
MachOPrintSizeWarning = true;
|
||||
}
|
||||
if (!checkMachOAndArchFlags(O, Filename))
|
||||
return;
|
||||
if (!PrintFileName) {
|
||||
@ -1357,6 +1367,11 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
||||
return;
|
||||
}
|
||||
if (SymbolicFile *O = dyn_cast<SymbolicFile>(&Bin)) {
|
||||
if (!MachOPrintSizeWarning && PrintSize && isa<MachOObjectFile>(O)) {
|
||||
errs() << ToolName << ": warning sizes with -print-size for Mach-O files "
|
||||
"are always zero.\n";
|
||||
MachOPrintSizeWarning = true;
|
||||
}
|
||||
if (!checkMachOAndArchFlags(O, Filename))
|
||||
return;
|
||||
dumpSymbolNamesFromObject(*O, true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user