2 # RUN: llvm-mc -triple i686-pc-win32 %s -filetype=obj -o %t.obj
3 # RUN: lld-link -safeseh:no %t.obj -guard:cf -out:%t.exe -entry:main
4 # RUN: llvm-readobj --coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK
6 # Only f and _main should go in the table.
7 # (use /lldmap:map.txt to check their addresses).
9 # CHECK: GuardFidTable [
10 # CHECK-NEXT: 0x401000
11 # CHECK-NEXT: 0x401030
14 # The input was loosely based on studying this program:
16 # void foo() { return; }
17 # void bar() { return; }
20 # void (*arr[])() = { &bar };
24 # cl /c a.cc && dumpbin /disasm a.obj > a.txt &&
25 # link a.obj /guard:cf /map:map.txt && dumpbin /loadconfig a.exe
33 .section .text,"xr",one_only,f
43 .section .text,"xr",one_only,g
50 .scl 6; # StorageClass: Label
51 .type 0; # Type: Not a function.
53 .section .text,"xr",one_only,label
61 fp
: .long f # DIR32 relocation to function
62 .long label # DIR32 relocation to label
69 .section .text,"xr",one_only,_main
72 _main
: call
*fp
# DIR32 relocation to data
73 call g
# REL32 relocation to function
77 # Load configuration directory entry (winnt.h _IMAGE_LOAD_CONFIG_DIRECTORY32).
78 # The linker will define the ___guard_* symbols.
80 .globl __load_config_used
84 .long ___guard_fids_table
85 .long ___guard_fids_count