COFF: Fix locally-imported symbols.
Previously, pointers pointed by locally-imported symbols were broken. It has only 4 bytes although the correct size is 8 byte. This patch fixes that bug. llvm-svn: 241295
This commit is contained in:
parent
65813edfe2
commit
7a333c66be
|
@ -221,6 +221,15 @@ void ImportThunkChunk::writeTo(uint8_t *Buf) {
|
|||
write32le(Buf + FileOff + 2, Operand);
|
||||
}
|
||||
|
||||
void LocalImportChunk::getBaserels(std::vector<uint32_t> *Res,
|
||||
Defined *ImageBase) {
|
||||
Res->push_back(getRVA() + Config->ImageBase);
|
||||
}
|
||||
|
||||
void LocalImportChunk::writeTo(uint8_t *Buf) {
|
||||
write64le(Buf + FileOff, Sym->getRVA() + Config->ImageBase);
|
||||
}
|
||||
|
||||
// Windows-specific.
|
||||
// This class represents a block in .reloc section.
|
||||
BaserelChunk::BaserelChunk(uint32_t Page, uint32_t *Begin, uint32_t *End) {
|
||||
|
@ -237,10 +246,6 @@ BaserelChunk::BaserelChunk(uint32_t Page, uint32_t *Begin, uint32_t *End) {
|
|||
}
|
||||
}
|
||||
|
||||
void LocalImportChunk::writeTo(uint8_t *Buf) {
|
||||
write32le(Buf + FileOff, Sym->getRVA());
|
||||
}
|
||||
|
||||
void BaserelChunk::writeTo(uint8_t *Buf) {
|
||||
memcpy(Buf + FileOff, Data.data(), Data.size());
|
||||
}
|
||||
|
|
|
@ -243,7 +243,8 @@ private:
|
|||
class LocalImportChunk : public Chunk {
|
||||
public:
|
||||
explicit LocalImportChunk(Defined *S) : Sym(S) {}
|
||||
size_t getSize() const override { return 4; }
|
||||
size_t getSize() const override { return 8; }
|
||||
void getBaserels(std::vector<uint32_t> *Res, Defined *ImageBase) override;
|
||||
void writeTo(uint8_t *Buf) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# CHECK-NEXT: 1000 00200000
|
||||
|
||||
# CHECK: Contents of section .rdata:
|
||||
# CHECK-NEXT: 2000 04100000
|
||||
# CHECK-NEXT: 2000 04100040 01000000
|
||||
|
||||
---
|
||||
header:
|
||||
|
|
Loading…
Reference in New Issue