77 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -triple x86_64-pc-win32 %s -filetype=obj -o %t.obj3# RUN: lld-link %t.obj -guard:cf -out:%t.exe -entry:main4# RUN: llvm-readobj --coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK5 6# f, g, and main go in the table.7# Including g isn't strictly necessary since it's not an indirect call target,8# however the linker can't know that because relative relocations are used both9# for direct calls and for getting the absolute address of a function.10# (use /lldmap:map.txt to check their addresses).11#12# CHECK: GuardFidTable [13# CHECK-NEXT: 0x14000100014# CHECK-NEXT: 0x14000101015# CHECK-NEXT: 0x14000103016# CHECK-NEXT: ]17 18 .def f;19 .scl 3;20 .type 32;21 .endef22 .section .text,"xr",one_only,f23 .p2align 424f: movl $1, %eax25 ret26 27 28 .def g;29 .scl 3;30 .type 32;31 .endef32 .section .text,"xr",one_only,g33 .p2align 434g: movl $2, %eax35 ret36 37 38 .def label;39 .scl 6; # StorageClass: Label40 .type 0; # Type: Not a function.41 .endef42 .section .text,"xr",one_only,label43 .p2align 444label: ret45 46 47 .data48 .globl fp49 .p2align 450fp: .quad f # DIR32 relocation to function51 .quad label # DIR32 relocation to label52 53 54 .def main;55 .scl 2;56 .type 32;57 .endef58 .section .text,"xr",one_only,main59 .globl main60 .p2align 461main: call *fp # DIR32 relocation to data62 call g # REL32 relocation to function63 ret64 65 66# Load configuration directory entry (winnt.h _IMAGE_LOAD_CONFIG_DIRECTORY64).67# The linker will define the __guard_* symbols.68 .section .rdata,"dr"69.globl _load_config_used70_load_config_used:71 .long 25672 .fill 124, 1, 073 .quad __guard_fids_table74 .quad __guard_fids_count75 .long __guard_flags76 .fill 128, 1, 077