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 133 134 135 136 137
|
# Check that references to local (unnamed) objects below are not
# treated as references relative to zero-sized A object.
# REQUIRES: system-linux
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
# RUN: %s -o %t.o
# RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe --print-cfg \
# RUN: --print-only=main -o %t.out | FileCheck %s
.file "rust_bug.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
movl %eax, %eax
movq .L4(,%rax,8), %rax
jmp *%rax
.section .rodata
.align 8
.globl A
.type A, @object
A:
.section .rodata
.align 8
.align 4
.L4:
.quad .L3
.quad .L5
.quad .L6
.quad .L7
.quad .L8
.quad .L9
.text
.L3:
movl $.LC0, %edi
call puts
movl $1, %eax
jmp .L10
.L5:
movl $.LC1, %edi
call puts
movl $2, %eax
jmp .L10
.L6:
movl $.LC2, %edi
call puts
movl $3, %eax
jmp .L10
.L7:
movl $.LC3, %edi
call puts
movl $4, %eax
jmp .L10
.L8:
movl $.LC4, %edi
call puts
movl $5, %eax
jmp .L10
.L9:
movl $.LC5, %edi
call puts
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
.section .rodata
.LC6:
.string "%d\n"
.text
.globl main
.type main, @function
main:
# CHECK: Binary Function "main" after building cfg
.LFB1:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl .LN(%rip), %eax
# We should not reference a data object as an offset from A
# CHECK-NOT: movl A+{{.*}}(%rip), %eax
movl %eax, %esi
movl $.LC6, %edi
movl $0, %eax
call printf
movl $0, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE1:
.size main, .-main
.section .rodata
.align 4
.LN:
.long 42
.ident "GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-44)"
.section .note.GNU-stack,"",@progbits
|