[lld] r238719 - COFF: Fix the import table Hint/Name field.

Rui Ueyama ruiu at google.com
Sun May 31 20:55:04 PDT 2015


Author: ruiu
Date: Sun May 31 22:55:04 2015
New Revision: 238719

URL: http://llvm.org/viewvc/llvm-project?rev=238719&view=rev
Log:
COFF: Fix the import table Hint/Name field.

Modified:
    lld/trunk/COFF/Chunks.cpp
    lld/trunk/COFF/Chunks.h

Modified: lld/trunk/COFF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.cpp?rev=238719&r1=238718&r2=238719&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Sun May 31 22:55:04 2015
@@ -171,8 +171,11 @@ void ImportThunkChunk::applyRelocations(
   write32le(Buf + FileOff + 2, Operand);
 }
 
-HintNameChunk::HintNameChunk(StringRef N, uint16_t H)
-    : Name(N), Hint(H), Size(RoundUpToAlignment(Name.size() + 4, 2)) {}
+size_t HintNameChunk::getSize() const {
+  // Starts with 2 byte Hint field, followed by a null-terminated string,
+  // ends with 0 or 1 byte padding.
+  return RoundUpToAlignment(Name.size() + 3, 2);
+}
 
 void HintNameChunk::writeTo(uint8_t *Buf) {
   write16le(Buf + FileOff, Hint);

Modified: lld/trunk/COFF/Chunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.h?rev=238719&r1=238718&r2=238719&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.h (original)
+++ lld/trunk/COFF/Chunks.h Sun May 31 22:55:04 2015
@@ -194,14 +194,13 @@ private:
 // A chunk for the import descriptor table.
 class HintNameChunk : public Chunk {
 public:
-  HintNameChunk(StringRef Name, uint16_t Hint);
-  size_t getSize() const override { return Size; }
+  HintNameChunk(StringRef N, uint16_t H) : Name(N), Hint(H) {}
+  size_t getSize() const override;
   void writeTo(uint8_t *Buf) override;
 
 private:
   StringRef Name;
   uint16_t Hint;
-  size_t Size;
 };
 
 // A chunk for the import descriptor table.





More information about the llvm-commits mailing list