summaryrefslogtreecommitdiff
path: root/tools/llvm-nm
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-08-07 23:27:14 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-08-07 23:27:14 +0000
commite84d8c12d5157a926db15976389f703809c49aa5 (patch)
tree6f5b50f41f0d132b6218ad28661ddf89d77b57de /tools/llvm-nm
parent3a16c7948a67a16da7a968984201b1f85a8009fa (diff)
Convert getSymbolSection to return an ErrorOr.
This function can actually fail since the symbol contains an index to the section and that can be invalid. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244375 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-nm')
-rw-r--r--tools/llvm-nm/llvm-nm.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp
index e7ee3124ed7..ce12fe6bc0e 100644
--- a/tools/llvm-nm/llvm-nm.cpp
+++ b/tools/llvm-nm/llvm-nm.cpp
@@ -314,8 +314,7 @@ static void darwinPrintSymbol(MachOObjectFile *MachO, SymbolListT::iterator I,
outs() << "(indirect) ";
break;
case MachO::N_SECT: {
- section_iterator Sec = MachO->section_end();
- MachO->getSymbolSection(I->Sym.getRawDataRefImpl(), Sec);
+ section_iterator Sec = *MachO->getSymbolSection(I->Sym.getRawDataRefImpl());
DataRefImpl Ref = Sec->getRawDataRefImpl();
StringRef SectionName;
MachO->getSectionName(Ref, SectionName);
@@ -594,10 +593,11 @@ static char getSymbolNMTypeChar(ELFObjectFileBase &Obj,
// OK, this is ELF
elf_symbol_iterator SymI(I);
- elf_section_iterator SecI = Obj.section_end();
- if (error(SymI->getSection(SecI)))
+ ErrorOr<elf_section_iterator> SecIOrErr = SymI->getSection();
+ if (error(SecIOrErr.getError()))
return '?';
+ elf_section_iterator SecI = *SecIOrErr;
if (SecI != Obj.section_end()) {
switch (SecI->getType()) {
case ELF::SHT_PROGBITS:
@@ -651,9 +651,10 @@ static char getSymbolNMTypeChar(COFFObjectFile &Obj, symbol_iterator I) {
uint32_t Characteristics = 0;
if (!COFF::isReservedSectionNumber(Symb.getSectionNumber())) {
- section_iterator SecI = Obj.section_end();
- if (error(SymI->getSection(SecI)))
+ ErrorOr<section_iterator> SecIOrErr = SymI->getSection();
+ if (error(SecIOrErr.getError()))
return '?';
+ section_iterator SecI = *SecIOrErr;
const coff_section *Section = Obj.getCOFFSection(*SecI);
Characteristics = Section->Characteristics;
}
@@ -701,8 +702,7 @@ static char getSymbolNMTypeChar(MachOObjectFile &Obj, basic_symbol_iterator I) {
case MachO::N_INDR:
return 'i';
case MachO::N_SECT: {
- section_iterator Sec = Obj.section_end();
- Obj.getSymbolSection(Symb, Sec);
+ section_iterator Sec = *Obj.getSymbolSection(Symb);
DataRefImpl Ref = Sec->getRawDataRefImpl();
StringRef SectionName;
Obj.getSectionName(Ref, SectionName);