本文整理汇总了C++中COFFSymbolRef::getNumberOfAuxSymbols方法的典型用法代码示例。如果您正苦于以下问题:C++ COFFSymbolRef::getNumberOfAuxSymbols方法的具体用法?C++ COFFSymbolRef::getNumberOfAuxSymbols怎么用?C++ COFFSymbolRef::getNumberOfAuxSymbols使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COFFSymbolRef
的用法示例。
在下文中一共展示了COFFSymbolRef::getNumberOfAuxSymbols方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeArrayRef
ArrayRef<uint8_t>
COFFObjectFile::getSymbolAuxData(COFFSymbolRef Symbol) const {
const uint8_t *Aux = nullptr;
size_t SymbolSize = getSymbolTableEntrySize();
if (Symbol.getNumberOfAuxSymbols() > 0) {
// AUX data comes immediately after the symbol in COFF
Aux = reinterpret_cast<const uint8_t *>(Symbol.getRawPtr()) + SymbolSize;
# ifndef NDEBUG
// Verify that the Aux symbol points to a valid entry in the symbol table.
uintptr_t Offset = uintptr_t(Aux) - uintptr_t(base());
if (Offset < getPointerToSymbolTable() ||
Offset >=
getPointerToSymbolTable() + (getNumberOfSymbols() * SymbolSize))
report_fatal_error("Aux Symbol data was outside of symbol table.");
assert((Offset - getPointerToSymbolTable()) % SymbolSize == 0 &&
"Aux Symbol data did not point to the beginning of a symbol");
# endif
}
return makeArrayRef(Aux, Symbol.getNumberOfAuxSymbols() * SymbolSize);
}
示例2: initializeSymbols
void ObjectFile::initializeSymbols() {
uint32_t NumSymbols = COFFObj->getNumberOfSymbols();
SymbolBodies.reserve(NumSymbols);
SparseSymbolBodies.resize(NumSymbols);
llvm::SmallVector<std::pair<Undefined *, uint32_t>, 8> WeakAliases;
int32_t LastSectionNumber = 0;
for (uint32_t I = 0; I < NumSymbols; ++I) {
// Get a COFFSymbolRef object.
auto SymOrErr = COFFObj->getSymbol(I);
error(SymOrErr, Twine("broken object file: ") + getName());
COFFSymbolRef Sym = *SymOrErr;
const void *AuxP = nullptr;
if (Sym.getNumberOfAuxSymbols())
AuxP = COFFObj->getSymbol(I + 1)->getRawPtr();
bool IsFirst = (LastSectionNumber != Sym.getSectionNumber());
SymbolBody *Body = nullptr;
if (Sym.isUndefined()) {
Body = createUndefined(Sym);
} else if (Sym.isWeakExternal()) {
Body = createUndefined(Sym);
uint32_t TagIndex =
static_cast<const coff_aux_weak_external *>(AuxP)->TagIndex;
WeakAliases.emplace_back((Undefined *)Body, TagIndex);
} else {
Body = createDefined(Sym, AuxP, IsFirst);
}
if (Body) {
SymbolBodies.push_back(Body);
SparseSymbolBodies[I] = Body;
}
I += Sym.getNumberOfAuxSymbols();
LastSectionNumber = Sym.getSectionNumber();
}
for (auto WeakAlias : WeakAliases)
WeakAlias.first->WeakAlias = SparseSymbolBodies[WeakAlias.second];
}
示例3: initializeSymbols
void ObjectFile::initializeSymbols() {
uint32_t NumSymbols = COFFObj->getNumberOfSymbols();
SymbolBodies.reserve(NumSymbols);
SparseSymbolBodies.resize(NumSymbols);
llvm::SmallVector<Undefined *, 8> WeakAliases;
int32_t LastSectionNumber = 0;
for (uint32_t I = 0; I < NumSymbols; ++I) {
// Get a COFFSymbolRef object.
auto SymOrErr = COFFObj->getSymbol(I);
error(SymOrErr, Twine("broken object file: ") + getName());
COFFSymbolRef Sym = *SymOrErr;
const void *AuxP = nullptr;
if (Sym.getNumberOfAuxSymbols())
AuxP = COFFObj->getSymbol(I + 1)->getRawPtr();
bool IsFirst = (LastSectionNumber != Sym.getSectionNumber());
SymbolBody *Body = nullptr;
if (Sym.isUndefined()) {
Body = createUndefined(Sym);
} else if (Sym.isWeakExternal()) {
Body = createWeakExternal(Sym, AuxP);
WeakAliases.push_back((Undefined *)Body);
} else {
Body = createDefined(Sym, AuxP, IsFirst);
}
if (Body) {
SymbolBodies.push_back(Body);
SparseSymbolBodies[I] = Body;
}
I += Sym.getNumberOfAuxSymbols();
LastSectionNumber = Sym.getSectionNumber();
}
for (Undefined *U : WeakAliases)
U->WeakAlias = SparseSymbolBodies[(uintptr_t)U->WeakAlias];
}
示例4: printSymbol
void COFFDumper::printSymbol(const SymbolRef &Sym) {
DictScope D(W, "Symbol");
COFFSymbolRef Symbol = Obj->getCOFFSymbol(Sym);
const coff_section *Section;
if (std::error_code EC = Obj->getSection(Symbol.getSectionNumber(), Section)) {
W.startLine() << "Invalid section number: " << EC.message() << "\n";
W.flush();
return;
}
StringRef SymbolName;
if (Obj->getSymbolName(Symbol, SymbolName))
SymbolName = "";
StringRef SectionName = "";
ErrorOr<StringRef> Res =
getSectionName(Obj, Symbol.getSectionNumber(), Section);
if (Res)
SectionName = *Res;
W.printString("Name", SymbolName);
W.printNumber("Value", Symbol.getValue());
W.printNumber("Section", SectionName, Symbol.getSectionNumber());
W.printEnum ("BaseType", Symbol.getBaseType(), makeArrayRef(ImageSymType));
W.printEnum ("ComplexType", Symbol.getComplexType(),
makeArrayRef(ImageSymDType));
W.printEnum ("StorageClass", Symbol.getStorageClass(),
makeArrayRef(ImageSymClass));
W.printNumber("AuxSymbolCount", Symbol.getNumberOfAuxSymbols());
for (uint8_t I = 0; I < Symbol.getNumberOfAuxSymbols(); ++I) {
if (Symbol.isFunctionDefinition()) {
const coff_aux_function_definition *Aux;
error(getSymbolAuxData(Obj, Symbol, I, Aux));
DictScope AS(W, "AuxFunctionDef");
W.printNumber("TagIndex", Aux->TagIndex);
W.printNumber("TotalSize", Aux->TotalSize);
W.printHex("PointerToLineNumber", Aux->PointerToLinenumber);
W.printHex("PointerToNextFunction", Aux->PointerToNextFunction);
} else if (Symbol.isAnyUndefined()) {
const coff_aux_weak_external *Aux;
error(getSymbolAuxData(Obj, Symbol, I, Aux));
ErrorOr<COFFSymbolRef> Linked = Obj->getSymbol(Aux->TagIndex);
StringRef LinkedName;
std::error_code EC = Linked.getError();
if (EC || (EC = Obj->getSymbolName(*Linked, LinkedName))) {
LinkedName = "";
error(EC);
}
DictScope AS(W, "AuxWeakExternal");
W.printNumber("Linked", LinkedName, Aux->TagIndex);
W.printEnum ("Search", Aux->Characteristics,
makeArrayRef(WeakExternalCharacteristics));
} else if (Symbol.isFileRecord()) {
const char *FileName;
error(getSymbolAuxData(Obj, Symbol, I, FileName));
DictScope AS(W, "AuxFileRecord");
StringRef Name(FileName, Symbol.getNumberOfAuxSymbols() *
Obj->getSymbolTableEntrySize());
W.printString("FileName", Name.rtrim(StringRef("\0", 1)));
break;
} else if (Symbol.isSectionDefinition()) {
const coff_aux_section_definition *Aux;
error(getSymbolAuxData(Obj, Symbol, I, Aux));
int32_t AuxNumber = Aux->getNumber(Symbol.isBigObj());
DictScope AS(W, "AuxSectionDef");
W.printNumber("Length", Aux->Length);
W.printNumber("RelocationCount", Aux->NumberOfRelocations);
W.printNumber("LineNumberCount", Aux->NumberOfLinenumbers);
W.printHex("Checksum", Aux->CheckSum);
W.printNumber("Number", AuxNumber);
W.printEnum("Selection", Aux->Selection, makeArrayRef(ImageCOMDATSelect));
if (Section && Section->Characteristics & COFF::IMAGE_SCN_LNK_COMDAT
&& Aux->Selection == COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE) {
const coff_section *Assoc;
StringRef AssocName = "";
std::error_code EC = Obj->getSection(AuxNumber, Assoc);
ErrorOr<StringRef> Res = getSectionName(Obj, AuxNumber, Assoc);
if (Res)
AssocName = *Res;
if (!EC)
EC = Res.getError();
if (EC) {
AssocName = "";
error(EC);
}
W.printNumber("AssocSection", AssocName, AuxNumber);
}
//.........这里部分代码省略.........