[lld] r256449 - Split Writer::assignAddresses. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 26 02:52:29 PST 2015
Author: ruiu
Date: Sat Dec 26 04:52:26 2015
New Revision: 256449
URL: http://llvm.org/viewvc/llvm-project?rev=256449&view=rev
Log:
Split Writer::assignAddresses. NFC.
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=256449&r1=256448&r2=256449&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sat Dec 26 04:52:26 2015
@@ -55,6 +55,7 @@ private:
void updateRelro(Elf_Phdr *Cur, Elf_Phdr *GnuRelroPhdr, uintX_t VA);
void assignAddresses();
void buildSectionMap();
+ void fixAbsoluteSymbols();
void openFile(StringRef OutputPath);
void writeHeader();
void writeSections();
@@ -154,6 +155,7 @@ template <class ELFT> void Writer<ELFT>:
addReservedSymbols();
createSections();
assignAddresses();
+ fixAbsoluteSymbols();
openFile(Config->OutputFile);
writeHeader();
writeSections();
@@ -1110,18 +1112,6 @@ template <class ELFT> void Writer<ELFT>:
// Update "_end" and "end" symbols so that they
// point to the end of the data segment.
ElfSym<ELFT>::End.st_value = VA;
-
- // Update __rel_iplt_start/__rel_iplt_end to wrap the
- // rela.plt section.
- if (Out<ELFT>::RelaPlt) {
- uintX_t Start = Out<ELFT>::RelaPlt->getVA();
- ElfSym<ELFT>::RelaIpltStart.st_value = Start;
- ElfSym<ELFT>::RelaIpltEnd.st_value = Start + Out<ELFT>::RelaPlt->getSize();
- }
-
- // Update MIPS _gp absolute symbol so that it points to the static data.
- if (Config->EMachine == EM_MIPS)
- ElfSym<ELFT>::MipsGp.st_value = getMipsGpAddr<ELFT>();
}
// Returns the number of PHDR entries.
@@ -1176,6 +1166,23 @@ static typename ELFFile<ELFT>::uintX_t g
return 0;
}
+// 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() {
+ // Update __rel[a]_iplt_{start,end} symbols so that they point
+ // to beginning or ending of .rela.plt section, respectively.
+ if (Out<ELFT>::RelaPlt) {
+ uintX_t Start = Out<ELFT>::RelaPlt->getVA();
+ ElfSym<ELFT>::RelaIpltStart.st_value = Start;
+ ElfSym<ELFT>::RelaIpltEnd.st_value = Start + Out<ELFT>::RelaPlt->getSize();
+ }
+
+ // Update MIPS _gp absolute symbol so that it points to the static data.
+ if (Config->EMachine == EM_MIPS)
+ ElfSym<ELFT>::MipsGp.st_value = getMipsGpAddr<ELFT>();
+}
+
template <class ELFT> void Writer<ELFT>::writeHeader() {
uint8_t *Buf = Buffer->getBufferStart();
memcpy(Buf, "\177ELF", 4);
More information about the llvm-commits
mailing list