[BOLT] Emit ICF symbols for large functions

Summary:
In non-relocation mode, make sure we emit extra symbols for a folded
function even if the function was not overwritten due to its large
size.

(cherry picked from FBD21080467)
This commit is contained in:
Maksim Panchenko 2020-04-16 00:05:01 -07:00
parent 606532bdf1
commit 10245b5c5b
1 changed files with 9 additions and 7 deletions

View File

@ -3800,17 +3800,19 @@ void RewriteInstance::updateELFSymbolTable(
// Create a new symbol based on the existing symbol.
auto NewSymbol = Symbol;
// If the symbol matched a function that was not emitted, leave the
// symbol unchanged.
if (Function && Function->isEmitted()) {
NewSymbol.st_value = Function->getOutputAddress();
NewSymbol.st_size = Function->getOutputSize();
NewSymbol.st_shndx = Function->getCodeSection()->getIndex();
if (Function) {
// If the symbol matched a function that was not emitted, leave the
// symbol unchanged.
if (Function->isEmitted()) {
NewSymbol.st_value = Function->getOutputAddress();
NewSymbol.st_size = Function->getOutputSize();
NewSymbol.st_shndx = Function->getCodeSection()->getIndex();
}
// Add new symbols to the symbol table if necessary.
if (!PatchExisting)
addExtraSymbols(*Function, NewSymbol);
} else if (!Function) {
} else {
// Check if the function symbol matches address inside a function, i.e.
// it marks a secondary entry point.
Function = (Symbol.getType() == ELF::STT_FUNC)