1# REQUIRES: x86
2# RUN: llvm-mc -triple x86_64-windows-msvc -filetype=obj -o %t.obj %s
3# RUN: yaml2obj < %p/Inputs/guardcf-align-foobar.yaml \
4# RUN:     > %T/guardcf-align-foobar.obj
5# RUN: lld-link -out:%T/guardcf-align.exe -entry:main -guard:cf \
6# RUN:     %t.obj %T/guardcf-align-foobar.obj
7# RUN: llvm-readobj --coff-load-config %T/guardcf-align.exe | FileCheck %s
8
9# Check that the gfids table contains at least one entry that ends in 0
10# and no entries that end in something other than 0.
11# CHECK: GuardFidTable [
12# CHECK-NOT: 0x{{[0-9A-Fa-f]+[^0]$}}
13# CHECK: 0x{{[0-9A-Fa-f]+0$}}
14# CHECK-NOT: 0x{{[0-9A-Fa-f]+[^0]$}}
15# CHECK: ]
16
17# @feat.00 and _load_config_used to indicate we have gfids.
18        .def     @feat.00;
19        .scl    3;
20        .type   0;
21        .endef
22        .globl  @feat.00
23@feat.00 = 0x801
24
25        .section .rdata,"dr"
26.globl _load_config_used
27_load_config_used:
28        .long 256
29        .fill 124, 1, 0
30        .quad __guard_fids_table
31        .quad __guard_fids_count
32        .long __guard_flags
33        .fill 128, 1, 0
34
35# Functions that are called indirectly.
36        .section        .gfids$y,"dr"
37        .symidx foo
38
39
40        .section .text,"rx"
41        .global main
42main:
43        movq foo, %rcx
44        xorq %rax, %rax
45        callq bar
46        retq
47