mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 21:55:39 +08:00
[BOLT] Add support for __literal16 section on MachO
Summary: 1. Add support for __literal16 section in the instrumentation runtime library for MacOS. 2. Fix emitting __counters section. (cherry picked from FBD25746342)
This commit is contained in:
committed by
Maksim Panchenko
parent
fea6b4e469
commit
6a84124e1d
@@ -58,8 +58,9 @@ uint8_t *ExecutableFileMemoryManager::allocateSection(intptr_t Size,
|
||||
} else if (BC.isMachO()) {
|
||||
assert((SectionName == "__text" || SectionName == "__data" ||
|
||||
SectionName == "__fini" || SectionName == "__setup" ||
|
||||
SectionName == "__cstring") &&
|
||||
SectionName == "__cstring" || SectionName == "__literal16") &&
|
||||
"Unexpected section in the instrumentation library");
|
||||
// Sections coming from the instrumentation runtime are prefixed with "I".
|
||||
SectionName = ("I" + Twine(SectionName)).toStringRef(Buf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,6 +433,7 @@ void MachORewriteInstance::emitAndLink() {
|
||||
mapInstrumentationSection(Key, "I__data");
|
||||
mapInstrumentationSection(Key, "I__text");
|
||||
mapInstrumentationSection(Key, "I__cstring");
|
||||
mapInstrumentationSection(Key, "I__literal16");
|
||||
}
|
||||
},
|
||||
[&](orc::VModuleKey Key) {
|
||||
@@ -493,6 +494,8 @@ void MachORewriteInstance::rewriteFile() {
|
||||
Function->getImageSize(), Function->getFileOffset());
|
||||
}
|
||||
|
||||
writeInstrumentationSection("__counters", OS);
|
||||
|
||||
// TODO: Refactor addRuntimeLibSections to work properly on Mach-O and
|
||||
// use it here.
|
||||
writeInstrumentationSection("I__setup", OS);
|
||||
@@ -500,6 +503,7 @@ void MachORewriteInstance::rewriteFile() {
|
||||
writeInstrumentationSection("I__data", OS);
|
||||
writeInstrumentationSection("I__text", OS);
|
||||
writeInstrumentationSection("I__cstring", OS);
|
||||
writeInstrumentationSection("I__literal16", OS);
|
||||
|
||||
Out->keep();
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ void InstrumentationRuntimeLibrary::emitBinary(BinaryContext &BC,
|
||||
|
||||
))
|
||||
: static_cast<MCSection *>(BC.Ctx->getMachOSection(
|
||||
"__INSTR", "__counters", MachO::S_REGULAR,
|
||||
"__BOLT", "__counters", MachO::S_REGULAR,
|
||||
SectionKind::getData()));
|
||||
|
||||
// All of the following symbols will be exported as globals to be used by the
|
||||
|
||||
Reference in New Issue
Block a user