Make computeSymbolSizes never fail.

On ELF that was already the case since getting the size of a symbol
never fails.

On MachO and COFF we could fail trying to get the section of a symbol. But
we don't really need the section, just the section number to know if two
symbols are in the same section or not.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240580 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2015-06-24 19:57:32 +00:00
parent c9a4f3d5d9
commit a3af347f38
8 changed files with 54 additions and 24 deletions

View File

@ -258,6 +258,11 @@ COFFObjectFile::getSymbolSection(DataRefImpl Ref,
return std::error_code();
}
unsigned COFFObjectFile::getSymbolSectionID(SymbolRef Sym) const {
COFFSymbolRef Symb = getCOFFSymbol(Sym.getRawDataRefImpl());
return Symb.getSectionNumber();
}
void COFFObjectFile::moveSectionNext(DataRefImpl &Ref) const {
const coff_section *Sec = toSec(Ref);
Sec += 1;
@ -311,6 +316,13 @@ bool COFFObjectFile::isSectionBSS(DataRefImpl Ref) const {
return (Sec->Characteristics & BssFlags) == BssFlags;
}
unsigned COFFObjectFile::getSectionID(SectionRef Sec) const {
uintptr_t Offset =
uintptr_t(Sec.getRawDataRefImpl().p) - uintptr_t(SectionTable);
assert((Offset % sizeof(coff_section)) == 0);
return (Offset / sizeof(coff_section)) + 1;
}
bool COFFObjectFile::isSectionVirtual(DataRefImpl Ref) const {
const coff_section *Sec = toSec(Ref);
// In COFF, a virtual section won't have any in-file