[lld] r234928 - [ELF] Use type helper Elf_Word instead of plain uint32_t data type

Simon Atanasyan simon at atanasyan.com
Tue Apr 14 11:53:21 PDT 2015


Author: atanasyan
Date: Tue Apr 14 13:53:21 2015
New Revision: 234928

URL: http://llvm.org/viewvc/llvm-project?rev=234928&view=rev
Log:
[ELF] Use type helper Elf_Word instead of plain uint32_t data type

That helps to correctly write content of hash table if target and host
endianness are not the same. Right now that commit does not affect
any supported targets.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h

Modified: lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h?rev=234928&r1=234927&r2=234928&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h Tue Apr 14 13:53:21 2015
@@ -1408,22 +1408,25 @@ public:
              llvm::FileOutputBuffer &buffer) override {
     uint8_t *chunkBuffer = buffer.getBufferStart();
     uint8_t *dest = chunkBuffer + this->fileOffset();
-    uint32_t bucketChainCounts[2];
+    Elf_Word bucketChainCounts[2];
     bucketChainCounts[0] = _buckets.size();
     bucketChainCounts[1] = _chains.size();
     std::memcpy(dest, bucketChainCounts, sizeof(bucketChainCounts));
     dest += sizeof(bucketChainCounts);
     // write bucket values
-    std::memcpy(dest, _buckets.data(), _buckets.size() * sizeof(uint32_t));
-    dest += _buckets.size() * sizeof(uint32_t);
+    std::memcpy(dest, _buckets.data(), _buckets.size() * sizeof(Elf_Word));
+    dest += _buckets.size() * sizeof(Elf_Word);
     // write chain values
-    std::memcpy(dest, _chains.data(), _chains.size() * sizeof(uint32_t));
+    std::memcpy(dest, _chains.data(), _chains.size() * sizeof(Elf_Word));
   }
 
 private:
+  typedef
+      typename llvm::object::ELFDataTypeTypedefHelper<ELFT>::Elf_Word Elf_Word;
+
   std::vector<SymbolTableEntry> _entries;
-  std::vector<uint32_t> _buckets;
-  std::vector<uint32_t> _chains;
+  std::vector<Elf_Word> _buckets;
+  std::vector<Elf_Word> _chains;
   const DynamicSymbolTable<ELFT> *_symbolTable = nullptr;
 };
 





More information about the llvm-commits mailing list