forked from OSchip/llvm-project
[BOLT][NFC] Disable ProcessAllSections in RuntimeDyld
Summary: FBD55943 changed the way ProcessAllSections works in RuntimeDyld. After the change, all sections, including symbol table, section table, etc. are loaded into memory whenever ProcessAllSections is enabled. In BOLT we rely on RuntimeDyld for processing sections with relocations. These include most allocatable sections and additionally .debug_line. The latter is skipped by RuntimeDyld without ProcessAllSections flag. If we enable ProcessAllSections, we will have to deal with allocating memory for more sections than we need (see above) and later to filter them out. The alternative is to mark all sections that we actually plan to use as "required for execution" (using RuntimeDyld terminology). For .debug_line section on ELF it means adding SHF_ALLOC flag. On MachO, RuntimeDyld currently treats all sections as required. (cherry picked from FBD28729398)
This commit is contained in:
parent
5a6c379f5b
commit
a26370389a
|
@ -193,6 +193,17 @@ private:
|
|||
void BinaryEmitter::emitAll(StringRef OrgSecPrefix) {
|
||||
Streamer.initSections(false, *BC.STI);
|
||||
|
||||
if (opts::UpdateDebugSections && BC.isELF()) {
|
||||
// Force the emission of debug line info into allocatable section to ensure
|
||||
// RuntimeDyld will process it without ProcessAllSections flag.
|
||||
//
|
||||
// NB: on MachO all sections are required for execution, hence no need
|
||||
// to change flags/attributes.
|
||||
MCSectionELF *ELFDwarfLineSection =
|
||||
static_cast<MCSectionELF *>(BC.MOFI->getDwarfLineSection());
|
||||
ELFDwarfLineSection->setFlags(ELF::SHF_ALLOC);
|
||||
}
|
||||
|
||||
if (RuntimeLibrary *RtLibrary = BC.getRuntimeLibrary()) {
|
||||
RtLibrary->emitBinary(BC, Streamer);
|
||||
}
|
||||
|
|
|
@ -3037,7 +3037,7 @@ void RewriteInstance::emitAndLink() {
|
|||
static_cast<MCObjectStreamer *>(Streamer.get())->getAssembler());
|
||||
|
||||
RTDyld.reset(new decltype(RTDyld)::element_type(*BC->EFMM, Resolver));
|
||||
RTDyld->setProcessAllSections(true);
|
||||
RTDyld->setProcessAllSections(false);
|
||||
RTDyld->loadObject(*Obj);
|
||||
|
||||
// Assign addresses to all sections. If key corresponds to the object
|
||||
|
|
Loading…
Reference in New Issue