[COFF] Use the correct size of the TLS directory

The TLS directory has a different layout depending on the bitness of the
machine the image will run on.  LLD would always use the 64-bit TLS
directory for the data directory entry instead of an appropriately sized
TLS directory.

llvm-svn: 263539
This commit is contained in:
David Majnemer 2016-03-15 06:41:02 +00:00
parent 0c2adbc7a0
commit 22a19a9ace
2 changed files with 4 additions and 2 deletions

View File

@ -596,7 +596,9 @@ template <typename PEHeaderTy> void Writer::writeHeader() {
if (Symbol *Sym = Symtab->findUnderscore("_tls_used")) {
if (Defined *B = dyn_cast<Defined>(Sym->Body)) {
Dir[TLS_TABLE].RelativeVirtualAddress = B->getRVA();
Dir[TLS_TABLE].Size = 40;
Dir[TLS_TABLE].Size = Config->is64()
? sizeof(object::coff_tls_directory64)
: sizeof(object::coff_tls_directory32);
}
}
if (Symbol *Sym = Symtab->findUnderscore("_load_config_used")) {

View File

@ -3,7 +3,7 @@
# RUN: llvm-readobj -file-headers %t.exe | FileCheck %s
# CHECK: TLSTableRVA: 0x1000
# CHECK: TLSTableSize: 0x28
# CHECK: TLSTableSize: 0x18
---
header: