diff options
Diffstat (limited to 'lld/ELF')
-rw-r--r-- | lld/ELF/LTO.cpp | 9 | ||||
-rw-r--r-- | lld/ELF/SymbolTable.cpp | 7 |
2 files changed, 10 insertions, 6 deletions
diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp index f24327a139a..228dc95d78f 100644 --- a/lld/ELF/LTO.cpp +++ b/lld/ELF/LTO.cpp @@ -202,8 +202,6 @@ void BitcodeCompiler::add(BitcodeFile &F) { continue; } SymbolBody *B = S->body(); - if (B->kind() != SymbolBody::DefinedRegularKind) - continue; if (B->File != &F) continue; @@ -221,7 +219,12 @@ void BitcodeCompiler::add(BitcodeFile &F) { // needs to be able to replace the original definition without conflicting. // In the latter case, we need to allow the combined LTO object to provide a // definition with the same name, for example when doing parallel codegen. - undefine(S); + if (auto *C = dyn_cast<DefinedCommon>(B)) { + if (auto *GO = dyn_cast<GlobalObject>(GV)) + GO->setAlignment(C->Alignment); + } else { + undefine(S); + } if (!GV) // Module asm symbol. diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index e99e5077d7e..caae0978766 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -351,7 +351,7 @@ Symbol *SymbolTable<ELFT>::addCommon(StringRef N, uint64_t Size, bool WasInserted; std::tie(S, WasInserted) = insert(N, Type, StOther & 3, /*CanOmitFromDynSym*/ false, HasUnnamedAddr, - /*IsUsedInRegularObj*/ true, File); + !isa<BitcodeFile>(File), File); int Cmp = compareDefined(S, WasInserted, Binding); if (Cmp > 0) { S->Binding = Binding; @@ -368,8 +368,9 @@ Symbol *SymbolTable<ELFT>::addCommon(StringRef N, uint64_t Size, if (Config->WarnCommon) warning("multiple common of " + S->body()->getName()); - C->Size = std::max(C->Size, Size); - C->Alignment = std::max(C->Alignment, Alignment); + Alignment = C->Alignment = std::max(C->Alignment, Alignment); + if (Size > C->Size) + replaceBody<DefinedCommon>(S, N, Size, Alignment, StOther, Type, File); } return S; } |