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

hfinkel@anl.gov via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 13:27:41 PDT 2015


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13365.36290.patch
Type: text/x-patch
Size: 945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151001/4d39ea7b/attachment.bin>


More information about the llvm-commits mailing list