[lld] r286499 - Make the .idata$4 and .idata$5 import lib sections 8 bytes on x64
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 10 12:38:58 PST 2016
Author: rnk
Date: Thu Nov 10 14:38:58 2016
New Revision: 286499
URL: http://llvm.org/viewvc/llvm-project?rev=286499&view=rev
Log:
Make the .idata$4 and .idata$5 import lib sections 8 bytes on x64
The MSVC linker relies on this invariant to produce a valid import
table. More ASan tests pass in a stage 2 build now. They still fail when
using LLD since there are no PDBs for the dynamic ASan runtime.
Modified:
lld/trunk/COFF/Librarian.cpp
Modified: lld/trunk/COFF/Librarian.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Librarian.cpp?rev=286499&r1=286498&r2=286499&view=diff
==============================================================================
--- lld/trunk/COFF/Librarian.cpp (original)
+++ lld/trunk/COFF/Librarian.cpp Thu Nov 10 14:38:58 2016
@@ -352,15 +352,16 @@ ObjectFactory::createNullImportDescripto
NewArchiveMember ObjectFactory::createNullThunk(std::vector<uint8_t> &Buffer) {
static const uint32_t NumberOfSections = 2;
static const uint32_t NumberOfSymbols = 1;
+ uint32_t VASize = is32bit() ? 4 : 8;
// COFF Header
coff_file_header Header{
u16(Config->Machine), u16(NumberOfSections), u32(0),
u32(sizeof(Header) + (NumberOfSections * sizeof(coff_section)) +
// .idata$5
- sizeof(export_address_table_entry) +
+ VASize +
// .idata$4
- sizeof(export_address_table_entry)),
+ VASize),
u32(NumberOfSymbols), u16(0),
u16(is32bit() ? IMAGE_FILE_32BIT_MACHINE : 0),
};
@@ -371,36 +372,40 @@ NewArchiveMember ObjectFactory::createNu
{{'.', 'i', 'd', 'a', 't', 'a', '$', '5'},
u32(0),
u32(0),
- u32(sizeof(export_address_table_entry)),
+ u32(VASize),
u32(sizeof(coff_file_header) + NumberOfSections * sizeof(coff_section)),
u32(0),
u32(0),
u16(0),
u16(0),
- u32(IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_CNT_INITIALIZED_DATA |
- IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE)},
+ u32((is32bit() ? IMAGE_SCN_ALIGN_4BYTES : IMAGE_SCN_ALIGN_8BYTES) |
+ IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ |
+ IMAGE_SCN_MEM_WRITE)},
{{'.', 'i', 'd', 'a', 't', 'a', '$', '4'},
u32(0),
u32(0),
- u32(sizeof(export_address_table_entry)),
+ u32(VASize),
u32(sizeof(coff_file_header) + NumberOfSections * sizeof(coff_section) +
- sizeof(export_address_table_entry)),
+ VASize),
u32(0),
u32(0),
u16(0),
u16(0),
- u32(IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_CNT_INITIALIZED_DATA |
- IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE)},
+ u32((is32bit() ? IMAGE_SCN_ALIGN_4BYTES : IMAGE_SCN_ALIGN_8BYTES) |
+ IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ |
+ IMAGE_SCN_MEM_WRITE)},
};
append(Buffer, SectionTable);
- // .idata$5
- static const export_address_table_entry ILT{u32(0)};
- append(Buffer, ILT);
+ // .idata$5, ILT
+ append(Buffer, u32(0));
+ if (!is32bit())
+ append(Buffer, u32(0));
- // .idata$4
- static const export_address_table_entry IAT{u32(0)};
- append(Buffer, IAT);
+ // .idata$4, IAT
+ append(Buffer, u32(0));
+ if (!is32bit())
+ append(Buffer, u32(0));
// Symbol Table
coff_symbol16 SymbolTable[NumberOfSymbols] = {
More information about the llvm-commits
mailing list