[lld] r287675 - [ELF] Convert .rld_map to input section

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 22 10:18:51 PST 2016


On Tue, Nov 22, 2016 at 9:49 AM, Eugene Leviant via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: evgeny777
> Date: Tue Nov 22 11:49:14 2016
> New Revision: 287675
>
> URL: http://llvm.org/viewvc/llvm-project?rev=287675&view=rev
> Log:
> [ELF] Convert .rld_map to input section
>
> Differential revision: https://reviews.llvm.org/D26958
>
> Modified:
>     lld/trunk/ELF/OutputSections.h
>     lld/trunk/ELF/SyntheticSections.cpp
>     lld/trunk/ELF/SyntheticSections.h
>     lld/trunk/ELF/Writer.cpp
>
> Modified: lld/trunk/ELF/OutputSections.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/
> OutputSections.h?rev=287675&r1=287674&r2=287675&view=diff
> ============================================================
> ==================
> --- lld/trunk/ELF/OutputSections.h (original)
> +++ lld/trunk/ELF/OutputSections.h Tue Nov 22 11:49:14 2016
> @@ -201,7 +201,6 @@ template <class ELFT> struct Out {
>    static uint8_t First;
>    static EhOutputSection<ELFT> *EhFrame;
>    static OutputSection<ELFT> *Bss;
> -  static OutputSection<ELFT> *MipsRldMap;
>    static OutputSectionBase *Opd;
>    static uint8_t *OpdBuf;
>    static Elf_Phdr *TlsPhdr;
> @@ -249,7 +248,6 @@ template <class ELFT> uint64_t getHeader
>  template <class ELFT> uint8_t Out<ELFT>::First;
>  template <class ELFT> EhOutputSection<ELFT> *Out<ELFT>::EhFrame;
>  template <class ELFT> OutputSection<ELFT> *Out<ELFT>::Bss;
> -template <class ELFT> OutputSection<ELFT> *Out<ELFT>::MipsRldMap;
>  template <class ELFT> OutputSectionBase *Out<ELFT>::Opd;
>  template <class ELFT> uint8_t *Out<ELFT>::OpdBuf;
>  template <class ELFT> typename ELFT::Phdr *Out<ELFT>::TlsPhdr;
>
> Modified: lld/trunk/ELF/SyntheticSections.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/
> SyntheticSections.cpp?rev=287675&r1=287674&r2=287675&view=diff
> ============================================================
> ==================
> --- lld/trunk/ELF/SyntheticSections.cpp (original)
> +++ lld/trunk/ELF/SyntheticSections.cpp Tue Nov 22 11:49:14 2016
> @@ -18,6 +18,7 @@
>  #include "Config.h"
>  #include "Error.h"
>  #include "InputFiles.h"
> +#include "LinkerScript.h"
>  #include "Memory.h"
>  #include "OutputSections.h"
>  #include "Strings.h"
> @@ -883,8 +884,8 @@ template <class ELFT> void DynamicSectio
>      else
>        add({DT_MIPS_GOTSYM, In<ELFT>::DynSymTab->getNumSymbols()});
>      add({DT_PLTGOT, In<ELFT>::MipsGot});
> -    if (Out<ELFT>::MipsRldMap)
> -      add({DT_MIPS_RLD_MAP, Out<ELFT>::MipsRldMap});
> +    if (In<ELFT>::MipsRldMap)
> +      add({DT_MIPS_RLD_MAP, In<ELFT>::MipsRldMap});
>    }
>
>    this->OutSec->Entsize = this->Entsize;
> @@ -1655,6 +1656,19 @@ template <class ELFT> size_t VersionNeed
>    return Size;
>  }
>
> +template <class ELFT>
> +MipsRldMap<ELFT>::MipsRldMap()
> +    : SyntheticSection<ELFT>(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS,
> +                             sizeof(typename ELFT::uint), ".rld_map") {}
> +
> +template <class ELFT> void MipsRldMap<ELFT>::writeTo(uint8_t *Buf) {
> +
>

nit: remove this blank line.


> +  // Apply filler from linker script.
> +  uint64_t Filler = Script<ELFT>::X->getFiller(this->Name);
> +  Filler = (Filler << 32) | Filler;
> +  memcpy(Buf, &Filler, getSize());
> +}
> +
>  template InputSection<ELF32LE> *elf::createCommonSection();
>  template InputSection<ELF32BE> *elf::createCommonSection();
>  template InputSection<ELF64LE> *elf::createCommonSection();
> @@ -1764,3 +1778,8 @@ template class elf::VersionDefinitionSec
>  template class elf::VersionDefinitionSection<ELF32BE>;
>  template class elf::VersionDefinitionSection<ELF64LE>;
>  template class elf::VersionDefinitionSection<ELF64BE>;
> +
> +template class elf::MipsRldMap<ELF32LE>;
> +template class elf::MipsRldMap<ELF32BE>;
> +template class elf::MipsRldMap<ELF64LE>;
> +template class elf::MipsRldMap<ELF64BE>;
>
> Modified: lld/trunk/ELF/SyntheticSections.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/
> SyntheticSections.h?rev=287675&r1=287674&r2=287675&view=diff
> ============================================================
> ==================
> --- lld/trunk/ELF/SyntheticSections.h (original)
> +++ lld/trunk/ELF/SyntheticSections.h Tue Nov 22 11:49:14 2016
> @@ -599,6 +599,17 @@ private:
>    Elf_Mips_RegInfo Reginfo;
>  };
>
> +// This is a MIPS specific section to hold a space within the data segment
> +// of executable file which is pointed to by the DT_MIPS_RLD_MAP entry.
> +// See "Dynamic section" in Chapter 5 in the following document:
> +// ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
> +template <class ELFT> class MipsRldMap : public SyntheticSection<ELFT> {
> +public:
> +  MipsRldMap();
> +  size_t getSize() const override { return sizeof(typename ELFT::uint); }
> +  void writeTo(uint8_t *Buf) override;
> +};
> +
>  template <class ELFT> InputSection<ELFT> *createCommonSection();
>  template <class ELFT> InputSection<ELFT> *createInterpSection();
>  template <class ELFT> MergeInputSection<ELFT> *createCommentSection();
> @@ -618,6 +629,7 @@ template <class ELFT> struct In {
>    static GotPltSection<ELFT> *GotPlt;
>    static HashTableSection<ELFT> *HashTab;
>    static InputSection<ELFT> *Interp;
> +  static MipsRldMap<ELFT> *MipsRldMap;
>    static PltSection<ELFT> *Plt;
>    static RelocationSection<ELFT> *RelaDyn;
>    static RelocationSection<ELFT> *RelaPlt;
> @@ -642,6 +654,7 @@ template <class ELFT> MipsGotSection<ELF
>  template <class ELFT> GotPltSection<ELFT> *In<ELFT>::GotPlt;
>  template <class ELFT> HashTableSection<ELFT> *In<ELFT>::HashTab;
>  template <class ELFT> InputSection<ELFT> *In<ELFT>::Interp;
> +template <class ELFT> MipsRldMap<ELFT> *In<ELFT>::MipsRldMap;
>  template <class ELFT> PltSection<ELFT> *In<ELFT>::Plt;
>  template <class ELFT> RelocationSection<ELFT> *In<ELFT>::RelaDyn;
>  template <class ELFT> RelocationSection<ELFT> *In<ELFT>::RelaPlt;
>
> Modified: lld/trunk/ELF/Writer.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.
> cpp?rev=287675&r1=287674&r2=287675&view=diff
> ============================================================
> ==================
> --- lld/trunk/ELF/Writer.cpp (original)
> +++ lld/trunk/ELF/Writer.cpp Tue Nov 22 11:49:14 2016
> @@ -277,16 +277,6 @@ template <class ELFT> void Writer<ELFT>:
>      In<ELFT>::SymTab = make<SymbolTableSection<ELFT>>(*In<ELFT>::StrTab);
>    }
>
> -  if (Config->EMachine == EM_MIPS && !Config->Shared) {
> -    // This is a MIPS specific section to hold a space within the data
> segment
> -    // of executable file which is pointed to by the DT_MIPS_RLD_MAP
> entry.
> -    // See "Dynamic section" in Chapter 5 in the following document:
> -    // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
> -    Out<ELFT>::MipsRldMap = make<OutputSection<ELFT>>(".rld_map",
> SHT_PROGBITS,
> -                                                      SHF_ALLOC |
> SHF_WRITE);
> -    Out<ELFT>::MipsRldMap->Size = sizeof(uintX_t);
> -    Out<ELFT>::MipsRldMap->updateAlignment(sizeof(uintX_t));
> -  }
>    if (!Config->VersionDefinitions.empty())
>      In<ELFT>::VerDef = make<VersionDefinitionSection<ELFT>>();
>
> @@ -307,6 +297,10 @@ template <class ELFT> void Writer<ELFT>:
>
>    // Add MIPS-specific sections.
>    if (Config->EMachine == EM_MIPS) {
> +    if (!Config->Shared && In<ELFT>::DynSymTab) {
> +      In<ELFT>::MipsRldMap = make<MipsRldMap<ELFT>>();
> +      Symtab<ELFT>::X->Sections.push_back(In<ELFT>::MipsRldMap);
> +    }
>      if (auto *Sec = MipsAbiFlagsSection<ELFT>::create())
>        Symtab<ELFT>::X->Sections.push_back(Sec);
>      if (auto *Sec = MipsOptionsSection<ELFT>::create())
> @@ -1009,7 +1003,6 @@ template <class ELFT> void Writer<ELFT>:
>      addInputSec(In<ELFT>::DynStrTab);
>      if (In<ELFT>::RelaDyn->hasRelocs())
>        addInputSec(In<ELFT>::RelaDyn);
> -    Add(Out<ELFT>::MipsRldMap);
>    }
>
>    // We always need to add rel[a].plt to output if it has entries.
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161122/77d48dfa/attachment.html>


More information about the llvm-commits mailing list