From 30a6d3ada6570254c27295eafe1188aa7baca574 Mon Sep 17 00:00:00 2001 From: Maksim Panchenko Date: Mon, 20 Jun 2022 14:20:22 -0700 Subject: [PATCH] [BOLT][TEST] Fix stack alignment in section-reloc-with-addend.s Misaligned stack can cause a runtime crash. Reviewed By: Amir Differential Revision: https://reviews.llvm.org/D128227 --- bolt/test/runtime/X86/section-reloc-with-addend.s | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bolt/test/runtime/X86/section-reloc-with-addend.s b/bolt/test/runtime/X86/section-reloc-with-addend.s index 97b4710..63b7733 100755 --- a/bolt/test/runtime/X86/section-reloc-with-addend.s +++ b/bolt/test/runtime/X86/section-reloc-with-addend.s @@ -13,9 +13,10 @@ # RUN: llvm-strip --strip-unneeded %t.o # RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q -# RUN: llvm-bolt %t.exe --relocs=1 --print-finalized --print-only=main -o %t.out +# RUN: llvm-bolt %t.exe --print-finalized --print-only=main -o %t.out \ +# RUN: 2>&1 | FileCheck %s -# RUN: %t.out 1 2 +# RUN: %t.out 1 2 | FileCheck --check-prefix=CHECK-RT %s .text .globl main @@ -24,11 +25,14 @@ main: pushq %rbp movq %rsp, %rbp - subq $0x18, %rsp + subq $0x10, %rsp cmpl $0x2, %edi jb .BBend .BB2: - leaq .data-0x1000000, %rsi # Use a large negative addend to cause a + +# CHECK: leaq +# CHECK-SAME: {{.*}}-{{.*}} + leaq mystring-0x1000000, %rsi # Use a large negative addend to cause a # negative result to be encoded in LEA addq $0x1000000, %rsi # Eventually program logic compensates to get # a real address @@ -47,4 +51,6 @@ main: .size main, .-main .data + +# CHECK-RT: {{.*}} is rbx mod 10 contents in decimal mystring: .asciz "0 is rbx mod 10 contents in decimal\n" -- 2.7.4