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
diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp
index 30a1364..daf2ff6 100644
--- a/lld/COFF/Chunks.cpp
+++ b/lld/COFF/Chunks.cpp
@@ -221,6 +221,15 @@
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 @@
}
}
-void LocalImportChunk::writeTo(uint8_t *Buf) {
- write32le(Buf + FileOff, Sym->getRVA());
-}
-
void BaserelChunk::writeTo(uint8_t *Buf) {
memcpy(Buf + FileOff, Data.data(), Data.size());
}