[PATCH] D13365: [ELF2] Fix mixed-Endian handling in DynamicSection<ELFT>::writeTo

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 06:48:03 PDT 2015


It should be possible to add a testcase with a big ending .o file that
is currently failing when running on a little endian machine, no?
LGTM wit that.

On 1 October 2015 at 16:27, hfinkel at anl.gov <hfinkel at anl.gov> wrote:
> hfinkel created this revision.
> hfinkel added reviewers: ruiu, rafael.
> hfinkel added a subscriber: llvm-commits.
> hfinkel added a project: lld.
>
> Using the "raw" Elf64_Dyn or Elf32_Dyn structures in DynamicSection<ELFT>::writeTo does not correctly handle mixed-Endian situations. Instead, use the corresponding llvm::object::* structures which have Endian-converting members (like the rest of the code).
>
> This fixes all currently-failing elf2 tests when running on big-Endian PPC64/Linux.
>
>
> http://reviews.llvm.org/D13365
>
> Files:
>   ELF/OutputSections.cpp
>   ELF/OutputSections.h
>
> Index: ELF/OutputSections.h
> ===================================================================
> --- ELF/OutputSections.h
> +++ ELF/OutputSections.h
> @@ -316,6 +316,7 @@
>    typedef typename llvm::object::ELFFile<ELFT>::Elf_Rel Elf_Rel;
>    typedef typename llvm::object::ELFFile<ELFT>::Elf_Rela Elf_Rela;
>    typedef typename llvm::object::ELFFile<ELFT>::Elf_Sym Elf_Sym;
> +  typedef typename llvm::object::ELFFile<ELFT>::Elf_Dyn Elf_Dyn;
>
>  public:
>    DynamicSection(SymbolTable &SymTab, HashTableSection<ELFT> &HashSec,
> Index: ELF/OutputSections.cpp
> ===================================================================
> --- ELF/OutputSections.cpp
> +++ ELF/OutputSections.cpp
> @@ -216,8 +216,6 @@
>  }
>
>  template <class ELFT> void DynamicSection<ELFT>::writeTo(uint8_t *Buf) {
> -  typedef typename std::conditional<ELFT::Is64Bits, Elf64_Dyn, Elf32_Dyn>::type
> -      Elf_Dyn;
>    auto *P = reinterpret_cast<Elf_Dyn *>(Buf);
>
>    if (RelaDynSec.hasRelocs()) {
>
>


More information about the llvm-commits mailing list