diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index c3d5635a3bdb..6e22131c4621 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -407,8 +407,8 @@ template struct ElfSym { // __rel_iplt_start/__rel_iplt_end for signaling // where R_[*]_IRELATIVE relocations do live. - static DefinedRegular *RelaIpltStart; - static DefinedRegular *RelaIpltEnd; + static SymbolBody *RelaIpltStart; + static SymbolBody *RelaIpltEnd; }; template DefinedRegular *ElfSym::Etext; @@ -418,8 +418,8 @@ template DefinedRegular *ElfSym::Edata2; template DefinedRegular *ElfSym::End; template DefinedRegular *ElfSym::End2; template DefinedRegular *ElfSym::MipsGp; -template DefinedRegular *ElfSym::RelaIpltStart; -template DefinedRegular *ElfSym::RelaIpltEnd; +template SymbolBody *ElfSym::RelaIpltStart; +template SymbolBody *ElfSym::RelaIpltEnd; } // namespace elf } // namespace lld diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 5f57433a39f3..b46b0786d3ea 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -806,10 +806,14 @@ void Writer::addRelIpltSymbols() { if (isOutputDynamic() || !Out::RelaPlt) return; StringRef S = Config->Rela ? "__rela_iplt_start" : "__rel_iplt_start"; - ElfSym::RelaIpltStart = Symtab.addIgnored(S); + if (Symtab.find(S)) + ElfSym::RelaIpltStart = + Symtab.addSynthetic(S, *Out::RelaPlt, 0, STV_HIDDEN); S = Config->Rela ? "__rela_iplt_end" : "__rel_iplt_end"; - ElfSym::RelaIpltEnd = Symtab.addIgnored(S); + if (Symtab.find(S)) + ElfSym::RelaIpltEnd = Symtab.addSynthetic( + S, *Out::RelaPlt, DefinedSynthetic::SectionEnd, STV_HIDDEN); } template static bool includeInSymtab(const SymbolBody &B) { @@ -1505,16 +1509,6 @@ static uint16_t getELFType() { // to each section. This function fixes some predefined absolute // symbol values that depend on section address and size. template void Writer::fixAbsoluteSymbols() { - // Update __rel[a]_iplt_{start,end} symbols so that they point - // to beginning or ending of .rela.plt section, respectively. - if (Out::RelaPlt) { - uintX_t Start = Out::RelaPlt->getVA(); - if (ElfSym::RelaIpltStart) - ElfSym::RelaIpltStart->Value = Start; - if (ElfSym::RelaIpltEnd) - ElfSym::RelaIpltEnd->Value = Start + Out::RelaPlt->getSize(); - } - // Update MIPS _gp absolute symbol so that it points to the static data. if (Config->EMachine == EM_MIPS) ElfSym::MipsGp->Value = getMipsGpAddr(); diff --git a/lld/test/ELF/aarch64-gnu-ifunc.s b/lld/test/ELF/aarch64-gnu-ifunc.s index 32e9636ce679..159e2310d68f 100644 --- a/lld/test/ELF/aarch64-gnu-ifunc.s +++ b/lld/test/ELF/aarch64-gnu-ifunc.s @@ -54,7 +54,7 @@ // CHECK-NEXT: Other [ // CHECK-NEXT: STV_HIDDEN // CHECK-NEXT: ] -// CHECK-NEXT: Section: Absolute +// CHECK-NEXT: Section: .rela.plt // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: __rela_iplt_start @@ -65,7 +65,7 @@ // CHECK-NEXT: Other [ // CHECK-NEXT: STV_HIDDEN // CHECK-NEXT: ] -// CHECK-NEXT: Section: Absolute +// CHECK-NEXT: Section: .rela.plt // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: _start diff --git a/lld/test/ELF/gnu-ifunc-i386.s b/lld/test/ELF/gnu-ifunc-i386.s index 925ed22ec63c..58363b13a60e 100644 --- a/lld/test/ELF/gnu-ifunc-i386.s +++ b/lld/test/ELF/gnu-ifunc-i386.s @@ -46,7 +46,7 @@ // CHECK-NEXT: Other [ // CHECK-NEXT: STV_HIDDEN // CHECK-NEXT: ] -// CHECK-NEXT: Section: Absolute +// CHECK-NEXT: Section: .rel.plt // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: __rel_iplt_start @@ -57,7 +57,7 @@ // CHECK-NEXT: Other [ // CHECK-NEXT: STV_HIDDEN // CHECK-NEXT: ] -// CHECK-NEXT: Section: Absolute +// CHECK-NEXT: Section: .rel.plt // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: _start diff --git a/lld/test/ELF/gnu-ifunc.s b/lld/test/ELF/gnu-ifunc.s index 38e37279787a..d2ba627d06f2 100644 --- a/lld/test/ELF/gnu-ifunc.s +++ b/lld/test/ELF/gnu-ifunc.s @@ -45,7 +45,7 @@ // CHECK-NEXT: Other [ // CHECK-NEXT: STV_HIDDEN // CHECK-NEXT: ] -// CHECK-NEXT: Section: Absolute +// CHECK-NEXT: Section: .rela.plt // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: __rela_iplt_start @@ -56,7 +56,7 @@ // CHECK-NEXT: Other [ // CHECK-NEXT: STV_HIDDEN // CHECK-NEXT: ] -// CHECK-NEXT: Section: Absolute +// CHECK-NEXT: Section: .rela.plt // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: _start