Closed CcWeapon closed 1 year ago
Sorry, missed that earlier. Yes, you are right that GOT will not get updated in this case. What application were you trying to optimize?
We try to replace getBinaryFunctionAtAddress() with getBinaryFunctionContainingAddress() in func getNewFunctionAddress().
uint64_t RewriteInstance::getNewFunctionAddress(uint64_t OldAddress) {
const BinaryFunction *Function = BC->getBinaryFunctionContainingAddress(OldAddress);
if (!Function)
return 0;
assert(!Function->isFragment() && "cannot get new address for a fragment");
auto MultientryOffset = BC->getMultientryOffsets().find(OldAddress);
if (MultientryOffset == BC->getMultientryOffsets().end()) {
return Function->getOutputAddress();
} else {
return Function->getOutputAddress() + MultientryOffset->second;
}
}
Sounds like you fixed it in your fork?
Yes, func getBinaryFunctionContainingAddress() is used to solve the problem.
Hello. I found that when BOLT updates the got table, only the main entry and the first secondary entry of the function are updated. The .got tables of other secondary entries of the function are not updated. Why is that so? Is it correct that all symbols in the .got table should be updated?
Problem Analysis
When bolt updates .got, it will use function getBinaryFunctionAtAddress(). The return value is determined by BF and EntryID.
then in func getFunctionForSymbol(), EntryID is determined by getEntryIDForSymbol(). getEntryIDForSymbol() indicates that the return value is 0 only when the symbol is the primary entry of the function or the first secondary entry. This means that EntryID will not be 0, and the return value of getBinaryFunctionAtAddress will be nullptr. Symbols for other secondary entries will not be updated in the .got table