void postProcess(TransRelocInfo&& tri, void* paramPtr) { auto& param = *static_cast<PostProcessParam*>(paramPtr); auto& rel = param.rel; auto& deadStubs = param.deadStubs; auto relocMap = param.relocMap; if (!rel.adjustedAddressAfter(tri.start)) { x64::adjustForRelocation(rel, tri.start, tri.end); auto coldStart = tri.coldStart; if (&mcg->code.blockFor(coldStart) == &mcg->code.realFrozen()) { /* * This is a bit silly. If we were generating code into frozen, * and we also put stubs in frozen, and those stubs are now dead * the code in them isn't valid (we smashed the first few bytes * with a pointer and a size; see FreeStubList::StubNode). * So skip over any of those. Its ok to process the live ones * more than once. */ auto it = deadStubs.lower_bound(tri.coldStart); while (it != deadStubs.end() && *it < tri.coldEnd) { x64::adjustForRelocation(rel, coldStart, *it); coldStart = *it + svcreq::stub_size(); ++it; } } x64::adjustForRelocation(rel, coldStart, tri.coldEnd); } auto adjustAfter = [&rel](TCA& addr) { if (auto adj = rel.adjustedAddressAfter(addr)) addr = adj; }; auto adjustBefore = [&rel](TCA& addr) { if (auto adj = rel.adjustedAddressBefore(addr)) addr = adj; }; adjustAfter(tri.start); adjustBefore(tri.end); adjustAfter(tri.coldStart); adjustBefore(tri.coldEnd); for (auto& ib : tri.incomingBranches) { if (auto adjusted = rel.adjustedAddressAfter(ib.toSmash())) { ib.adjust(adjusted); } } x64::adjustMetaDataForRelocation(rel, nullptr, tri.fixups); auto data = perfRelocMapInfo( tri.start, tri.end, tri.coldStart, tri.coldEnd, tri.sk, tri.argNum, tri.incomingBranches, tri.fixups ); fprintf(relocMap, "%" PRIxPTR " %" PRIxPTR " %s\n", intptr_t(tri.start), intptr_t(tri.end), data.c_str()); }
void recordPerfRelocMap( TCA start, TCA end, TCA coldStart, TCA coldEnd, SrcKey sk, int argNum, const GrowableVector<IncomingBranch> &incomingBranchesIn, CGMeta& fixups) { auto info = perfRelocMapInfo(start, end, coldStart, coldEnd, sk, argNum, incomingBranchesIn, fixups); Debug::DebugInfo::Get()->recordRelocMap(start, end, info); }