summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-nm
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-06-24 10:20:30 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-06-24 10:20:30 +0000
commitd7a32ea4b86c04ba0c4736f803527eb393a40867 (patch)
tree1b09dcd2e51416a33c0b030346842e8ea6dd3e38 /llvm/tools/llvm-nm
parent595348228569c587e14bf8cea1c4fdf1b503c104 (diff)
downloadbcm5719-llvm-d7a32ea4b86c04ba0c4736f803527eb393a40867.tar.gz
bcm5719-llvm-d7a32ea4b86c04ba0c4736f803527eb393a40867.zip
Change how symbol sizes are handled in lib/Object.
COFF and MachO only define symbol sizes for common symbols. Reflect that in the class hierarchy by having a method for common symbols only in the base and a general one in ELF. This avoids the need of using a magic value for the size, which had a few problems * Most callers didn't check for it. * The ones that did could not tell the magic value from a file actually having that value. llvm-svn: 240529
Diffstat (limited to 'llvm/tools/llvm-nm')
-rw-r--r--llvm/tools/llvm-nm/llvm-nm.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index 8013f584239..b96d152f783 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -569,7 +569,7 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName,
continue;
if ((I->TypeChar == 'U') && DefinedOnly)
continue;
- if (SizeSort && !PrintAddress && I->Size == UnknownAddressOrSize)
+ if (SizeSort && !PrintAddress)
continue;
if (PrintFileName) {
if (!ArchitectureName.empty())
@@ -586,16 +586,15 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName,
char SymbolAddrStr[18] = "";
char SymbolSizeStr[18] = "";
- if (OutputFormat == sysv || I->Address == UnknownAddressOrSize)
+ if (OutputFormat == sysv || I->Address == UnknownAddress)
strcpy(SymbolAddrStr, printBlanks);
if (OutputFormat == sysv)
strcpy(SymbolSizeStr, printBlanks);
- if (I->Address != UnknownAddressOrSize)
+ if (I->Address != UnknownAddress)
format(printFormat, I->Address)
.print(SymbolAddrStr, sizeof(SymbolAddrStr));
- if (I->Size != UnknownAddressOrSize)
- format(printFormat, I->Size).print(SymbolSizeStr, sizeof(SymbolSizeStr));
+ format(printFormat, I->Size).print(SymbolSizeStr, sizeof(SymbolSizeStr));
// If OutputFormat is darwin or we are printing Mach-O symbols in hex and
// we have a MachOObjectFile, call darwinPrintSymbol to print as darwin's
@@ -613,8 +612,7 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName,
outs() << SymbolAddrStr << ' ';
if (PrintSize) {
outs() << SymbolSizeStr;
- if (I->Size != UnknownAddressOrSize)
- outs() << ' ';
+ outs() << ' ';
}
outs() << I->TypeChar;
if (I->TypeChar == '-' && MachO)
@@ -930,11 +928,13 @@ static void dumpSymbolNamesFromObject(SymbolicFile &Obj, bool printName,
if (Nsect && Nsect != getNsectInMachO(*MachO, I))
continue;
NMSymbol S;
- S.Size = UnknownAddressOrSize;
- S.Address = UnknownAddressOrSize;
- if (PrintSize && isa<ELFObjectFileBase>(Obj)) {
- symbol_iterator SymI = I;
- S.Size = SymI->getSize();
+ S.Size = 0;
+ S.Address = UnknownAddress;
+ if (PrintSize) {
+ if (auto *E = dyn_cast<ELFObjectFileBase>(&Obj)) {
+ symbol_iterator SymI = I;
+ S.Size = E->getSymbolSize(*SymI);
+ }
}
if (PrintAddress && isa<ObjectFile>(Obj))
if (error(symbol_iterator(I)->getAddress(S.Address)))
OpenPOWER on IntegriCloud