<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Nov 22, 2016 at 9:49 AM, Eugene Leviant via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: evgeny777<br>
Date: Tue Nov 22 11:49:14 2016<br>
New Revision: 287675<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=287675&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=287675&view=rev</a><br>
Log:<br>
[ELF] Convert .rld_map to input section<br>
<br>
Differential revision: <a href="https://reviews.llvm.org/D26958" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D26958</a><br>
<br>
Modified:<br>
lld/trunk/ELF/OutputSections.h<br>
lld/trunk/ELF/<wbr>SyntheticSections.cpp<br>
lld/trunk/ELF/<wbr>SyntheticSections.h<br>
lld/trunk/ELF/Writer.cpp<br>
<br>
Modified: lld/trunk/ELF/OutputSections.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=287675&r1=287674&r2=287675&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>OutputSections.h?rev=287675&<wbr>r1=287674&r2=287675&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/OutputSections.h (original)<br>
+++ lld/trunk/ELF/OutputSections.h Tue Nov 22 11:49:14 2016<br>
@@ -201,7 +201,6 @@ template <class ELFT> struct Out {<br>
static uint8_t First;<br>
static EhOutputSection<ELFT> *EhFrame;<br>
static OutputSection<ELFT> *Bss;<br>
- static OutputSection<ELFT> *MipsRldMap;<br>
static OutputSectionBase *Opd;<br>
static uint8_t *OpdBuf;<br>
static Elf_Phdr *TlsPhdr;<br>
@@ -249,7 +248,6 @@ template <class ELFT> uint64_t getHeader<br>
template <class ELFT> uint8_t Out<ELFT>::First;<br>
template <class ELFT> EhOutputSection<ELFT> *Out<ELFT>::EhFrame;<br>
template <class ELFT> OutputSection<ELFT> *Out<ELFT>::Bss;<br>
-template <class ELFT> OutputSection<ELFT> *Out<ELFT>::MipsRldMap;<br>
template <class ELFT> OutputSectionBase *Out<ELFT>::Opd;<br>
template <class ELFT> uint8_t *Out<ELFT>::OpdBuf;<br>
template <class ELFT> typename ELFT::Phdr *Out<ELFT>::TlsPhdr;<br>
<br>
Modified: lld/trunk/ELF/<wbr>SyntheticSections.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=287675&r1=287674&r2=287675&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>SyntheticSections.cpp?rev=<wbr>287675&r1=287674&r2=287675&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/<wbr>SyntheticSections.cpp (original)<br>
+++ lld/trunk/ELF/<wbr>SyntheticSections.cpp Tue Nov 22 11:49:14 2016<br>
@@ -18,6 +18,7 @@<br>
#include "Config.h"<br>
#include "Error.h"<br>
#include "InputFiles.h"<br>
+#include "LinkerScript.h"<br>
#include "Memory.h"<br>
#include "OutputSections.h"<br>
#include "Strings.h"<br>
@@ -883,8 +884,8 @@ template <class ELFT> void DynamicSectio<br>
else<br>
add({DT_MIPS_GOTSYM, In<ELFT>::DynSymTab-><wbr>getNumSymbols()});<br>
add({DT_PLTGOT, In<ELFT>::MipsGot});<br>
- if (Out<ELFT>::MipsRldMap)<br>
- add({DT_MIPS_RLD_MAP, Out<ELFT>::MipsRldMap});<br>
+ if (In<ELFT>::MipsRldMap)<br>
+ add({DT_MIPS_RLD_MAP, In<ELFT>::MipsRldMap});<br>
}<br>
<br>
this->OutSec->Entsize = this->Entsize;<br>
@@ -1655,6 +1656,19 @@ template <class ELFT> size_t VersionNeed<br>
return Size;<br>
}<br>
<br>
+template <class ELFT><br>
+MipsRldMap<ELFT>::MipsRldMap(<wbr>)<br>
+ : SyntheticSection<ELFT>(SHF_<wbr>ALLOC | SHF_WRITE, SHT_PROGBITS,<br>
+ sizeof(typename ELFT::uint), ".rld_map") {}<br>
+<br>
+template <class ELFT> void MipsRldMap<ELFT>::writeTo(<wbr>uint8_t *Buf) {<br>
+<br></blockquote><div><br></div><div>nit: remove this blank line.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ // Apply filler from linker script.<br>
+ uint64_t Filler = Script<ELFT>::X->getFiller(<wbr>this->Name);<br>
+ Filler = (Filler << 32) | Filler;<br>
+ memcpy(Buf, &Filler, getSize());<br>
+}<br>
+<br>
template InputSection<ELF32LE> *elf::createCommonSection();<br>
template InputSection<ELF32BE> *elf::createCommonSection();<br>
template InputSection<ELF64LE> *elf::createCommonSection();<br>
@@ -1764,3 +1778,8 @@ template class elf::VersionDefinitionSec<br>
template class elf::VersionDefinitionSection<<wbr>ELF32BE>;<br>
template class elf::VersionDefinitionSection<<wbr>ELF64LE>;<br>
template class elf::VersionDefinitionSection<<wbr>ELF64BE>;<br>
+<br>
+template class elf::MipsRldMap<ELF32LE>;<br>
+template class elf::MipsRldMap<ELF32BE>;<br>
+template class elf::MipsRldMap<ELF64LE>;<br>
+template class elf::MipsRldMap<ELF64BE>;<br>
<br>
Modified: lld/trunk/ELF/<wbr>SyntheticSections.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=287675&r1=287674&r2=287675&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>SyntheticSections.h?rev=<wbr>287675&r1=287674&r2=287675&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/<wbr>SyntheticSections.h (original)<br>
+++ lld/trunk/ELF/<wbr>SyntheticSections.h Tue Nov 22 11:49:14 2016<br>
@@ -599,6 +599,17 @@ private:<br>
Elf_Mips_RegInfo Reginfo;<br>
};<br>
<br>
+// This is a MIPS specific section to hold a space within the data segment<br>
+// of executable file which is pointed to by the DT_MIPS_RLD_MAP entry.<br>
+// See "Dynamic section" in Chapter 5 in the following document:<br>
+// <a href="ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf" rel="noreferrer" target="_blank">ftp://www.linux-mips.org/pub/<wbr>linux/mips/doc/ABI/mipsabi.pdf</a><br>
+template <class ELFT> class MipsRldMap : public SyntheticSection<ELFT> {<br>
+public:<br>
+ MipsRldMap();<br>
+ size_t getSize() const override { return sizeof(typename ELFT::uint); }<br>
+ void writeTo(uint8_t *Buf) override;<br>
+};<br>
+<br>
template <class ELFT> InputSection<ELFT> *createCommonSection();<br>
template <class ELFT> InputSection<ELFT> *createInterpSection();<br>
template <class ELFT> MergeInputSection<ELFT> *createCommentSection();<br>
@@ -618,6 +629,7 @@ template <class ELFT> struct In {<br>
static GotPltSection<ELFT> *GotPlt;<br>
static HashTableSection<ELFT> *HashTab;<br>
static InputSection<ELFT> *Interp;<br>
+ static MipsRldMap<ELFT> *MipsRldMap;<br>
static PltSection<ELFT> *Plt;<br>
static RelocationSection<ELFT> *RelaDyn;<br>
static RelocationSection<ELFT> *RelaPlt;<br>
@@ -642,6 +654,7 @@ template <class ELFT> MipsGotSection<ELF<br>
template <class ELFT> GotPltSection<ELFT> *In<ELFT>::GotPlt;<br>
template <class ELFT> HashTableSection<ELFT> *In<ELFT>::HashTab;<br>
template <class ELFT> InputSection<ELFT> *In<ELFT>::Interp;<br>
+template <class ELFT> MipsRldMap<ELFT> *In<ELFT>::MipsRldMap;<br>
template <class ELFT> PltSection<ELFT> *In<ELFT>::Plt;<br>
template <class ELFT> RelocationSection<ELFT> *In<ELFT>::RelaDyn;<br>
template <class ELFT> RelocationSection<ELFT> *In<ELFT>::RelaPlt;<br>
<br>
Modified: lld/trunk/ELF/Writer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=287675&r1=287674&r2=287675&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Writer.<wbr>cpp?rev=287675&r1=287674&r2=<wbr>287675&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Writer.cpp (original)<br>
+++ lld/trunk/ELF/Writer.cpp Tue Nov 22 11:49:14 2016<br>
@@ -277,16 +277,6 @@ template <class ELFT> void Writer<ELFT>:<br>
In<ELFT>::SymTab = make<SymbolTableSection<ELFT>><wbr>(*In<ELFT>::StrTab);<br>
}<br>
<br>
- if (Config->EMachine == EM_MIPS && !Config->Shared) {<br>
- // This is a MIPS specific section to hold a space within the data segment<br>
- // of executable file which is pointed to by the DT_MIPS_RLD_MAP entry.<br>
- // See "Dynamic section" in Chapter 5 in the following document:<br>
- // <a href="ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf" rel="noreferrer" target="_blank">ftp://www.linux-mips.org/pub/<wbr>linux/mips/doc/ABI/mipsabi.pdf</a><br>
- Out<ELFT>::MipsRldMap = make<OutputSection<ELFT>>(".<wbr>rld_map", SHT_PROGBITS,<br>
- SHF_ALLOC | SHF_WRITE);<br>
- Out<ELFT>::MipsRldMap->Size = sizeof(uintX_t);<br>
- Out<ELFT>::MipsRldMap-><wbr>updateAlignment(sizeof(uintX_<wbr>t));<br>
- }<br>
if (!Config->VersionDefinitions.<wbr>empty())<br>
In<ELFT>::VerDef = make<VersionDefinitionSection<<wbr>ELFT>>();<br>
<br>
@@ -307,6 +297,10 @@ template <class ELFT> void Writer<ELFT>:<br>
<br>
// Add MIPS-specific sections.<br>
if (Config->EMachine == EM_MIPS) {<br>
+ if (!Config->Shared && In<ELFT>::DynSymTab) {<br>
+ In<ELFT>::MipsRldMap = make<MipsRldMap<ELFT>>();<br>
+ Symtab<ELFT>::X->Sections.<wbr>push_back(In<ELFT>::<wbr>MipsRldMap);<br>
+ }<br>
if (auto *Sec = MipsAbiFlagsSection<ELFT>::<wbr>create())<br>
Symtab<ELFT>::X->Sections.<wbr>push_back(Sec);<br>
if (auto *Sec = MipsOptionsSection<ELFT>::<wbr>create())<br>
@@ -1009,7 +1003,6 @@ template <class ELFT> void Writer<ELFT>:<br>
addInputSec(In<ELFT>::<wbr>DynStrTab);<br>
if (In<ELFT>::RelaDyn->hasRelocs(<wbr>))<br>
addInputSec(In<ELFT>::RelaDyn)<wbr>;<br>
- Add(Out<ELFT>::MipsRldMap);<br>
}<br>
<br>
// We always need to add rel[a].plt to output if it has entries.<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>