brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · a80bac7 Raw
88 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -triple i686-pc-win32 %s -filetype=obj -o %t.obj3# RUN: lld-link -safeseh:no %t.obj -guard:cf -out:%t.exe -entry:main4# RUN: llvm-readobj --coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK5 6# Only f and _main should go in the table.7# (use /lldmap:map.txt to check their addresses).8#9# CHECK: GuardFidTable [10# CHECK-NEXT: 0x40100011# CHECK-NEXT: 0x40103012# CHECK-NEXT: ]13 14# The input was loosely based on studying this program:15#16#  void foo() { return; }17#  void bar() { return; }18#  int main() {19#    foo();20#    void (*arr[])() = { &bar };21#    (*arr[0])();22#    return 0;23#  }24# cl /c a.cc && dumpbin /disasm a.obj > a.txt &&25#   link a.obj /guard:cf /map:map.txt && dumpbin /loadconfig a.exe26 27 28 29        .def    f;30        .scl    3;31        .type   32;32        .endef33        .section       .text,"xr",one_only,f34        .p2align 435f:      movl $1, %eax36        ret37 38 39        .def    g;40        .scl    3;41        .type   32;42        .endef43        .section       .text,"xr",one_only,g44        .p2align 445g:      movl $2, %eax46        ret47 48 49        .def    label;50        .scl    6;     # StorageClass: Label51        .type   0;     # Type: Not a function.52        .endef53        .section       .text,"xr",one_only,label54        .p2align 455label:  ret56 57 58        .data59        .globl fp60        .p2align 461fp:     .long f        # DIR32 relocation to function62        .long label    # DIR32 relocation to label63 64 65        .def    _main;66        .scl    2;67        .type   32;68        .endef69        .section       .text,"xr",one_only,_main70        .globl  _main71        .p2align 472_main:  call *fp       # DIR32 relocation to data73        call g         # REL32 relocation to function74        ret75 76 77# Load configuration directory entry (winnt.h _IMAGE_LOAD_CONFIG_DIRECTORY32).78# The linker will define the ___guard_* symbols.79        .section .rdata,"dr"80.globl __load_config_used81__load_config_used:82        .long 104  # Size.83        .fill 76, 1, 084        .long ___guard_fids_table85        .long ___guard_fids_count86        .long ___guard_flags87        .fill 12, 1, 088