Index: lld/trunk/COFF/Driver.cpp =================================================================== --- lld/trunk/COFF/Driver.cpp +++ lld/trunk/COFF/Driver.cpp @@ -662,9 +662,8 @@ } // Windows specific -- if __load_config_used can be resolved, resolve it. - if (Symbol *Sym = Symtab.find(Config->LoadConfigUsed)) - if (isa(Sym->Body)) - Symtab.addUndefined(Config->LoadConfigUsed); + if (Symtab.find(Config->LoadConfigUsed)) + addUndefined(Config->LoadConfigUsed); if (Symtab.queueEmpty()) break; Index: lld/trunk/test/COFF/loadcfg.ll =================================================================== --- lld/trunk/test/COFF/loadcfg.ll +++ lld/trunk/test/COFF/loadcfg.ll @@ -0,0 +1,15 @@ +; RUN: llvm-as -o %t.obj %s +; RUN: lld -flavor link2 /out:%t.exe %t.obj /entry:main /subsystem:console +; RUN: llvm-readobj -file-headers %t.exe | FileCheck %s + +; CHECK: LoadConfigTableRVA: 0x1000 +; CHECK: LoadConfigTableSize: 0x70 + +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc" + +@_load_config_used = constant i32 1 + +define void @main() { + ret void +} Index: lld/trunk/test/COFF/loadcfg.test =================================================================== --- lld/trunk/test/COFF/loadcfg.test +++ lld/trunk/test/COFF/loadcfg.test @@ -2,7 +2,7 @@ # RUN: lld -flavor link2 /out:%t.exe %t.obj /entry:main /subsystem:console # RUN: llvm-readobj -file-headers %t.exe | FileCheck %s -# CHECK: LoadConfigTableRVA: 0x1000 +# CHECK: LoadConfigTableRVA: 0x1008 # CHECK: LoadConfigTableSize: 0x70 --- @@ -14,6 +14,10 @@ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 4 SectionData: B82A000000C3 + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: B82A000000C3 symbols: - Name: .text Value: 0 @@ -27,6 +31,19 @@ NumberOfLinenumbers: 0 CheckSum: 0 Number: 0 + - Name: .text + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 6 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + Selection: IMAGE_COMDAT_SELECT_ANY - Name: main Value: 0 SectionNumber: 1 @@ -35,7 +52,7 @@ StorageClass: IMAGE_SYM_CLASS_EXTERNAL - Name: _load_config_used Value: 0 - SectionNumber: 1 + SectionNumber: 2 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_EXTERNAL