diff options
Diffstat (limited to 'lld/ELF/Writer.cpp')
| -rw-r--r-- | lld/ELF/Writer.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 2412cb86dba..1cee79cf051 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -344,7 +344,10 @@ template <class ELFT> void SymbolTableSection<ELFT>::writeTo(uint8_t *Buf) { uintX_t VA = Out->getVA(); if (Section) VA += Section->getOutputSectionOff(); - VA += InputSym->st_value; + if (auto *C = dyn_cast<DefinedCommon<ELFT>>(Body)) + VA += C->OffsetInBSS; + else + VA += InputSym->st_value; ESym->st_value = VA; } @@ -445,6 +448,7 @@ template <class ELFT> void Writer<ELFT>::createSections() { const Elf_Sym &Sym = C->Sym; uintX_t Align = Sym.st_value; Off = RoundUpToAlignment(Off, Align); + C->OffsetInBSS = Off; Off += Sym.st_size; } BSSSec->setSize(Off); |

