xref: /llvm-project-15.0.7/lld/ELF/Symbols.cpp (revision 8a42bf24)
1 //===- Symbols.cpp --------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "Symbols.h"
10 #include "InputFiles.h"
11 #include "InputSection.h"
12 #include "OutputSections.h"
13 #include "SyntheticSections.h"
14 #include "Target.h"
15 #include "Writer.h"
16 #include "lld/Common/ErrorHandler.h"
17 #include "lld/Common/Strings.h"
18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/Support/Path.h"
20 #include <cstring>
21 
22 using namespace llvm;
23 using namespace llvm::object;
24 using namespace llvm::ELF;
25 
26 namespace lld {
27 // Returns a symbol for an error message.
28 static std::string demangle(StringRef symName) {
29   if (elf::config->demangle)
30     return demangleItanium(symName);
31   return std::string(symName);
32 }
33 
34 std::string toString(const elf::Symbol &sym) {
35   StringRef name = sym.getName();
36   std::string ret = demangle(name);
37 
38   // If sym has a non-default version, its name may have been truncated at '@'
39   // by Symbol::parseSymbolVersion(). Add the trailing part. This check is safe
40   // because every symbol name ends with '\0'.
41   if (name.data()[name.size()] == '@')
42     ret += name.data() + name.size();
43   return ret;
44 }
45 
46 std::string toELFString(const Archive::Symbol &b) {
47   return demangle(b.getName());
48 }
49 
50 namespace elf {
51 Defined *ElfSym::bss;
52 Defined *ElfSym::etext1;
53 Defined *ElfSym::etext2;
54 Defined *ElfSym::edata1;
55 Defined *ElfSym::edata2;
56 Defined *ElfSym::end1;
57 Defined *ElfSym::end2;
58 Defined *ElfSym::globalOffsetTable;
59 Defined *ElfSym::mipsGp;
60 Defined *ElfSym::mipsGpDisp;
61 Defined *ElfSym::mipsLocalGp;
62 Defined *ElfSym::relaIpltStart;
63 Defined *ElfSym::relaIpltEnd;
64 Defined *ElfSym::riscvGlobalPointer;
65 Defined *ElfSym::tlsModuleBase;
66 
67 static uint64_t getSymVA(const Symbol &sym, int64_t &addend) {
68   switch (sym.kind()) {
69   case Symbol::DefinedKind: {
70     auto &d = cast<Defined>(sym);
71     SectionBase *isec = d.section;
72 
73     // This is an absolute symbol.
74     if (!isec)
75       return d.value;
76 
77     assert(isec != &InputSection::discarded);
78     isec = isec->repl;
79 
80     uint64_t offset = d.value;
81 
82     // An object in an SHF_MERGE section might be referenced via a
83     // section symbol (as a hack for reducing the number of local
84     // symbols).
85     // Depending on the addend, the reference via a section symbol
86     // refers to a different object in the merge section.
87     // Since the objects in the merge section are not necessarily
88     // contiguous in the output, the addend can thus affect the final
89     // VA in a non-linear way.
90     // To make this work, we incorporate the addend into the section
91     // offset (and zero out the addend for later processing) so that
92     // we find the right object in the section.
93     if (d.isSection()) {
94       offset += addend;
95       addend = 0;
96     }
97 
98     // In the typical case, this is actually very simple and boils
99     // down to adding together 3 numbers:
100     // 1. The address of the output section.
101     // 2. The offset of the input section within the output section.
102     // 3. The offset within the input section (this addition happens
103     //    inside InputSection::getOffset).
104     //
105     // If you understand the data structures involved with this next
106     // line (and how they get built), then you have a pretty good
107     // understanding of the linker.
108     uint64_t va = isec->getVA(offset);
109 
110     // MIPS relocatable files can mix regular and microMIPS code.
111     // Linker needs to distinguish such code. To do so microMIPS
112     // symbols has the `STO_MIPS_MICROMIPS` flag in the `st_other`
113     // field. Unfortunately, the `MIPS::relocate()` method has
114     // a symbol value only. To pass type of the symbol (regular/microMIPS)
115     // to that routine as well as other places where we write
116     // a symbol value as-is (.dynamic section, `Elf_Ehdr::e_entry`
117     // field etc) do the same trick as compiler uses to mark microMIPS
118     // for CPU - set the less-significant bit.
119     if (config->emachine == EM_MIPS && isMicroMips() &&
120         ((sym.stOther & STO_MIPS_MICROMIPS) || sym.needsPltAddr))
121       va |= 1;
122 
123     if (d.isTls() && !config->relocatable) {
124       // Use the address of the TLS segment's first section rather than the
125       // segment's address, because segment addresses aren't initialized until
126       // after sections are finalized. (e.g. Measuring the size of .rela.dyn
127       // for Android relocation packing requires knowing TLS symbol addresses
128       // during section finalization.)
129       if (!Out::tlsPhdr || !Out::tlsPhdr->firstSec)
130         fatal(toString(d.file) +
131               " has an STT_TLS symbol but doesn't have an SHF_TLS section");
132       return va - Out::tlsPhdr->firstSec->addr;
133     }
134     return va;
135   }
136   case Symbol::SharedKind:
137   case Symbol::UndefinedKind:
138     return 0;
139   case Symbol::LazyArchiveKind:
140   case Symbol::LazyObjectKind:
141     assert(sym.isUsedInRegularObj && "lazy symbol reached writer");
142     return 0;
143   case Symbol::CommonKind:
144     llvm_unreachable("common symbol reached writer");
145   case Symbol::PlaceholderKind:
146     llvm_unreachable("placeholder symbol reached writer");
147   }
148   llvm_unreachable("invalid symbol kind");
149 }
150 
151 uint64_t Symbol::getVA(int64_t addend) const {
152   uint64_t outVA = getSymVA(*this, addend);
153   return outVA + addend;
154 }
155 
156 uint64_t Symbol::getGotVA() const {
157   if (gotInIgot)
158     return in.igotPlt->getVA() + getGotPltOffset();
159   return in.got->getVA() + getGotOffset();
160 }
161 
162 uint64_t Symbol::getGotOffset() const { return gotIndex * config->wordsize; }
163 
164 uint64_t Symbol::getGotPltVA() const {
165   if (isInIplt)
166     return in.igotPlt->getVA() + getGotPltOffset();
167   return in.gotPlt->getVA() + getGotPltOffset();
168 }
169 
170 uint64_t Symbol::getGotPltOffset() const {
171   if (isInIplt)
172     return pltIndex * config->wordsize;
173   return (pltIndex + target->gotPltHeaderEntriesNum) * config->wordsize;
174 }
175 
176 uint64_t Symbol::getPltVA() const {
177   uint64_t outVA = isInIplt
178                        ? in.iplt->getVA() + pltIndex * target->ipltEntrySize
179                        : in.plt->getVA() + in.plt->headerSize +
180                              pltIndex * target->pltEntrySize;
181 
182   // While linking microMIPS code PLT code are always microMIPS
183   // code. Set the less-significant bit to track that fact.
184   // See detailed comment in the `getSymVA` function.
185   if (config->emachine == EM_MIPS && isMicroMips())
186     outVA |= 1;
187   return outVA;
188 }
189 
190 uint64_t Symbol::getSize() const {
191   if (const auto *dr = dyn_cast<Defined>(this))
192     return dr->size;
193   return cast<SharedSymbol>(this)->size;
194 }
195 
196 OutputSection *Symbol::getOutputSection() const {
197   if (auto *s = dyn_cast<Defined>(this)) {
198     if (auto *sec = s->section)
199       return sec->repl->getOutputSection();
200     return nullptr;
201   }
202   return nullptr;
203 }
204 
205 // If a symbol name contains '@', the characters after that is
206 // a symbol version name. This function parses that.
207 void Symbol::parseSymbolVersion() {
208   StringRef s = getName();
209   size_t pos = s.find('@');
210   if (pos == 0 || pos == StringRef::npos)
211     return;
212   StringRef verstr = s.substr(pos + 1);
213   if (verstr.empty())
214     return;
215 
216   // Truncate the symbol name so that it doesn't include the version string.
217   nameSize = pos;
218 
219   // If this is not in this DSO, it is not a definition.
220   if (!isDefined())
221     return;
222 
223   // '@@' in a symbol name means the default version.
224   // It is usually the most recent one.
225   bool isDefault = (verstr[0] == '@');
226   if (isDefault)
227     verstr = verstr.substr(1);
228 
229   for (const VersionDefinition &ver : namedVersionDefs()) {
230     if (ver.name != verstr)
231       continue;
232 
233     if (isDefault)
234       versionId = ver.id;
235     else
236       versionId = ver.id | VERSYM_HIDDEN;
237     return;
238   }
239 
240   // It is an error if the specified version is not defined.
241   // Usually version script is not provided when linking executable,
242   // but we may still want to override a versioned symbol from DSO,
243   // so we do not report error in this case. We also do not error
244   // if the symbol has a local version as it won't be in the dynamic
245   // symbol table.
246   if (config->shared && versionId != VER_NDX_LOCAL)
247     error(toString(file) + ": symbol " + s + " has undefined version " +
248           verstr);
249 }
250 
251 void Symbol::fetch() const {
252   if (auto *sym = dyn_cast<LazyArchive>(this)) {
253     cast<ArchiveFile>(sym->file)->fetch(sym->sym);
254     return;
255   }
256 
257   if (auto *sym = dyn_cast<LazyObject>(this)) {
258     dyn_cast<LazyObjFile>(sym->file)->fetch();
259     return;
260   }
261 
262   llvm_unreachable("Symbol::fetch() is called on a non-lazy symbol");
263 }
264 
265 MemoryBufferRef LazyArchive::getMemberBuffer() {
266   Archive::Child c =
267       CHECK(sym.getMember(),
268             "could not get the member for symbol " + toELFString(sym));
269 
270   return CHECK(c.getMemoryBufferRef(),
271                "could not get the buffer for the member defining symbol " +
272                    toELFString(sym));
273 }
274 
275 uint8_t Symbol::computeBinding() const {
276   if (config->relocatable)
277     return binding;
278   if ((visibility != STV_DEFAULT && visibility != STV_PROTECTED) ||
279       (versionId == VER_NDX_LOCAL && isDefined()))
280     return STB_LOCAL;
281   if (!config->gnuUnique && binding == STB_GNU_UNIQUE)
282     return STB_GLOBAL;
283   return binding;
284 }
285 
286 bool Symbol::includeInDynsym() const {
287   if (!config->hasDynSymTab)
288     return false;
289   if (computeBinding() == STB_LOCAL)
290     return false;
291   if (!isDefined() && !isCommon())
292     // This should unconditionally return true, unfortunately glibc -static-pie
293     // expects undefined weak symbols not to exist in .dynsym, e.g.
294     // __pthread_mutex_lock reference in _dl_add_to_namespace_list,
295     // __pthread_initialize_minimal reference in csu/libc-start.c.
296     return !(config->noDynamicLinker && isUndefWeak());
297 
298   return exportDynamic || inDynamicList;
299 }
300 
301 // Print out a log message for --trace-symbol.
302 void printTraceSymbol(const Symbol *sym) {
303   std::string s;
304   if (sym->isUndefined())
305     s = ": reference to ";
306   else if (sym->isLazy())
307     s = ": lazy definition of ";
308   else if (sym->isShared())
309     s = ": shared definition of ";
310   else if (sym->isCommon())
311     s = ": common definition of ";
312   else
313     s = ": definition of ";
314 
315   message(toString(sym->file) + s + sym->getName());
316 }
317 
318 void maybeWarnUnorderableSymbol(const Symbol *sym) {
319   if (!config->warnSymbolOrdering)
320     return;
321 
322   // If UnresolvedPolicy::Ignore is used, no "undefined symbol" error/warning
323   // is emitted. It makes sense to not warn on undefined symbols.
324   //
325   // Note, ld.bfd --symbol-ordering-file= does not warn on undefined symbols,
326   // but we don't have to be compatible here.
327   if (sym->isUndefined() &&
328       config->unresolvedSymbols == UnresolvedPolicy::Ignore)
329     return;
330 
331   const InputFile *file = sym->file;
332   auto *d = dyn_cast<Defined>(sym);
333 
334   auto report = [&](StringRef s) { warn(toString(file) + s + sym->getName()); };
335 
336   if (sym->isUndefined())
337     report(": unable to order undefined symbol: ");
338   else if (sym->isShared())
339     report(": unable to order shared symbol: ");
340   else if (d && !d->section)
341     report(": unable to order absolute symbol: ");
342   else if (d && isa<OutputSection>(d->section))
343     report(": unable to order synthetic symbol: ");
344   else if (d && !d->section->repl->isLive())
345     report(": unable to order discarded symbol: ");
346 }
347 
348 // Returns true if a symbol can be replaced at load-time by a symbol
349 // with the same name defined in other ELF executable or DSO.
350 bool computeIsPreemptible(const Symbol &sym) {
351   assert(!sym.isLocal());
352 
353   // Only symbols with default visibility that appear in dynsym can be
354   // preempted. Symbols with protected visibility cannot be preempted.
355   if (!sym.includeInDynsym() || sym.visibility != STV_DEFAULT)
356     return false;
357 
358   // At this point copy relocations have not been created yet, so any
359   // symbol that is not defined locally is preemptible.
360   if (!sym.isDefined())
361     return true;
362 
363   if (!config->shared)
364     return false;
365 
366   // If the dynamic list is present, it specifies preemptable symbols in a DSO.
367   if (config->hasDynamicList)
368     return sym.inDynamicList;
369 
370   // -Bsymbolic means that definitions are not preempted.
371   if (config->bsymbolic || (config->bsymbolicFunctions && sym.isFunc()))
372     return false;
373   return true;
374 }
375 
376 static uint8_t getMinVisibility(uint8_t va, uint8_t vb) {
377   if (va == STV_DEFAULT)
378     return vb;
379   if (vb == STV_DEFAULT)
380     return va;
381   return std::min(va, vb);
382 }
383 
384 // Merge symbol properties.
385 //
386 // When we have many symbols of the same name, we choose one of them,
387 // and that's the result of symbol resolution. However, symbols that
388 // were not chosen still affect some symbol properties.
389 void Symbol::mergeProperties(const Symbol &other) {
390   if (other.exportDynamic)
391     exportDynamic = true;
392   if (other.isUsedInRegularObj)
393     isUsedInRegularObj = true;
394 
395   // DSO symbols do not affect visibility in the output.
396   if (!other.isShared())
397     visibility = getMinVisibility(visibility, other.visibility);
398 }
399 
400 void Symbol::resolve(const Symbol &other) {
401   mergeProperties(other);
402 
403   if (isPlaceholder()) {
404     replace(other);
405     return;
406   }
407 
408   switch (other.kind()) {
409   case Symbol::UndefinedKind:
410     resolveUndefined(cast<Undefined>(other));
411     break;
412   case Symbol::CommonKind:
413     resolveCommon(cast<CommonSymbol>(other));
414     break;
415   case Symbol::DefinedKind:
416     resolveDefined(cast<Defined>(other));
417     break;
418   case Symbol::LazyArchiveKind:
419     resolveLazy(cast<LazyArchive>(other));
420     break;
421   case Symbol::LazyObjectKind:
422     resolveLazy(cast<LazyObject>(other));
423     break;
424   case Symbol::SharedKind:
425     resolveShared(cast<SharedSymbol>(other));
426     break;
427   case Symbol::PlaceholderKind:
428     llvm_unreachable("bad symbol kind");
429   }
430 }
431 
432 void Symbol::resolveUndefined(const Undefined &other) {
433   // An undefined symbol with non default visibility must be satisfied
434   // in the same DSO.
435   //
436   // If this is a non-weak defined symbol in a discarded section, override the
437   // existing undefined symbol for better error message later.
438   if ((isShared() && other.visibility != STV_DEFAULT) ||
439       (isUndefined() && other.binding != STB_WEAK && other.discardedSecIdx)) {
440     replace(other);
441     return;
442   }
443 
444   if (traced)
445     printTraceSymbol(&other);
446 
447   if (isLazy()) {
448     // An undefined weak will not fetch archive members. See comment on Lazy in
449     // Symbols.h for the details.
450     if (other.binding == STB_WEAK) {
451       binding = STB_WEAK;
452       type = other.type;
453       return;
454     }
455 
456     // Do extra check for --warn-backrefs.
457     //
458     // --warn-backrefs is an option to prevent an undefined reference from
459     // fetching an archive member written earlier in the command line. It can be
460     // used to keep compatibility with GNU linkers to some degree.
461     // I'll explain the feature and why you may find it useful in this comment.
462     //
463     // lld's symbol resolution semantics is more relaxed than traditional Unix
464     // linkers. For example,
465     //
466     //   ld.lld foo.a bar.o
467     //
468     // succeeds even if bar.o contains an undefined symbol that has to be
469     // resolved by some object file in foo.a. Traditional Unix linkers don't
470     // allow this kind of backward reference, as they visit each file only once
471     // from left to right in the command line while resolving all undefined
472     // symbols at the moment of visiting.
473     //
474     // In the above case, since there's no undefined symbol when a linker visits
475     // foo.a, no files are pulled out from foo.a, and because the linker forgets
476     // about foo.a after visiting, it can't resolve undefined symbols in bar.o
477     // that could have been resolved otherwise.
478     //
479     // That lld accepts more relaxed form means that (besides it'd make more
480     // sense) you can accidentally write a command line or a build file that
481     // works only with lld, even if you have a plan to distribute it to wider
482     // users who may be using GNU linkers. With --warn-backrefs, you can detect
483     // a library order that doesn't work with other Unix linkers.
484     //
485     // The option is also useful to detect cyclic dependencies between static
486     // archives. Again, lld accepts
487     //
488     //   ld.lld foo.a bar.a
489     //
490     // even if foo.a and bar.a depend on each other. With --warn-backrefs, it is
491     // handled as an error.
492     //
493     // Here is how the option works. We assign a group ID to each file. A file
494     // with a smaller group ID can pull out object files from an archive file
495     // with an equal or greater group ID. Otherwise, it is a reverse dependency
496     // and an error.
497     //
498     // A file outside --{start,end}-group gets a fresh ID when instantiated. All
499     // files within the same --{start,end}-group get the same group ID. E.g.
500     //
501     //   ld.lld A B --start-group C D --end-group E
502     //
503     // A forms group 0. B form group 1. C and D (including their member object
504     // files) form group 2. E forms group 3. I think that you can see how this
505     // group assignment rule simulates the traditional linker's semantics.
506     bool backref = config->warnBackrefs && other.file &&
507                    file->groupId < other.file->groupId;
508     fetch();
509 
510     // We don't report backward references to weak symbols as they can be
511     // overridden later.
512     if (backref && !isWeak())
513       warn("backward reference detected: " + other.getName() + " in " +
514            toString(other.file) + " refers to " + toString(file));
515     return;
516   }
517 
518   // Undefined symbols in a SharedFile do not change the binding.
519   if (dyn_cast_or_null<SharedFile>(other.file))
520     return;
521 
522   if (isUndefined() || isShared()) {
523     // The binding will be weak if there is at least one reference and all are
524     // weak. The binding has one opportunity to change to weak: if the first
525     // reference is weak.
526     if (other.binding != STB_WEAK || !referenced)
527       binding = other.binding;
528   }
529 }
530 
531 // Using .symver foo,foo@@VER unfortunately creates two symbols: foo and
532 // foo@@VER. We want to effectively ignore foo, so give precedence to
533 // foo@@VER.
534 // FIXME: If users can transition to using
535 // .symver foo,foo@@@VER
536 // we can delete this hack.
537 static int compareVersion(StringRef a, StringRef b) {
538   bool x = a.contains("@@");
539   bool y = b.contains("@@");
540   if (!x && y)
541     return 1;
542   if (x && !y)
543     return -1;
544   return 0;
545 }
546 
547 // Compare two symbols. Return 1 if the new symbol should win, -1 if
548 // the new symbol should lose, or 0 if there is a conflict.
549 int Symbol::compare(const Symbol *other) const {
550   assert(other->isDefined() || other->isCommon());
551 
552   if (!isDefined() && !isCommon())
553     return 1;
554 
555   if (int cmp = compareVersion(getName(), other->getName()))
556     return cmp;
557 
558   if (other->isWeak())
559     return -1;
560 
561   if (isWeak())
562     return 1;
563 
564   if (isCommon() && other->isCommon()) {
565     if (config->warnCommon)
566       warn("multiple common of " + getName());
567     return 0;
568   }
569 
570   if (isCommon()) {
571     if (config->warnCommon)
572       warn("common " + getName() + " is overridden");
573     return 1;
574   }
575 
576   if (other->isCommon()) {
577     if (config->warnCommon)
578       warn("common " + getName() + " is overridden");
579     return -1;
580   }
581 
582   auto *oldSym = cast<Defined>(this);
583   auto *newSym = cast<Defined>(other);
584 
585   if (dyn_cast_or_null<BitcodeFile>(other->file))
586     return 0;
587 
588   if (!oldSym->section && !newSym->section && oldSym->value == newSym->value &&
589       newSym->binding == STB_GLOBAL)
590     return -1;
591 
592   return 0;
593 }
594 
595 static void reportDuplicate(Symbol *sym, InputFile *newFile,
596                             InputSectionBase *errSec, uint64_t errOffset) {
597   if (config->allowMultipleDefinition)
598     return;
599 
600   Defined *d = cast<Defined>(sym);
601   if (!d->section || !errSec) {
602     error("duplicate symbol: " + toString(*sym) + "\n>>> defined in " +
603           toString(sym->file) + "\n>>> defined in " + toString(newFile));
604     return;
605   }
606 
607   // Construct and print an error message in the form of:
608   //
609   //   ld.lld: error: duplicate symbol: foo
610   //   >>> defined at bar.c:30
611   //   >>>            bar.o (/home/alice/src/bar.o)
612   //   >>> defined at baz.c:563
613   //   >>>            baz.o in archive libbaz.a
614   auto *sec1 = cast<InputSectionBase>(d->section);
615   std::string src1 = sec1->getSrcMsg(*sym, d->value);
616   std::string obj1 = sec1->getObjMsg(d->value);
617   std::string src2 = errSec->getSrcMsg(*sym, errOffset);
618   std::string obj2 = errSec->getObjMsg(errOffset);
619 
620   std::string msg = "duplicate symbol: " + toString(*sym) + "\n>>> defined at ";
621   if (!src1.empty())
622     msg += src1 + "\n>>>            ";
623   msg += obj1 + "\n>>> defined at ";
624   if (!src2.empty())
625     msg += src2 + "\n>>>            ";
626   msg += obj2;
627   error(msg);
628 }
629 
630 void Symbol::resolveCommon(const CommonSymbol &other) {
631   int cmp = compare(&other);
632   if (cmp < 0)
633     return;
634 
635   if (cmp > 0) {
636     if (auto *s = dyn_cast<SharedSymbol>(this)) {
637       // Increase st_size if the shared symbol has a larger st_size. The shared
638       // symbol may be created from common symbols. The fact that some object
639       // files were linked into a shared object first should not change the
640       // regular rule that picks the largest st_size.
641       uint64_t size = s->size;
642       replace(other);
643       if (size > cast<CommonSymbol>(this)->size)
644         cast<CommonSymbol>(this)->size = size;
645     } else {
646       replace(other);
647     }
648     return;
649   }
650 
651   CommonSymbol *oldSym = cast<CommonSymbol>(this);
652 
653   oldSym->alignment = std::max(oldSym->alignment, other.alignment);
654   if (oldSym->size < other.size) {
655     oldSym->file = other.file;
656     oldSym->size = other.size;
657   }
658 }
659 
660 void Symbol::resolveDefined(const Defined &other) {
661   int cmp = compare(&other);
662   if (cmp > 0)
663     replace(other);
664   else if (cmp == 0)
665     reportDuplicate(this, other.file,
666                     dyn_cast_or_null<InputSectionBase>(other.section),
667                     other.value);
668 }
669 
670 template <class LazyT> void Symbol::resolveLazy(const LazyT &other) {
671   if (!isUndefined())
672     return;
673 
674   // An undefined weak will not fetch archive members. See comment on Lazy in
675   // Symbols.h for the details.
676   if (isWeak()) {
677     uint8_t ty = type;
678     replace(other);
679     type = ty;
680     binding = STB_WEAK;
681     return;
682   }
683 
684   other.fetch();
685 }
686 
687 void Symbol::resolveShared(const SharedSymbol &other) {
688   if (isCommon()) {
689     // See the comment in resolveCommon() above.
690     if (other.size > cast<CommonSymbol>(this)->size)
691       cast<CommonSymbol>(this)->size = other.size;
692     return;
693   }
694   if (visibility == STV_DEFAULT && (isUndefined() || isLazy())) {
695     // An undefined symbol with non default visibility must be satisfied
696     // in the same DSO.
697     uint8_t bind = binding;
698     replace(other);
699     binding = bind;
700   }
701 }
702 
703 } // namespace elf
704 } // namespace lld
705