From ecf6eb515fccc46e4f8a13f27919e2c9ec394a21 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 22 May 2019 09:19:30 +0000 Subject: [PATCH] Copy symbol length when we replace a symbol. 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 --- lld/ELF/Symbols.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index 940767ea09e0..a2b904f057d5 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -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)