COFF: Fix the import table Hint/Name field.

llvm-svn: 238719
This commit is contained in:
Rui Ueyama 2015-06-01 03:55:04 +00:00
parent 68216c680d
commit 5b25edddfe
2 changed files with 7 additions and 5 deletions

View File

@ -171,8 +171,11 @@ void ImportThunkChunk::applyRelocations(uint8_t *Buf) {
write32le(Buf + FileOff + 2, Operand); write32le(Buf + FileOff + 2, Operand);
} }
HintNameChunk::HintNameChunk(StringRef N, uint16_t H) size_t HintNameChunk::getSize() const {
: Name(N), Hint(H), Size(RoundUpToAlignment(Name.size() + 4, 2)) {} // 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) { void HintNameChunk::writeTo(uint8_t *Buf) {
write16le(Buf + FileOff, Hint); write16le(Buf + FileOff, Hint);

View File

@ -194,14 +194,13 @@ private:
// A chunk for the import descriptor table. // A chunk for the import descriptor table.
class HintNameChunk : public Chunk { class HintNameChunk : public Chunk {
public: public:
HintNameChunk(StringRef Name, uint16_t Hint); HintNameChunk(StringRef N, uint16_t H) : Name(N), Hint(H) {}
size_t getSize() const override { return Size; } size_t getSize() const override;
void writeTo(uint8_t *Buf) override; void writeTo(uint8_t *Buf) override;
private: private:
StringRef Name; StringRef Name;
uint16_t Hint; uint16_t Hint;
size_t Size;
}; };
// A chunk for the import descriptor table. // A chunk for the import descriptor table.