Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lld/COFF
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-06-26 21:28:56 +0300
committerRui Ueyama <ruiu@google.com>2015-06-26 21:28:56 +0300
commit7383562bc9726a12f2758645d0911b859af73f8f (patch)
tree9614c5a3ce6efc7d849a3f751317e64aacc54283 /lld/COFF
parent3af9a25b65ae8684fbc2b73ead7c7f15e5e67e22 (diff)
COFF: Align DLL import thunks on 16-byte boundaries.
llvm-svn: 240806
Diffstat (limited to 'lld/COFF')
-rw-r--r--lld/COFF/Chunks.cpp6
-rw-r--r--lld/COFF/Chunks.h2
2 files changed, 7 insertions, 1 deletions
diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp
index c5cf80ec7758..aa2c0be3ef51 100644
--- a/lld/COFF/Chunks.cpp
+++ b/lld/COFF/Chunks.cpp
@@ -216,6 +216,12 @@ void StringChunk::writeTo(uint8_t *Buf) {
memcpy(Buf + FileOff, Str.data(), Str.size());
}
+ImportThunkChunk::ImportThunkChunk(Defined *S) : ImpSymbol(S) {
+ // Intel Optimization Manual says that all branch targets
+ // should be 16-byte aligned. MSVC linker does this too.
+ Align = 16;
+}
+
void ImportThunkChunk::writeTo(uint8_t *Buf) {
memcpy(Buf + FileOff, ImportThunkData, sizeof(ImportThunkData));
// The first two bytes is a JMP instruction. Fill its operand.
diff --git a/lld/COFF/Chunks.h b/lld/COFF/Chunks.h
index d44c02550836..37a6003cf8ec 100644
--- a/lld/COFF/Chunks.h
+++ b/lld/COFF/Chunks.h
@@ -198,7 +198,7 @@ static const uint8_t ImportThunkData[] = {
// contents will be a JMP instruction to some __imp_ symbol.
class ImportThunkChunk : public Chunk {
public:
- explicit ImportThunkChunk(Defined *S) : ImpSymbol(S) {}
+ explicit ImportThunkChunk(Defined *ImpSymbol);
size_t getSize() const override { return sizeof(ImportThunkData); }
void writeTo(uint8_t *Buf) override;