diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index 5aa585d7bfe09..221a89ac49610 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -268,8 +268,6 @@ MemoryBufferRef LazyArchive::getMemberBuffer() { } uint8_t Symbol::computeBinding() const { - if (config->relocatable) - return binding; if ((visibility != STV_DEFAULT && visibility != STV_PROTECTED) || (versionId == VER_NDX_LOCAL && !isLazy())) return STB_LOCAL; diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index b87123a216bc4..4ff3ec5849f17 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1972,7 +1972,8 @@ template void Writer::finalizeSections() { for (Symbol *sym : symtab->symbols()) { if (!sym->isUsedInRegularObj || !includeInSymtab(*sym)) continue; - sym->binding = sym->computeBinding(); + if (!config->relocatable) + sym->binding = sym->computeBinding(); if (in.symTab) in.symTab->addSymbol(sym);