1# RUN: rm -rf %t && mkdir -p %t 2# RUN: llvm-mc -triple=x86_64-apple-macos10.9 -filetype=obj \ 3# RUN: -o %t/helper.o %S/Inputs/MachO_GOTAndStubsOptimizationHelper.s 4# RUN: llvm-mc -triple=x86_64-apple-macos10.9 -filetype=obj \ 5# RUN: -o %t/testcase.o %s 6# RUN: llvm-jitlink -noexec -slab-allocate 64Kb -entry=bypass_stub -check %s \ 7# RUN: %t/testcase.o %t/helper.o 8# 9# Test that references to in-range GOT and stub targets can be bypassed. 10# The helper file contains a function that uses the GOT for _x, and this file 11# contains an external call to that function. By slab allocating the JIT memory 12# we can ensure that the references and targets will be in-range of one another, 13# which should cause both the GOT load and stub to be bypassed. 14 15 .section __TEXT,__text,regular,pure_instructions 16 .macosx_version_min 10, 14 17 .globl bypass_stub 18 .p2align 4, 0x90 19 20# jitlink-check: decode_operand(bypass_got, 4) = _x - next_pc(bypass_got) 21# jitlink-check: decode_operand(bypass_stub, 0) = bypass_got - next_pc(bypass_stub) 22bypass_stub: 23 callq bypass_got 24 25 .section __DATA,__data 26 .globl _x 27 .p2align 2 28_x: 29 .long 42 30 31.subsections_via_symbols 32