3 # Make a DLL that exports exportfn1.
4 # RUN: yaml2obj %p/Inputs/export.yaml -o %basename_t-exp.obj
5 # RUN: lld-link /out:%basename_t-exp.dll /dll %basename_t-exp.obj /export:exportfn1 /implib:%basename_t-exp.lib
7 # Make an object file that imports exportfn1.
8 # RUN: llvm-mc -triple x86_64-windows-msvc %s -filetype=obj -o %basename_t.obj
10 # Check that the Guard address-taken IAT entry tables are propagated to the final executable.
11 # RUN: lld-link %basename_t.obj -guard:cf -entry:main -out:%basename_t-nodelay.exe %basename_t-exp.lib
12 # RUN: llvm-readobj --file-headers --coff-load-config %basename_t-nodelay.exe | FileCheck %s --check-prefix CHECK
14 # CHECK: ImageBase: 0x140000000
16 # CHECK: GuardCFFunctionTable: 0x140002114
17 # CHECK: GuardCFFunctionCount: 1
18 # CHECK: GuardFlags: 0x10500
19 # CHECK: GuardAddressTakenIatEntryTable: 0x140002118
20 # CHECK: GuardAddressTakenIatEntryCount: 1
22 # CHECK: GuardFidTable [
23 # CHECK-NEXT: 0x14000{{.*}}
25 # CHECK: GuardIatTable [
26 # CHECK-NEXT: 0x14000{{.*}}
30 # Check that the additional load thunk symbol is added to the GFIDs table.
31 # RUN: lld-link %basename_t.obj -guard:cf -entry:main -out:%basename_t-delay.exe %basename_t-exp.lib -alternatename:__delayLoadHelper2=main -delayload:%basename_t-exp.dll
32 # RUN: llvm-readobj --file-headers --coff-load-config %basename_t-delay.exe | FileCheck %s --check-prefix DELAY-CHECK
34 # DELAY-CHECK: ImageBase: 0x140000000
35 # DELAY-CHECK: LoadConfig [
36 # DELAY-CHECK: GuardCFFunctionTable: 0x140002114
37 # DELAY-CHECK: GuardCFFunctionCount: 2
38 # DELAY-CHECK: GuardFlags: 0x10500
39 # DELAY-CHECK: GuardAddressTakenIatEntryTable: 0x14000211C
40 # DELAY-CHECK: GuardAddressTakenIatEntryCount: 1
42 # DELAY-CHECK: GuardFidTable [
43 # DELAY-CHECK-NEXT: 0x14000{{.*}}
44 # DELAY-CHECK-NEXT: 0x14000{{.*}}
46 # DELAY-CHECK: GuardIatTable [
47 # DELAY-CHECK-NEXT: 0x14000{{.*}}
51 # This assembly is reduced from C code like:
52 # __declspec(noinline)
53 # void IndirectCall(BOOL (func)(HANDLE)) {
56 # int main(int argc, char** argv) {
57 # IndirectCall(exportfn1);
67 .def IndirectCall; .scl 2; .type 32; .endef
68 .globl IndirectCall # -- Begin function IndirectCall
70 IndirectCall
: # @IndirectCall
75 movq
%rax
, %rdx
# This would otherwise have be: movq __guard_dispatch_icall_fptr(%rip), %rdx
82 .def main; .scl 2; .type 32; .endef
83 .globl main # -- Begin function main
88 movq __imp_exportfn1
(%rip
), %rax
97 .section .gfids$y,"dr"
98 .section .giats$y,"dr"
99 .symidx __imp_exportfn1
100 .section .gljmp$y,"dr"
102 # Load configuration directory entry (winnt.h _IMAGE_LOAD_CONFIG_DIRECTORY64).
103 # The linker will define the __guard_* symbols.
105 .globl _load_config_used
109 .quad __guard_fids_table
110 .quad __guard_fids_count
113 .quad __guard_iat_table
114 .quad __guard_iat_count
115 .quad __guard_longjmp_table
116 .quad __guard_fids_count