Index: ELF/Relocations.cpp =================================================================== --- ELF/Relocations.cpp +++ ELF/Relocations.cpp @@ -525,8 +525,14 @@ // See if this symbol is in a read-only segment. If so, preserve the symbol's // memory protection by reserving space in the .bss.rel.ro section. bool IsReadOnly = isReadOnly(SS); - BssSection *Sec = IsReadOnly ? InX::BssRelRo : InX::Bss; + BssSection *Sec = make(IsReadOnly ? ".bss.rel.ro" : ".bss"); uint64_t Off = Sec->reserveSpace(SymSize, SS->getAlignment()); + if (IsReadOnly) + InX::BssRelRo->getParent()->addSection(Sec); + else + InX::Bss->getParent()->addSection(Sec); + assert(Off == 0); + (void)Off; // Look through the DSO's dynamic symbol table for aliases and create a // dynamic symbol for each one. This causes the copy relocation to correctly @@ -534,7 +540,6 @@ for (SharedSymbol *Sym : getSymbolsAt(SS)) { Sym->CopyRelSec = Sec; Sym->IsPreemptible = false; - Sym->CopyRelSecOff = Off; Sym->symbol()->IsUsedInRegularObj = true; } Index: ELF/Symbols.h =================================================================== --- ELF/Symbols.h +++ ELF/Symbols.h @@ -243,7 +243,6 @@ // CopyRelSec and CopyRelSecOff are significant only when NeedsCopy is true. InputSection *CopyRelSec; - uint64_t CopyRelSecOff; private: template const typename ELFT::Sym &getSym() const { Index: ELF/Symbols.cpp =================================================================== --- ELF/Symbols.cpp +++ ELF/Symbols.cpp @@ -108,8 +108,7 @@ case SymbolBody::SharedKind: { auto &SS = cast(Body); if (SS.CopyRelSec) - return SS.CopyRelSec->getParent()->Addr + SS.CopyRelSec->OutSecOff + - SS.CopyRelSecOff; + return SS.CopyRelSec->getParent()->Addr + SS.CopyRelSec->OutSecOff; if (SS.NeedsPltAddr) return Body.getPltVA(); return 0;