brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 62ffd61 Raw
102 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -triple x86_64-windows-msvc %s -filetype=obj -o %t.obj3# RUN: lld-link %t.obj -guard:cf,nolongjmp -out:%t.exe -opt:icf -entry:main4# RUN: llvm-readobj --file-headers --coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK5 6# This assembly is meant to mimic what CL emits for this kind of C code:7# int icf1() { return 42; }8# int icf2() { return 42; }9# int (*fp1)() = &icf1;10# int (*fp2)() = &icf2;11# int main() {12#   return fp1();13#   return fp2();14# }15 16# 'icf1' and 'icf2' are address taken, but should be merged into one entry.17# There are two entries in the table because 'main' is included.18 19# CHECK: ImageBase: 0x14000000020# CHECK: LoadConfig [21# CHECK:   SEHandlerTable: 0x022# CHECK:   SEHandlerCount: 023# CHECK:   GuardCFCheckFunction: 0x024# CHECK:   GuardCFCheckDispatch: 0x025# CHECK:   GuardCFFunctionTable: 0x14000{{.*}}26# CHECK:   GuardCFFunctionCount: 227# CHECK:   GuardFlags [ (0x500)28# CHECK:     CF_FUNCTION_TABLE_PRESENT (0x400)29# CHECK:     CF_INSTRUMENTED (0x100)30# CHECK:   ]31# CHECK:   GuardAddressTakenIatEntryTable: 0x032# CHECK:   GuardAddressTakenIatEntryCount: 033# CHECK:   GuardLongJumpTargetTable: 0x034# CHECK:   GuardLongJumpTargetCount: 035# CHECK: ]36# CHECK:      GuardFidTable [37# CHECK-NEXT:   0x14000{{.*}}38# CHECK-NEXT:   0x14000{{.*}}39# CHECK-NEXT: ]40 41# There should be no .gfids section in the output executable when we link with42# -guard:cf or with no -guard:cf/nolongjmp flag.43# RUN: llvm-readobj --sections %t.exe | FileCheck %s --check-prefix NOGFIDSEC44# RUN: lld-link %t.obj -out:%t.exe -opt:icf -entry:main45# RUN: llvm-readobj --sections %t.exe | FileCheck %s --check-prefix NOGFIDSEC46 47# NOGFIDSEC: Sections [48# NOGFIDSEC: Section {49# NOGFIDSEC: Name: .text50# NOGFIDSEC-NOT: Name: .gfids51 52# Indicate that gfids are present.53        .def     @feat.00; .scl    3; .type   0; .endef54        .globl  @feat.0055@feat.00 = 0x80056 57        .def     icf1; .scl    2; .type   32; .endef58        .section        .text,"xr",one_only,icf159        .global icf160icf1:61        movl $42, %eax62        retq63 64        .def     icf2; .scl    2; .type   32; .endef65        .section        .text,"xr",one_only,icf266        .global icf267icf2:68        movl $42, %eax69        retq70 71# Take their two addresses.72        .data73        .globl  fp174fp1:75        .quad   icf176        .globl  fp277fp2:78        .quad   icf279 80        .section        .gfids$y,"dr"81        .symidx icf182        .symidx icf283 84        .def     main; .scl    2; .type   32; .endef85        .section        .text,"xr",one_only,main86        .globl  main87main:88        callq      *fp1(%rip)89        callq      *fp2(%rip)90        xor %eax, %eax91        retq92 93        .section .rdata,"dr"94.globl _load_config_used95_load_config_used:96        .long 25697        .fill 124, 1, 098        .quad __guard_fids_table99        .quad __guard_fids_count100        .long __guard_flags101        .fill 128, 1, 0102