summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Symbols.h21
-rw-r--r--lld/ELF/Writer.cpp35
2 files changed, 30 insertions, 26 deletions
diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h
index af3cb7190d4..11fcdcb5a45 100644
--- a/lld/ELF/Symbols.h
+++ b/lld/ELF/Symbols.h
@@ -392,16 +392,17 @@ private:
// Some linker-generated symbols need to be created as
// DefinedRegular symbols.
template <class ELFT> struct ElfSym {
- typedef std::pair<DefinedRegular<ELFT> *, DefinedRegular<ELFT> *> SymPair;
-
// The content for _etext and etext symbols.
- static SymPair Etext;
+ static DefinedRegular<ELFT> *Etext;
+ static DefinedRegular<ELFT> *Etext2;
// The content for _edata and edata symbols.
- static SymPair Edata;
+ static DefinedRegular<ELFT> *Edata;
+ static DefinedRegular<ELFT> *Edata2;
// The content for _end and end symbols.
- static SymPair End;
+ static DefinedRegular<ELFT> *End;
+ static DefinedRegular<ELFT> *End2;
// The content for _gp symbol for MIPS target.
static SymbolBody *MipsGp;
@@ -415,10 +416,12 @@ template <class ELFT> struct ElfSym {
static SymbolBody *RelaIpltEnd;
};
-template <class ELFT> typename ElfSym<ELFT>::SymPair ElfSym<ELFT>::Etext;
-template <class ELFT> typename ElfSym<ELFT>::SymPair ElfSym<ELFT>::Edata;
-template <class ELFT> typename ElfSym<ELFT>::SymPair ElfSym<ELFT>::End;
-
+template <class ELFT> DefinedRegular<ELFT> *ElfSym<ELFT>::Etext;
+template <class ELFT> DefinedRegular<ELFT> *ElfSym<ELFT>::Etext2;
+template <class ELFT> DefinedRegular<ELFT> *ElfSym<ELFT>::Edata;
+template <class ELFT> DefinedRegular<ELFT> *ElfSym<ELFT>::Edata2;
+template <class ELFT> DefinedRegular<ELFT> *ElfSym<ELFT>::End;
+template <class ELFT> DefinedRegular<ELFT> *ElfSym<ELFT>::End2;
template <class ELFT> SymbolBody *ElfSym<ELFT>::MipsGp;
template <class ELFT> SymbolBody *ElfSym<ELFT>::MipsLocalGp;
template <class ELFT> SymbolBody *ElfSym<ELFT>::MipsGpDisp;
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 65dde8d68af..93792fe5c22 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1176,8 +1176,9 @@ template <class ELFT> void Writer<ELFT>::addReservedSymbols() {
if (!isOutputDynamic())
Symtab.addIgnored("__tls_get_addr");
- auto Define = [this](StringRef S, typename ElfSym<ELFT>::SymPair &Sym) {
- Sym.first = Symtab.addIgnored(S, STV_DEFAULT);
+ auto Define = [this](StringRef S, DefinedRegular<ELFT> *&Sym1,
+ DefinedRegular<ELFT> *&Sym2) {
+ Sym1 = Symtab.addIgnored(S, STV_DEFAULT);
// The name without the underscore is not a reserved name,
// so it is defined only when there is a reference against it.
@@ -1185,12 +1186,12 @@ template <class ELFT> void Writer<ELFT>::addReservedSymbols() {
S = S.substr(1);
if (SymbolBody *B = Symtab.find(S))
if (B->isUndefined())
- Sym.second = Symtab.addAbsolute(S, STV_DEFAULT);
+ Sym2 = Symtab.addAbsolute(S, STV_DEFAULT);
};
- Define("_end", ElfSym<ELFT>::End);
- Define("_etext", ElfSym<ELFT>::Etext);
- Define("_edata", ElfSym<ELFT>::Edata);
+ Define("_end", ElfSym<ELFT>::End, ElfSym<ELFT>::End2);
+ Define("_etext", ElfSym<ELFT>::Etext, ElfSym<ELFT>::Etext2);
+ Define("_edata", ElfSym<ELFT>::Edata, ElfSym<ELFT>::Edata2);
}
// Sort input sections by section name suffixes for
@@ -1719,18 +1720,18 @@ static uint16_t getELFType() {
return ET_EXEC;
}
-template <class ELFT, class SymPair, class uintX_t>
-static void assignSymValue(SymPair &Sym, uintX_t Val) {
- if (Sym.first)
- Sym.first->Value = Val;
- if (Sym.second)
- Sym.second->Value = Val;
-}
-
// This function is called after we have assigned address and size
// to each section. This function fixes some predefined absolute
// symbol values that depend on section address and size.
template <class ELFT> void Writer<ELFT>::fixAbsoluteSymbols() {
+ auto Set = [](DefinedRegular<ELFT> *&S1, DefinedRegular<ELFT> *&S2,
+ uintX_t V) {
+ if (S1)
+ S1->Value = V;
+ if (S2)
+ S2->Value = V;
+ };
+
// _etext is the first location after the last read-only loadable segment.
// _edata is the first location after the last read-write loadable segment.
// _end is the first location after the uninitialized data region.
@@ -1738,13 +1739,13 @@ template <class ELFT> void Writer<ELFT>::fixAbsoluteSymbols() {
Elf_Phdr &H = P.H;
if (H.p_type != PT_LOAD)
continue;
- assignSymValue<ELFT>(ElfSym<ELFT>::End, H.p_vaddr + H.p_memsz);
+ Set(ElfSym<ELFT>::End, ElfSym<ELFT>::End2, H.p_vaddr + H.p_memsz);
uintX_t Val = H.p_vaddr + H.p_filesz;
if (H.p_flags & PF_W)
- assignSymValue<ELFT>(ElfSym<ELFT>::Edata, Val);
+ Set(ElfSym<ELFT>::Edata, ElfSym<ELFT>::Edata2, Val);
else
- assignSymValue<ELFT>(ElfSym<ELFT>::Etext, Val);
+ Set(ElfSym<ELFT>::Etext, ElfSym<ELFT>::Etext2, Val);
}
}
OpenPOWER on IntegriCloud