138 lines · plain
1## Check that references to local (unnamed) objects below are not2## treated as references relative to zero-sized A object.3 4# REQUIRES: system-linux5 6# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \7# RUN: %s -o %t.o8# RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q9 10# RUN: llvm-bolt %t.exe --print-cfg \11# RUN: --print-only=main -o %t.out | FileCheck %s12 13 .file "rust_bug.c"14 .section .rodata15.LC0:16 .string "0"17.LC1:18 .string "1"19.LC2:20 .string "2"21.LC3:22 .string "3"23.LC4:24 .string "4"25.LC5:26 .string "5"27 .text28 .globl inc_dup29 .type inc_dup, @function30inc_dup:31.LFB0:32 .cfi_startproc33 pushq %rbp34 .cfi_def_cfa_offset 1635 .cfi_offset 6, -1636 movq %rsp, %rbp37 .cfi_def_cfa_register 638 subq $16, %rsp39 movl %edi, -4(%rbp)40 movl -4(%rbp), %eax41 subl $10, %eax42 cmpl $5, %eax43 ja .L244 movl %eax, %eax45 movq .L4(,%rax,8), %rax46 jmp *%rax47 .section .rodata48 .align 849 .globl A50 .type A, @object51A:52 .section .rodata53 .align 854 .align 455.L4:56 .quad .L357 .quad .L558 .quad .L659 .quad .L760 .quad .L861 .quad .L962 .text63.L3:64 movl $.LC0, %edi65 call puts66 movl $1, %eax67 jmp .L1068.L5:69 movl $.LC1, %edi70 call puts71 movl $2, %eax72 jmp .L1073.L6:74 movl $.LC2, %edi75 call puts76 movl $3, %eax77 jmp .L1078.L7:79 movl $.LC3, %edi80 call puts81 movl $4, %eax82 jmp .L1083.L8:84 movl $.LC4, %edi85 call puts86 movl $5, %eax87 jmp .L1088.L9:89 movl $.LC5, %edi90 call puts91 movl $6, %eax92 jmp .L1093.L2:94 movl -4(%rbp), %eax95 addl $1, %eax96.L10:97 leave98 .cfi_def_cfa 7, 899 ret100 .cfi_endproc101.LFE0:102 .size inc_dup, .-inc_dup103 .section .rodata104.LC6:105 .string "%d\n"106 .text107 .globl main108 .type main, @function109main:110# CHECK: Binary Function "main" after building cfg111.LFB1:112 .cfi_startproc113 pushq %rbp114 .cfi_def_cfa_offset 16115 .cfi_offset 6, -16116 movq %rsp, %rbp117 .cfi_def_cfa_register 6118 movl .LN(%rip), %eax119# We should not reference a data object as an offset from A120# CHECK-NOT: movl A+{{.*}}(%rip), %eax121 movl %eax, %esi122 movl $.LC6, %edi123 movl $0, %eax124 call printf125 movl $0, %eax126 popq %rbp127 .cfi_def_cfa 7, 8128 ret129 .cfi_endproc130.LFE1:131 .size main, .-main132 .section .rodata133 .align 4134.LN:135 .long 42136 .ident "GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-44)"137 .section .note.GNU-stack,"",@progbits138