[BOLT][NFC] Refactor EFMM initialization

Move EFMM initialization code to emitAndLink(), where EFMM is used.

Reviewed By: yavtuk

Differential Revision: https://reviews.llvm.org/D136205
This commit is contained in:
Maksim Panchenko 2022-09-22 13:08:05 -07:00
parent e3df4ba9d2
commit 28d70d3f1e
1 changed files with 8 additions and 8 deletions

View File

@ -407,14 +407,6 @@ Error RewriteInstance::discoverStorage() {
NamedRegionTimer T("discoverStorage", "discover storage", TimerGroupName,
TimerGroupDesc, opts::TimeRewrite);
// Stubs are harmful because RuntimeDyld may try to increase the size of
// sections accounting for stubs when we need those sections to match the
// same size seen in the input binary, in case this section is a copy
// of the original one seen in the binary.
BC->EFMM.reset(new ExecutableFileMemoryManager(*BC, /*AllowStubs*/ false));
BC->EFMM->setNewSecPrefix(getNewSecPrefix());
BC->EFMM->setOrgSecPrefix(getOrgSecPrefix());
auto ELF64LEFile = dyn_cast<ELF64LEObjectFile>(InputFile);
const ELFFile<ELF64LE> &Obj = ELF64LEFile->getELFFile();
@ -3180,6 +3172,14 @@ void RewriteInstance::emitAndLink() {
MCAsmLayout FinalLayout(
static_cast<MCObjectStreamer *>(Streamer.get())->getAssembler());
// Disable stubs because RuntimeDyld may try to increase the size of
// sections accounting for stubs. We need those sections to match the
// same size seen in the input binary, in case this section is a copy
// of the original one seen in the binary.
BC->EFMM.reset(new ExecutableFileMemoryManager(*BC, /*AllowStubs=*/false));
BC->EFMM->setNewSecPrefix(getNewSecPrefix());
BC->EFMM->setOrgSecPrefix(getOrgSecPrefix());
RTDyld.reset(new decltype(RTDyld)::element_type(*BC->EFMM, Resolver));
RTDyld->setProcessAllSections(false);
RTDyld->loadObject(*Obj);