1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
# Check that jump table detection does not fail on a false
# reference to a jump table.
# REQUIRES: system-linux
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
# RUN: %s -o %t.o
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe --print-cfg \
# RUN: --print-only=inc_dup -o %t.out | FileCheck %s
.file "jump_table.c"
.section .rodata
.LC0:
.string "0"
.LC1:
.string "1"
.LC2:
.string "2"
.LC3:
.string "3"
.LC4:
.string "4"
.LC5:
.string "5"
.text
.globl inc_dup
.type inc_dup, @function
inc_dup:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movl %edi, -4(%rbp)
movl -4(%rbp), %eax
subl $10, %eax
cmpl $5, %eax
ja .L2
# Control flow confusing for JT detection
# CHECK: leaq "JUMP_TABLE{{.*}}"(%rip), %rdx
leaq .L4(%rip), %rdx
jmp .LJT
# CHECK: leaq {{.*}}(%rip), %rdx
leaq .LC0(%rip), %rdx
jmp .L10
.LJT:
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
# CHECK: jmpq *%rax # UNKNOWN CONTROL FLOW
jmp *%rax
.section .rodata
.align 4
.align 4
.L4:
.long .L3-.L4
.long .L5-.L4
.long .L6-.L4
.long .L7-.L4
.long .L8-.L4
.long .L9-.L4
.text
.L3:
leaq .LC0(%rip), %rdi
call puts@PLT
movl $1, %eax
jmp .L10
.L5:
leaq .LC1(%rip), %rdi
call puts@PLT
movl $2, %eax
jmp .L10
.L6:
leaq .LC2(%rip), %rdi
call puts@PLT
movl $3, %eax
jmp .L10
.L7:
leaq .LC3(%rip), %rdi
call puts@PLT
movl $4, %eax
jmp .L10
.L8:
leaq .LC4(%rip), %rdi
call puts@PLT
movl $5, %eax
jmp .L10
.L9:
leaq .LC5(%rip), %rdi
call puts@PLT
movl $6, %eax
jmp .L10
.L2:
movl -4(%rbp), %eax
addl $1, %eax
.L10:
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size inc_dup, .-inc_dup
.text
.globl main
.type main, @function
main:
.LFB1:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movl %edi, -4(%rbp)
movq %rsi, -16(%rbp)
movl -4(%rbp), %eax
addl $9, %eax
movl %eax, %edi
call inc_dup@PLT
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE1:
.size main, .-main
.ident "GCC: (GNU) 6.3.0"
.section .note.GNU-stack,"",@progbits
|