Skip to content

Commit

Permalink
Copy symbol length when we replace a symbol.
Browse files Browse the repository at this point in the history
Symbol's NameSize is computed lazily. Currently, when we replace a symbol,
a cached length value can be discarded. This patch propagates that value.

Differential Revision: https://reviews.llvm.org/D62234

llvm-svn: 361364
  • Loading branch information
rui314 committed May 22, 2019
1 parent 091aaa6 commit ecf6eb5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lld/ELF/Symbols.h
Expand Up @@ -486,6 +486,11 @@ void Symbol::replace(const Symbol &New) {
IsPreemptible = Old.IsPreemptible;
ScriptDefined = Old.ScriptDefined;

// Symbol length is computed lazily. If we already know a symbol length,
// propagate it.
if (NameData == Old.NameData && NameSize == 0 && Old.NameSize != 0)
NameSize = Old.NameSize;

// Print out a log message if --trace-symbol was specified.
// This is for debugging.
if (Traced)
Expand Down

0 comments on commit ecf6eb5

Please sign in to comment.