@@ -167,19 +167,19 @@ void elf::addReservedSymbols() {
167167 // to GOT. Default offset is 0x7ff0.
168168 // See "Global Data Symbols" in Chapter 6 in the following document:
169169 // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
170- ElfSym:: mipsGp = addAbsolute (" _gp" );
170+ ctx. sym . mipsGp = addAbsolute (" _gp" );
171171
172172 // On MIPS O32 ABI, _gp_disp is a magic symbol designates offset between
173173 // start of function and 'gp' pointer into GOT.
174174 if (symtab.find (" _gp_disp" ))
175- ElfSym:: mipsGpDisp = addAbsolute (" _gp_disp" );
175+ ctx. sym . mipsGpDisp = addAbsolute (" _gp_disp" );
176176
177177 // The __gnu_local_gp is a magic symbol equal to the current value of 'gp'
178178 // pointer. This symbol is used in the code generated by .cpload pseudo-op
179179 // in case of using -mno-shared option.
180180 // https://sourceware.org/ml/binutils/2004-12/msg00094.html
181181 if (symtab.find (" __gnu_local_gp" ))
182- ElfSym:: mipsLocalGp = addAbsolute (" __gnu_local_gp" );
182+ ctx. sym . mipsLocalGp = addAbsolute (" __gnu_local_gp" );
183183 } else if (config->emachine == EM_PPC) {
184184 // glibc *crt1.o has a undefined reference to _SDA_BASE_. Since we don't
185185 // support Small Data Area, define it arbitrarily as 0.
@@ -212,7 +212,7 @@ void elf::addReservedSymbols() {
212212
213213 s->resolve (Defined{ctx.internalFile , StringRef (), STB_GLOBAL, STV_HIDDEN,
214214 STT_NOTYPE, gotOff, /* size=*/ 0 , ctx.out .elfHeader });
215- ElfSym:: globalOffsetTable = cast<Defined>(s);
215+ ctx. sym . globalOffsetTable = cast<Defined>(s);
216216 }
217217
218218 // __ehdr_start is the location of ELF file headers. Note that we define
@@ -238,13 +238,13 @@ void elf::addReservedSymbols() {
238238 return addOptionalRegular (s, ctx.out .elfHeader , pos, STV_DEFAULT);
239239 };
240240
241- ElfSym:: bss = add (" __bss_start" , 0 );
242- ElfSym:: end1 = add (" end" , -1 );
243- ElfSym:: end2 = add (" _end" , -1 );
244- ElfSym:: etext1 = add (" etext" , -1 );
245- ElfSym:: etext2 = add (" _etext" , -1 );
246- ElfSym:: edata1 = add (" edata" , -1 );
247- ElfSym:: edata2 = add (" _edata" , -1 );
241+ ctx. sym . bss = add (" __bss_start" , 0 );
242+ ctx. sym . end1 = add (" end" , -1 );
243+ ctx. sym . end2 = add (" _end" , -1 );
244+ ctx. sym . etext1 = add (" etext" , -1 );
245+ ctx. sym . etext2 = add (" _etext" , -1 );
246+ ctx. sym . edata1 = add (" edata" , -1 );
247+ ctx. sym . edata2 = add (" _edata" , -1 );
248248}
249249
250250static void demoteDefined (Defined &sym, DenseMap<SectionBase *, size_t > &map) {
@@ -799,10 +799,10 @@ template <class ELFT> void Writer<ELFT>::addRelIpltSymbols() {
799799 // We'll override ctx.out.elfHeader with relaDyn later when we are sure that
800800 // .rela.dyn will be present in the output.
801801 std::string name = config->isRela ? " __rela_iplt_start" : " __rel_iplt_start" ;
802- ElfSym:: relaIpltStart =
802+ ctx. sym . relaIpltStart =
803803 addOptionalRegular (name, ctx.out .elfHeader , 0 , STV_HIDDEN);
804804 name.replace (name.size () - 5 , 5 , " end" );
805- ElfSym:: relaIpltEnd =
805+ ctx. sym . relaIpltEnd =
806806 addOptionalRegular (name, ctx.out .elfHeader , 0 , STV_HIDDEN);
807807}
808808
@@ -812,21 +812,21 @@ template <class ELFT> void Writer<ELFT>::addRelIpltSymbols() {
812812// time any references to these symbols are processed and is equivalent to
813813// defining these symbols explicitly in the linker script.
814814template <class ELFT > void Writer<ELFT>::setReservedSymbolSections() {
815- if (ElfSym:: globalOffsetTable) {
815+ if (ctx. sym . globalOffsetTable ) {
816816 // The _GLOBAL_OFFSET_TABLE_ symbol is defined by target convention usually
817817 // to the start of the .got or .got.plt section.
818818 InputSection *sec = in.gotPlt .get ();
819819 if (!target->gotBaseSymInGotPlt )
820820 sec = in.mipsGot ? cast<InputSection>(in.mipsGot .get ())
821821 : cast<InputSection>(in.got .get ());
822- ElfSym:: globalOffsetTable->section = sec;
822+ ctx. sym . globalOffsetTable ->section = sec;
823823 }
824824
825825 // .rela_iplt_{start,end} mark the start and the end of .rel[a].dyn.
826- if (ElfSym:: relaIpltStart && mainPart->relaDyn ->isNeeded ()) {
827- ElfSym:: relaIpltStart->section = mainPart->relaDyn .get ();
828- ElfSym:: relaIpltEnd->section = mainPart->relaDyn .get ();
829- ElfSym:: relaIpltEnd->value = mainPart->relaDyn ->getSize ();
826+ if (ctx. sym . relaIpltStart && mainPart->relaDyn ->isNeeded ()) {
827+ ctx. sym . relaIpltStart ->section = mainPart->relaDyn .get ();
828+ ctx. sym . relaIpltEnd ->section = mainPart->relaDyn .get ();
829+ ctx. sym . relaIpltEnd ->value = mainPart->relaDyn ->getSize ();
830830 }
831831
832832 PhdrEntry *last = nullptr ;
@@ -847,10 +847,10 @@ template <class ELFT> void Writer<ELFT>::setReservedSymbolSections() {
847847 if (lastRO) {
848848 // _etext is the first location after the last read-only loadable segment
849849 // that does not contain large sections.
850- if (ElfSym:: etext1)
851- ElfSym:: etext1->section = lastRO;
852- if (ElfSym:: etext2)
853- ElfSym:: etext2->section = lastRO;
850+ if (ctx. sym . etext1 )
851+ ctx. sym . etext1 ->section = lastRO;
852+ if (ctx. sym . etext2 )
853+ ctx. sym . etext2 ->section = lastRO;
854854 }
855855
856856 if (last) {
@@ -864,34 +864,34 @@ template <class ELFT> void Writer<ELFT>::setReservedSymbolSections() {
864864 break ;
865865 }
866866
867- if (ElfSym:: edata1)
868- ElfSym:: edata1->section = edata;
869- if (ElfSym:: edata2)
870- ElfSym:: edata2->section = edata;
867+ if (ctx. sym . edata1 )
868+ ctx. sym . edata1 ->section = edata;
869+ if (ctx. sym . edata2 )
870+ ctx. sym . edata2 ->section = edata;
871871
872872 // _end is the first location after the uninitialized data region.
873- if (ElfSym:: end1)
874- ElfSym:: end1->section = last->lastSec ;
875- if (ElfSym:: end2)
876- ElfSym:: end2->section = last->lastSec ;
873+ if (ctx. sym . end1 )
874+ ctx. sym . end1 ->section = last->lastSec ;
875+ if (ctx. sym . end2 )
876+ ctx. sym . end2 ->section = last->lastSec ;
877877 }
878878
879- if (ElfSym:: bss) {
879+ if (ctx. sym . bss ) {
880880 // On RISC-V, set __bss_start to the start of .sbss if present.
881881 OutputSection *sbss =
882882 config->emachine == EM_RISCV ? findSection (" .sbss" ) : nullptr ;
883- ElfSym:: bss->section = sbss ? sbss : findSection (" .bss" );
883+ ctx. sym . bss ->section = sbss ? sbss : findSection (" .bss" );
884884 }
885885
886886 // Setup MIPS _gp_disp/__gnu_local_gp symbols which should
887887 // be equal to the _gp symbol's value.
888- if (ElfSym:: mipsGp) {
888+ if (ctx. sym . mipsGp ) {
889889 // Find GP-relative section with the lowest address
890890 // and use this address to calculate default _gp value.
891891 for (OutputSection *os : outputSections) {
892892 if (os->flags & SHF_MIPS_GPREL) {
893- ElfSym:: mipsGp->section = os;
894- ElfSym:: mipsGp->value = 0x7ff0 ;
893+ ctx. sym . mipsGp ->section = os;
894+ ctx. sym . mipsGp ->value = 0x7ff0 ;
895895 break ;
896896 }
897897 }
@@ -1725,7 +1725,6 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
17251725 // value/section does not matter but it has to be relative, so set its
17261726 // st_shndx arbitrarily to 1 (ctx.out.elfHeader).
17271727 if (config->emachine == EM_RISCV) {
1728- ElfSym::riscvGlobalPointer = nullptr ;
17291728 if (!config->shared ) {
17301729 OutputSection *sec = findSection (" .sdata" );
17311730 addOptionalRegular (" __global_pointer$" , sec ? sec : ctx.out .elfHeader ,
@@ -1735,7 +1734,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
17351734 if (config->relaxGP ) {
17361735 Symbol *s = symtab.find (" __global_pointer$" );
17371736 if (s && s->isDefined ())
1738- ElfSym:: riscvGlobalPointer = cast<Defined>(s);
1737+ ctx. sym . riscvGlobalPointer = cast<Defined>(s);
17391738 }
17401739 }
17411740 }
@@ -1757,7 +1756,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
17571756 s->resolve (Defined{ctx.internalFile , StringRef (), STB_GLOBAL,
17581757 STV_HIDDEN, STT_TLS, /* value=*/ 0 , 0 ,
17591758 /* section=*/ nullptr });
1760- ElfSym:: tlsModuleBase = cast<Defined>(s);
1759+ ctx. sym . tlsModuleBase = cast<Defined>(s);
17611760 }
17621761 }
17631762
0 commit comments