Changeset View
Changeset View
Standalone View
Standalone View
lld/ELF/Driver.cpp
Show First 20 Lines • Show All 2,190 Lines • ▼ Show 20 Lines | Symbol *wrap = | ||||
addUnusedUndefined(saver().save("__wrap_" + name), sym->binding); | addUnusedUndefined(saver().save("__wrap_" + name), sym->binding); | ||||
v.push_back({sym, real, wrap}); | v.push_back({sym, real, wrap}); | ||||
// We want to tell LTO not to inline symbols to be overwritten | // We want to tell LTO not to inline symbols to be overwritten | ||||
// because LTO doesn't know the final symbol contents after renaming. | // because LTO doesn't know the final symbol contents after renaming. | ||||
real->scriptDefined = true; | real->scriptDefined = true; | ||||
sym->scriptDefined = true; | sym->scriptDefined = true; | ||||
// Tell LTO not to eliminate these symbols. | // If a symbol is referenced in any object file, bitcode file or shared | ||||
sym->isUsedInRegularObj = true; | // object, mark its redirection target (foo for __real_foo and __wrap_foo | ||||
// If sym is referenced in any object file, bitcode file or shared object, | // for foo) as referenced after redirection, which will be used to tell LTO | ||||
// retain wrap which is the redirection target of sym. If the object file | // to not eliminate the redirection target. If the object file defining the | ||||
// defining sym has sym references, we cannot easily distinguish the case | // symbol also references it, we cannot easily distinguish the case from | ||||
// from cases where sym is not referenced. Retain wrap because we choose to | // cases where the symbol is not referenced. Retain the redirection target | ||||
// wrap sym references regardless of whether sym is defined | // in this case because we choose to wrap symbol references regardless of | ||||
// whether the symbol is defined | |||||
// (https://sourceware.org/bugzilla/show_bug.cgi?id=26358). | // (https://sourceware.org/bugzilla/show_bug.cgi?id=26358). | ||||
if (real->referenced || real->isDefined()) | |||||
sym->referencedAfterWrap = true; | |||||
if (sym->referenced || sym->isDefined()) | if (sym->referenced || sym->isDefined()) | ||||
wrap->isUsedInRegularObj = true; | wrap->referencedAfterWrap = true; | ||||
} | } | ||||
return v; | return v; | ||||
} | } | ||||
// Do renaming for --wrap and foo@v1 by updating pointers to symbols. | // Do renaming for --wrap and foo@v1 by updating pointers to symbols. | ||||
// | // | ||||
// When this function is executed, only InputFiles and symbol table | // When this function is executed, only InputFiles and symbol table | ||||
// contain pointers to symbol objects. We visit them to replace pointers, | // contain pointers to symbol objects. We visit them to replace pointers, | ||||
▲ Show 20 Lines • Show All 551 Lines • Show Last 20 Lines |