Skip to content

Commit e7107ec

Browse files
committedJul 31, 2015
COFF: When resolving _load_config_used, add it as a GC root.
This fixes the cases where the symbol is defined in a comdat or by bitcode. Differential Revision: http://reviews.llvm.org/D11673 llvm-svn: 243735
1 parent 4be014a commit e7107ec

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed
 

‎lld/COFF/Driver.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,8 @@ bool LinkerDriver::link(llvm::ArrayRef<const char *> ArgsArr) {
662662
}
663663

664664
// Windows specific -- if __load_config_used can be resolved, resolve it.
665-
if (Symbol *Sym = Symtab.find(Config->LoadConfigUsed))
666-
if (isa<Lazy>(Sym->Body))
667-
Symtab.addUndefined(Config->LoadConfigUsed);
665+
if (Symtab.find(Config->LoadConfigUsed))
666+
addUndefined(Config->LoadConfigUsed);
668667

669668
if (Symtab.queueEmpty())
670669
break;

‎lld/test/COFF/loadcfg.ll

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; RUN: llvm-as -o %t.obj %s
2+
; RUN: lld -flavor link2 /out:%t.exe %t.obj /entry:main /subsystem:console
3+
; RUN: llvm-readobj -file-headers %t.exe | FileCheck %s
4+
5+
; CHECK: LoadConfigTableRVA: 0x1000
6+
; CHECK: LoadConfigTableSize: 0x70
7+
8+
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
9+
target triple = "x86_64-pc-windows-msvc"
10+
11+
@_load_config_used = constant i32 1
12+
13+
define void @main() {
14+
ret void
15+
}

‎lld/test/COFF/loadcfg.test

+19-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# RUN: lld -flavor link2 /out:%t.exe %t.obj /entry:main /subsystem:console
33
# RUN: llvm-readobj -file-headers %t.exe | FileCheck %s
44

5-
# CHECK: LoadConfigTableRVA: 0x1000
5+
# CHECK: LoadConfigTableRVA: 0x1008
66
# CHECK: LoadConfigTableSize: 0x70
77

88
---
@@ -14,6 +14,10 @@ sections:
1414
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
1515
Alignment: 4
1616
SectionData: B82A000000C3
17+
- Name: .text
18+
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
19+
Alignment: 4
20+
SectionData: B82A000000C3
1721
symbols:
1822
- Name: .text
1923
Value: 0
@@ -27,6 +31,19 @@ symbols:
2731
NumberOfLinenumbers: 0
2832
CheckSum: 0
2933
Number: 0
34+
- Name: .text
35+
Value: 0
36+
SectionNumber: 2
37+
SimpleType: IMAGE_SYM_TYPE_NULL
38+
ComplexType: IMAGE_SYM_DTYPE_NULL
39+
StorageClass: IMAGE_SYM_CLASS_STATIC
40+
SectionDefinition:
41+
Length: 6
42+
NumberOfRelocations: 0
43+
NumberOfLinenumbers: 0
44+
CheckSum: 0
45+
Number: 0
46+
Selection: IMAGE_COMDAT_SELECT_ANY
3047
- Name: main
3148
Value: 0
3249
SectionNumber: 1
@@ -35,7 +52,7 @@ symbols:
3552
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
3653
- Name: _load_config_used
3754
Value: 0
38-
SectionNumber: 1
55+
SectionNumber: 2
3956
SimpleType: IMAGE_SYM_TYPE_NULL
4057
ComplexType: IMAGE_SYM_DTYPE_NULL
4158
StorageClass: IMAGE_SYM_CLASS_EXTERNAL

0 commit comments

Comments
 (0)