[lld] r241295 - COFF: Fix locally-imported symbols.
Rui Ueyama
ruiu at google.com
Thu Jul 2 13:33:51 PDT 2015
Author: ruiu
Date: Thu Jul 2 15:33:50 2015
New Revision: 241295
URL: http://llvm.org/viewvc/llvm-project?rev=241295&view=rev
Log:
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.
Modified:
lld/trunk/COFF/Chunks.cpp
lld/trunk/COFF/Chunks.h
lld/trunk/test/COFF/locally-imported.test
Modified: lld/trunk/COFF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.cpp?rev=241295&r1=241294&r2=241295&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Thu Jul 2 15:33:50 2015
@@ -221,6 +221,15 @@ void ImportThunkChunk::writeTo(uint8_t *
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
}
}
-void LocalImportChunk::writeTo(uint8_t *Buf) {
- write32le(Buf + FileOff, Sym->getRVA());
-}
-
void BaserelChunk::writeTo(uint8_t *Buf) {
memcpy(Buf + FileOff, Data.data(), Data.size());
}
Modified: lld/trunk/COFF/Chunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.h?rev=241295&r1=241294&r2=241295&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.h (original)
+++ lld/trunk/COFF/Chunks.h Thu Jul 2 15:33:50 2015
@@ -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:
Modified: lld/trunk/test/COFF/locally-imported.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/locally-imported.test?rev=241295&r1=241294&r2=241295&view=diff
==============================================================================
--- lld/trunk/test/COFF/locally-imported.test (original)
+++ lld/trunk/test/COFF/locally-imported.test Thu Jul 2 15:33:50 2015
@@ -6,7 +6,7 @@
# CHECK-NEXT: 1000 00200000
# CHECK: Contents of section .rdata:
-# CHECK-NEXT: 2000 04100000
+# CHECK-NEXT: 2000 04100040 01000000
---
header:
More information about the llvm-commits
mailing list