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

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 08:12:25 PDT 2015


----- Original Message -----
> From: "Rafael EspĂ­ndola" <rafael.espindola at gmail.com>
> To: reviews+D13365+public+c4deb05b041f4664 at reviews.llvm.org
> Cc: "Hal Finkel" <hfinkel at anl.gov>, "Rui Ueyama" <ruiu at google.com>, "llvm-commits" <llvm-commits at lists.llvm.org>,
> "Adhemerval Zanella" <adhemerval.zanella at linaro.org>
> Sent: Friday, October 2, 2015 8:48:03 AM
> Subject: Re: [PATCH] D13365: [ELF2] Fix mixed-Endian handling in DynamicSection<ELFT>::writeTo
> 
> 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.

Actually, I think I can just make the existing test cases run for targets of both Endian choices. Then one or the other would fail depending on the host byte ordering.

Thanks again,
Hal

> 
> 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()) {
> >
> >
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory


More information about the llvm-commits mailing list