本文整理汇总了C++中MCSection::setBeginSymbol方法的典型用法代码示例。如果您正苦于以下问题:C++ MCSection::setBeginSymbol方法的具体用法?C++ MCSection::setBeginSymbol怎么用?C++ MCSection::setBeginSymbol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCSection
的用法示例。
在下文中一共展示了MCSection::setBeginSymbol方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SectionNameStr
extern "C" void SwitchSection(ObjectWriter *OW, const char *SectionName) {
assert(OW && "ObjWriter is null");
auto *AsmPrinter = &OW->getAsmPrinter();
auto &OST = *AsmPrinter->OutStreamer;
MCContext &OutContext = OST.getContext();
const MCObjectFileInfo *MOFI = OutContext.getObjectFileInfo();
MCSection *Section = nullptr;
if (strcmp(SectionName, "text") == 0) {
Section = MOFI->getTextSection();
if (!Section->hasInstructions()) {
Section->setHasInstructions(true);
OutContext.addGenDwarfSection(Section);
}
} else if (strcmp(SectionName, "data") == 0) {
Section = MOFI->getDataSection();
} else if (strcmp(SectionName, "rdata") == 0) {
Section = MOFI->getReadOnlySection();
} else if (strcmp(SectionName, "xdata") == 0) {
Section = MOFI->getXDataSection();
} else {
std::string SectionNameStr(SectionName);
if (OW->CustomSections.find(SectionNameStr) != OW->CustomSections.end()) {
Section = OW->CustomSections[SectionNameStr];
} else {
// Add more general cases
assert(!"Unsupported section");
}
}
OW->Sections.insert(Section);
OST.SwitchSection(Section);
if (!Section->getBeginSymbol()) {
MCSymbol *SectionStartSym = OutContext.createTempSymbol();
OST.EmitLabel(SectionStartSym);
Section->setBeginSymbol(SectionStartSym);
}
}
示例2: ParseSectionArguments
//.........这里部分代码省略.........
MCAsmLexer &L = getLexer();
if (TypeName.empty()) {
if (Mergeable)
return TokError("Mergeable section must specify the type");
if (Group)
return TokError("Group section must specify the type");
if (L.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
}
if (Mergeable)
if (parseMergeSize(Size))
return true;
if (Group)
if (parseGroup(GroupName))
return true;
if (Flags & ELF::SHF_LINK_ORDER)
if (parseMetadataSym(Associated))
return true;
if (maybeParseUniqueID(UniqueID))
return true;
}
EndStmt:
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
Lex();
unsigned Type = ELF::SHT_PROGBITS;
if (TypeName.empty()) {
if (SectionName.startswith(".note"))
Type = ELF::SHT_NOTE;
else if (hasPrefix(SectionName, ".init_array."))
Type = ELF::SHT_INIT_ARRAY;
else if (hasPrefix(SectionName, ".bss."))
Type = ELF::SHT_NOBITS;
else if (hasPrefix(SectionName, ".tbss."))
Type = ELF::SHT_NOBITS;
else if (hasPrefix(SectionName, ".fini_array."))
Type = ELF::SHT_FINI_ARRAY;
else if (hasPrefix(SectionName, ".preinit_array."))
Type = ELF::SHT_PREINIT_ARRAY;
} else {
if (TypeName == "init_array")
Type = ELF::SHT_INIT_ARRAY;
else if (TypeName == "fini_array")
Type = ELF::SHT_FINI_ARRAY;
else if (TypeName == "preinit_array")
Type = ELF::SHT_PREINIT_ARRAY;
else if (TypeName == "nobits")
Type = ELF::SHT_NOBITS;
else if (TypeName == "progbits")
Type = ELF::SHT_PROGBITS;
else if (TypeName == "note")
Type = ELF::SHT_NOTE;
else if (TypeName == "unwind")
Type = ELF::SHT_X86_64_UNWIND;
else if (TypeName == "llvm_odrtab")
Type = ELF::SHT_LLVM_ODRTAB;
else if (TypeName == "llvm_linker_options")
Type = ELF::SHT_LLVM_LINKER_OPTIONS;
else if (TypeName == "llvm_call_graph_profile")
Type = ELF::SHT_LLVM_CALL_GRAPH_PROFILE;
else if (TypeName.getAsInteger(0, Type))
return TokError("unknown section type");
}
if (UseLastGroup) {
MCSectionSubPair CurrentSection = getStreamer().getCurrentSection();
if (const MCSectionELF *Section =
cast_or_null<MCSectionELF>(CurrentSection.first))
if (const MCSymbol *Group = Section->getGroup()) {
GroupName = Group->getName();
Flags |= ELF::SHF_GROUP;
}
}
MCSection *ELFSection =
getContext().getELFSection(SectionName, Type, Flags, Size, GroupName,
UniqueID, Associated);
getStreamer().SwitchSection(ELFSection, Subsection);
if (getContext().getGenDwarfForAssembly()) {
bool InsertResult = getContext().addGenDwarfSection(ELFSection);
if (InsertResult) {
if (getContext().getDwarfVersion() <= 2)
Warning(loc, "DWARF2 only supports one section per compilation unit");
if (!ELFSection->getBeginSymbol()) {
MCSymbol *SectionStartSymbol = getContext().createTempSymbol();
getStreamer().EmitLabel(SectionStartSymbol);
ELFSection->setBeginSymbol(SectionStartSymbol);
}
}
}
return false;
}
示例3: ParseSectionArguments
//.........这里部分代码省略.........
if (Size <= 0)
return TokError("entry size must be positive");
}
if (Group) {
if (getLexer().isNot(AsmToken::Comma))
return TokError("expected group name");
Lex();
if (getParser().parseIdentifier(GroupName))
return true;
if (getLexer().is(AsmToken::Comma)) {
Lex();
StringRef Linkage;
if (getParser().parseIdentifier(Linkage))
return true;
if (Linkage != "comdat")
return TokError("Linkage must be 'comdat'");
}
}
if (getLexer().is(AsmToken::Comma)) {
Lex();
if (getParser().parseIdentifier(UniqueStr))
return TokError("expected identifier in directive");
if (UniqueStr != "unique")
return TokError("expected 'unique'");
if (getLexer().isNot(AsmToken::Comma))
return TokError("expected commma");
Lex();
if (getParser().parseAbsoluteExpression(UniqueID))
return true;
if (UniqueID < 0)
return TokError("unique id must be positive");
if (!isUInt<32>(UniqueID) || UniqueID == ~0U)
return TokError("unique id is too large");
}
}
}
EndStmt:
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
unsigned Type = ELF::SHT_PROGBITS;
if (TypeName.empty()) {
if (SectionName.startswith(".note"))
Type = ELF::SHT_NOTE;
else if (SectionName == ".init_array")
Type = ELF::SHT_INIT_ARRAY;
else if (SectionName == ".fini_array")
Type = ELF::SHT_FINI_ARRAY;
else if (SectionName == ".preinit_array")
Type = ELF::SHT_PREINIT_ARRAY;
} else {
if (TypeName == "init_array")
Type = ELF::SHT_INIT_ARRAY;
else if (TypeName == "fini_array")
Type = ELF::SHT_FINI_ARRAY;
else if (TypeName == "preinit_array")
Type = ELF::SHT_PREINIT_ARRAY;
else if (TypeName == "nobits")
Type = ELF::SHT_NOBITS;
else if (TypeName == "progbits")
Type = ELF::SHT_PROGBITS;
else if (TypeName == "note")
Type = ELF::SHT_NOTE;
else if (TypeName == "unwind")
Type = ELF::SHT_X86_64_UNWIND;
else
return TokError("unknown section type");
}
if (UseLastGroup) {
MCSectionSubPair CurrentSection = getStreamer().getCurrentSection();
if (const MCSectionELF *Section =
cast_or_null<MCSectionELF>(CurrentSection.first))
if (const MCSymbol *Group = Section->getGroup()) {
GroupName = Group->getName();
Flags |= ELF::SHF_GROUP;
}
}
MCSection *ELFSection = getContext().getELFSection(SectionName, Type, Flags,
Size, GroupName, UniqueID);
getStreamer().SwitchSection(ELFSection, Subsection);
if (getContext().getGenDwarfForAssembly()) {
bool InsertResult = getContext().addGenDwarfSection(ELFSection);
if (InsertResult) {
if (getContext().getDwarfVersion() <= 2)
Warning(loc, "DWARF2 only supports one section per compilation unit");
MCSymbol *SectionStartSymbol = getContext().createTempSymbol();
getStreamer().EmitLabel(SectionStartSymbol);
ELFSection->setBeginSymbol(SectionStartSymbol);
}
}
return false;
}