46 lines · plain
1; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc | FileCheck %s2; RUN: llc < %s -mtriple=x86_64-w64-windows-gnu | FileCheck %s3; Control Flow Guard is currently only available on Windows4 5declare dllimport i32 @target_func1()6declare dllimport i32 @target_func2()7declare dllimport i32 @target_func3()8@ptrs = dso_local local_unnamed_addr global [2 x ptr] [ptr @target_func2, ptr @target_func3], align 169 10; Test address-taken functions from imported DLLs are correctly added to the 11; Guard Address-Taken IAT Entry (.giats) and Guard Function ID (.gfids) sections.12define i32 @func_cf_giats1() {13entry:14 ; Since it is a dllimport, target_func1 will be represented as "__imp_target_func1" when it is15 ; stored in the function pointer. Therefore, the .giats section must contain "__imp_target_func1".16 ; Unlike MSVC, we also have "target_func1" in the .gfids section, since this is not a security risk.17 %func_ptr = alloca ptr, align 818 store ptr @target_func1, ptr %func_ptr, align 819 %0 = load ptr, ptr %func_ptr, align 820 %1 = call i32 %0()21 ; target_func2 is called directly from a global array, so should only appear in the .gfids section.22 %2 = load ptr, ptr @ptrs, align 823 %3 = call i32 %2()24 ; target_func3 is called both via a stored function pointer (as with target_func1) and via a gloabl25 ; array (as with target_func2), so "target_func3" must appear in .gfids and "__imp_target_func3" in .giats.26 store ptr @target_func3, ptr %func_ptr, align 827 %4 = load ptr, ptr %func_ptr, align 828 %5 = call i32 %4()29 %6 = load ptr, ptr getelementptr inbounds ([2 x ptr], ptr @ptrs, i64 0, i64 1), align 830 %7 = call i32 %6()31 ret i32 %532}33 34; CHECK-LABEL: .section .gfids$y,"dr"35; CHECK-NEXT: .symidx target_func136; CHECK-NEXT: .symidx target_func237; CHECK-NEXT: .symidx target_func338; CHECK-NOT: .symidx39; CHECK-LABEL: .section .giats$y,"dr"40; CHECK-NEXT: .symidx __imp_target_func141; CHECK-NEXT: .symidx __imp_target_func342; CHECK-NOT: .symidx43 44!llvm.module.flags = !{!0}45!0 = !{i32 2, !"cfguard", i32 2}46