summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-12-26 10:52:26 +0000
committerRui Ueyama <ruiu@google.com>2015-12-26 10:52:26 +0000
commit1a311f1da6bd60b5230be52f0501e80949bd056e (patch)
treeed91b7a819b940be50ea218fe0a8709a17dfd83a
parent5a4ae1f5844f964542dd6b5baf9e1b302d0069a7 (diff)
downloadbcm5719-llvm-1a311f1da6bd60b5230be52f0501e80949bd056e.tar.gz
bcm5719-llvm-1a311f1da6bd60b5230be52f0501e80949bd056e.zip
Split Writer::assignAddresses. NFC.
llvm-svn: 256449
-rw-r--r--lld/ELF/Writer.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 6bcfc6f9678..bdcb720a8a4 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -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>::run() {
addReservedSymbols();
createSections();
assignAddresses();
+ fixAbsoluteSymbols();
openFile(Config->OutputFile);
writeHeader();
writeSections();
@@ -1110,18 +1112,6 @@ template <class ELFT> void Writer<ELFT>::assignAddresses() {
// 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 getEntryAddr() {
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);
OpenPOWER on IntegriCloud