1# RUN: llvm-mc %s -filetype obj -triple aarch64-- -o %t.o 2# RUN: llvm-cfi-verify %t.o | FileCheck %s 3 4# CHECK-LABEL: {{^Instruction: .* \(PROTECTED\)}} 5# CHECK-NEXT: tiny.cc:9 6 7# CHECK: Expected Protected: 1 (100.00%) 8# CHECK: Unexpected Protected: 0 (0.00%) 9# CHECK: Expected Unprotected: 0 (0.00%) 10# CHECK: Unexpected Unprotected (BAD): 0 (0.00%) 11 12# Source (tiny.cc): 13# int a() { return 42; } 14# int b() { return 137; } 15# int main(int argc, char** argv) { 16# int(*ptr)(); 17# if (argc == 1) 18# ptr = &a; 19# else 20# ptr = &b; 21# return ptr(); 22# } 23 .text 24 .file "ld-temp.o" 25 .p2align 2 26 .type _Z1av.cfi,@function 27_Z1av.cfi: 28.Lfunc_begin0: 29 .file 1 "/tmp/tiny.cc" 30 .loc 1 1 0 31 .cfi_startproc 32 .loc 1 1 11 prologue_end 33 mov w0, #42 34 ret 35.Ltmp0: 36.Lfunc_end0: 37 .size _Z1av.cfi, .Lfunc_end0-_Z1av.cfi 38 .cfi_endproc 39 40 .p2align 2 41 .type _Z1bv.cfi,@function 42_Z1bv.cfi: 43.Lfunc_begin1: 44 .loc 1 2 0 45 .cfi_startproc 46 .loc 1 2 11 prologue_end 47 mov w0, #137 48 ret 49.Ltmp1: 50.Lfunc_end1: 51 .size _Z1bv.cfi, .Lfunc_end1-_Z1bv.cfi 52 .cfi_endproc 53 54 .p2align 2 55 .type main,@function 56main: 57.Lfunc_begin2: 58 .loc 1 3 0 59 .cfi_startproc 60 sub sp, sp, #48 61 stp x29, x30, [sp, #32] 62 add x29, sp, #32 63 .cfi_def_cfa w29, 16 64 .cfi_offset w30, -8 65 .cfi_offset w29, -16 66 stur wzr, [x29, #-4] 67 stur w0, [x29, #-8] 68 str x1, [sp, #16] 69.Ltmp2: 70 .loc 1 5 7 prologue_end 71 ldur w8, [x29, #-8] 72 cmp w8, #1 73 b.ne .LBB2_2 74 .loc 1 0 7 is_stmt 0 75 adrp x8, _Z1av 76 add x8, x8, :lo12:_Z1av 77 .loc 1 6 9 is_stmt 1 78 str x8, [sp, #8] 79 .loc 1 6 5 is_stmt 0 80 b .LBB2_3 81.LBB2_2: 82 .loc 1 0 5 83 adrp x8, _Z1bv 84 add x8, x8, :lo12:_Z1bv 85 .loc 1 8 9 is_stmt 1 86 str x8, [sp, #8] 87.LBB2_3: 88 .loc 1 0 9 is_stmt 0 89 adrp x8, .L.cfi.jumptable 90 add x9, x8, :lo12:.L.cfi.jumptable 91 .loc 1 9 10 is_stmt 1 92 ldr x8, [sp, #8] 93 sub x9, x8, x9 94 lsr x10, x9, #2 95 orr x9, x10, x9, lsl #62 96 cmp x9, #1 97 b.ls .LBB2_5 98 brk #0x1 99.LBB2_5: 100 blr x8 101 .loc 1 9 3 is_stmt 0 102 ldp x29, x30, [sp, #32] 103 add sp, sp, #48 104 ret 105.Ltmp3: 106.Lfunc_end2: 107 .size main, .Lfunc_end2-main 108 .cfi_endproc 109 110 .p2align 2 111 .type .L.cfi.jumptable,@function 112.L.cfi.jumptable: 113.Lfunc_begin3: 114 .cfi_startproc 115 //APP 116 b _Z1av.cfi 117 b _Z1bv.cfi 118 119 //NO_APP 120.Lfunc_end3: 121 .size .L.cfi.jumptable, .Lfunc_end3-.L.cfi.jumptable 122 .cfi_endproc 123 124 .type .L__unnamed_1,@object 125 .section .rodata,"a",@progbits 126 .p2align 2 127.L__unnamed_1: 128 .size .L__unnamed_1, 0 129 130 .section .debug_str,"MS",@progbits,1 131.Linfo_string0: 132 .asciz "clang version 7.0.0 (trunk 335774) (llvm/trunk 335775)" 133.Linfo_string1: 134 .asciz "tiny.cc" 135.Linfo_string2: 136 .asciz "" 137 .section .debug_abbrev,"",@progbits 138 .byte 1 139 .byte 17 140 .byte 0 141 .byte 37 142 .byte 14 143 .byte 19 144 .byte 5 145 .byte 3 146 .byte 14 147 .byte 16 148 .byte 23 149 .byte 27 150 .byte 14 151 .byte 17 152 .byte 1 153 .byte 18 154 .byte 6 155 .byte 0 156 .byte 0 157 .byte 0 158 .section .debug_info,"",@progbits 159.Lcu_begin0: 160 .word 38 161 .hword 4 162 .word .debug_abbrev 163 .byte 8 164 .byte 1 165 .word .Linfo_string0 166 .hword 4 167 .word .Linfo_string1 168 .word .Lline_table_start0 169 .word .Linfo_string2 170 .xword .Lfunc_begin0 171 .word .Lfunc_end2-.Lfunc_begin0 172 .section .debug_ranges,"",@progbits 173 .section .debug_macinfo,"",@progbits 174 .byte 0 175 176 .type _Z1av,@function 177.set _Z1av, .L.cfi.jumptable 178 .type _Z1bv,@function 179.set _Z1bv, .L.cfi.jumptable+4 180 .ident "clang version 7.0.0 (trunk 335774) (llvm/trunk 335775)" 181 .section ".note.GNU-stack","",@progbits 182 .section .debug_line,"",@progbits 183.Lline_table_start0: 184