@@ -167,19 +167,19 @@ void elf::addReservedSymbols() {
167
167
// to GOT. Default offset is 0x7ff0.
168
168
// See "Global Data Symbols" in Chapter 6 in the following document:
169
169
// ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
170
- ElfSym:: mipsGp = addAbsolute (" _gp" );
170
+ ctx. sym . mipsGp = addAbsolute (" _gp" );
171
171
172
172
// On MIPS O32 ABI, _gp_disp is a magic symbol designates offset between
173
173
// start of function and 'gp' pointer into GOT.
174
174
if (symtab.find (" _gp_disp" ))
175
- ElfSym:: mipsGpDisp = addAbsolute (" _gp_disp" );
175
+ ctx. sym . mipsGpDisp = addAbsolute (" _gp_disp" );
176
176
177
177
// The __gnu_local_gp is a magic symbol equal to the current value of 'gp'
178
178
// pointer. This symbol is used in the code generated by .cpload pseudo-op
179
179
// in case of using -mno-shared option.
180
180
// https://sourceware.org/ml/binutils/2004-12/msg00094.html
181
181
if (symtab.find (" __gnu_local_gp" ))
182
- ElfSym:: mipsLocalGp = addAbsolute (" __gnu_local_gp" );
182
+ ctx. sym . mipsLocalGp = addAbsolute (" __gnu_local_gp" );
183
183
} else if (config->emachine == EM_PPC) {
184
184
// glibc *crt1.o has a undefined reference to _SDA_BASE_. Since we don't
185
185
// support Small Data Area, define it arbitrarily as 0.
@@ -212,7 +212,7 @@ void elf::addReservedSymbols() {
212
212
213
213
s->resolve (Defined{ctx.internalFile , StringRef (), STB_GLOBAL, STV_HIDDEN,
214
214
STT_NOTYPE, gotOff, /* size=*/ 0 , ctx.out .elfHeader });
215
- ElfSym:: globalOffsetTable = cast<Defined>(s);
215
+ ctx. sym . globalOffsetTable = cast<Defined>(s);
216
216
}
217
217
218
218
// __ehdr_start is the location of ELF file headers. Note that we define
@@ -238,13 +238,13 @@ void elf::addReservedSymbols() {
238
238
return addOptionalRegular (s, ctx.out .elfHeader , pos, STV_DEFAULT);
239
239
};
240
240
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 );
248
248
}
249
249
250
250
static void demoteDefined (Defined &sym, DenseMap<SectionBase *, size_t > &map) {
@@ -799,10 +799,10 @@ template <class ELFT> void Writer<ELFT>::addRelIpltSymbols() {
799
799
// We'll override ctx.out.elfHeader with relaDyn later when we are sure that
800
800
// .rela.dyn will be present in the output.
801
801
std::string name = config->isRela ? " __rela_iplt_start" : " __rel_iplt_start" ;
802
- ElfSym:: relaIpltStart =
802
+ ctx. sym . relaIpltStart =
803
803
addOptionalRegular (name, ctx.out .elfHeader , 0 , STV_HIDDEN);
804
804
name.replace (name.size () - 5 , 5 , " end" );
805
- ElfSym:: relaIpltEnd =
805
+ ctx. sym . relaIpltEnd =
806
806
addOptionalRegular (name, ctx.out .elfHeader , 0 , STV_HIDDEN);
807
807
}
808
808
@@ -812,21 +812,21 @@ template <class ELFT> void Writer<ELFT>::addRelIpltSymbols() {
812
812
// time any references to these symbols are processed and is equivalent to
813
813
// defining these symbols explicitly in the linker script.
814
814
template <class ELFT > void Writer<ELFT>::setReservedSymbolSections() {
815
- if (ElfSym:: globalOffsetTable) {
815
+ if (ctx. sym . globalOffsetTable ) {
816
816
// The _GLOBAL_OFFSET_TABLE_ symbol is defined by target convention usually
817
817
// to the start of the .got or .got.plt section.
818
818
InputSection *sec = in.gotPlt .get ();
819
819
if (!target->gotBaseSymInGotPlt )
820
820
sec = in.mipsGot ? cast<InputSection>(in.mipsGot .get ())
821
821
: cast<InputSection>(in.got .get ());
822
- ElfSym:: globalOffsetTable->section = sec;
822
+ ctx. sym . globalOffsetTable ->section = sec;
823
823
}
824
824
825
825
// .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 ();
830
830
}
831
831
832
832
PhdrEntry *last = nullptr ;
@@ -847,10 +847,10 @@ template <class ELFT> void Writer<ELFT>::setReservedSymbolSections() {
847
847
if (lastRO) {
848
848
// _etext is the first location after the last read-only loadable segment
849
849
// 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;
854
854
}
855
855
856
856
if (last) {
@@ -864,34 +864,34 @@ template <class ELFT> void Writer<ELFT>::setReservedSymbolSections() {
864
864
break ;
865
865
}
866
866
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;
871
871
872
872
// _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 ;
877
877
}
878
878
879
- if (ElfSym:: bss) {
879
+ if (ctx. sym . bss ) {
880
880
// On RISC-V, set __bss_start to the start of .sbss if present.
881
881
OutputSection *sbss =
882
882
config->emachine == EM_RISCV ? findSection (" .sbss" ) : nullptr ;
883
- ElfSym:: bss->section = sbss ? sbss : findSection (" .bss" );
883
+ ctx. sym . bss ->section = sbss ? sbss : findSection (" .bss" );
884
884
}
885
885
886
886
// Setup MIPS _gp_disp/__gnu_local_gp symbols which should
887
887
// be equal to the _gp symbol's value.
888
- if (ElfSym:: mipsGp) {
888
+ if (ctx. sym . mipsGp ) {
889
889
// Find GP-relative section with the lowest address
890
890
// and use this address to calculate default _gp value.
891
891
for (OutputSection *os : outputSections) {
892
892
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 ;
895
895
break ;
896
896
}
897
897
}
@@ -1725,7 +1725,6 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
1725
1725
// value/section does not matter but it has to be relative, so set its
1726
1726
// st_shndx arbitrarily to 1 (ctx.out.elfHeader).
1727
1727
if (config->emachine == EM_RISCV) {
1728
- ElfSym::riscvGlobalPointer = nullptr ;
1729
1728
if (!config->shared ) {
1730
1729
OutputSection *sec = findSection (" .sdata" );
1731
1730
addOptionalRegular (" __global_pointer$" , sec ? sec : ctx.out .elfHeader ,
@@ -1735,7 +1734,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
1735
1734
if (config->relaxGP ) {
1736
1735
Symbol *s = symtab.find (" __global_pointer$" );
1737
1736
if (s && s->isDefined ())
1738
- ElfSym:: riscvGlobalPointer = cast<Defined>(s);
1737
+ ctx. sym . riscvGlobalPointer = cast<Defined>(s);
1739
1738
}
1740
1739
}
1741
1740
}
@@ -1757,7 +1756,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
1757
1756
s->resolve (Defined{ctx.internalFile , StringRef (), STB_GLOBAL,
1758
1757
STV_HIDDEN, STT_TLS, /* value=*/ 0 , 0 ,
1759
1758
/* section=*/ nullptr });
1760
- ElfSym:: tlsModuleBase = cast<Defined>(s);
1759
+ ctx. sym . tlsModuleBase = cast<Defined>(s);
1761
1760
}
1762
1761
}
1763
1762
0 commit comments