124 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o3# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/x86-64-split-stack-extra.s -o %t2.o4# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/x86-64-split-stack-main.s -o %t3.o5 6# RUN: ld.lld --defsym __morestack=0x100 --defsym __morestack_non_split=0x200 %t1.o %t2.o %t3.o -o %t -z notext7# RUN: llvm-objdump --no-print-imm-hex -d %t | FileCheck %s8 9# Avoid duplicating the prologue for every test via macros.10 11.macro prologue1 function_to_call12 .global prologue1_calls_\function_to_call13 .type prologue1_calls_\function_to_call,@function14prologue1_calls_\function_to_call:15 cmp %fs:0x70,%rsp16 jae 1f17 callq __morestack18 retq191:20 # Various and duplicate calls to ensure every code path is taken.21 callq \function_to_call22 callq \function_to_call23 callq 1b24 callq non_function_text_symbol25 retq26 .size prologue1_calls_\function_to_call,. - prologue1_calls_\function_to_call27.endm28 29.macro prologue2 function_to_call register compare_amount30 .global prologue2_calls_\function_to_call\register31 .type prologue2_calls_\function_to_call\register,@function32prologue2_calls_\function_to_call\register:33 lea -\compare_amount(%rsp),%\register34 cmp %fs:0x70,%\register35 jae 1f36 callq __morestack37 retq381:39 # Various and duplicate calls to ensure every code path is taken.40 callq \function_to_call41 callq \function_to_call42 callq 1b43 callq non_function_text_symbol44 retq45 .size prologue2_calls_\function_to_call\register,. - prologue2_calls_\function_to_call\register46.endm47 48 .section .text,"ax",@progbits,unique,049 .local foo50foo:51 .quad foo52 53 .section .text,"ax",@progbits,unique,154 55# For split-stack code calling split-stack code, ensure prologue v1 still56# calls plain __morestack, and that any raw bytes written to the prologue57# make sense.58# CHECK: <prologue1_calls_split>:59# CHECK-NEXT: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%rsp60# CHECK: jae{{.*$}}61# CHECK-NEXT: callq{{.*}}<__morestack>62 63prologue1 split64 65# For split-stack code calling split-stack code, ensure prologue v2 still66# calls plain __morestack, that any raw bytes written to the prologue67# make sense, and that the register number is preserved.68# CHECK: <prologue2_calls_splitr10>:69# CHECK-NEXT: lea{{.*}} -512(%rsp),{{.*}}%r1070# CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r{{[0-9]+}}71# CHECK: jae{{.*}}72# CHECK-NEXT: callq{{.*}}<__morestack>73 74prologue2 split r10 0x20075 76# CHECK: <prologue2_calls_splitr11>:77# CHECK-NEXT: lea{{.*}} -256(%rsp),{{.*}}%r1178# CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r{{[0-9]+}}79# CHECK: jae{{.*}}80# CHECK-NEXT: callq{{.*}}<__morestack>81 82prologue2 split r11 0x10083 84# For split-stack code calling non-split-stack code, ensure prologue v185# calls __morestack_non_split, and that any raw bytes written to the prologue86# make sense.87# CHECK: <prologue1_calls_non_split>:88# CHECK-NEXT: stc{{.*$}}89# CHECK-NEXT: nopl{{.*$}}90# CHECK: jae{{.*$}}91# CHECK-NEXT: callq{{.*}}<__morestack_non_split>92 93prologue1 non_split94 95# For split-stack code calling non-split-stack code, ensure prologue v296# calls __morestack_non_split, that any raw bytes written to the prologue97# make sense, and that the register number is preserved98# CHECK: <prologue2_calls_non_splitr10>:99# CHECK-NEXT: lea{{.*}} -16640(%rsp),{{.*}}%r10100# CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r10101# CHECK: jae{{.*$}}102# CHECK-NEXT: callq{{.*}}<__morestack_non_split>103 104prologue2 non_split r10 0x100105 106# CHECK: <prologue2_calls_non_splitr11>:107# CHECK-NEXT: lea{{.*}} -16896(%rsp),{{.*}}%r11108# CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r11109# CHECK: jae{{.*$}}110# CHECK-NEXT: callq{{.*}}<__morestack_non_split>111 112prologue2 non_split r11 0x200113 114# CHECK: <prologue2_calls_non_split_hiddenr11>:115# CHECK-NEXT: lea{{.*}} -16896(%rsp),{{.*}}%r11116# CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r11117# CHECK: jae{{.*$}}118# CHECK-NEXT: callq{{.*}}<__morestack_non_split>119 120prologue2 non_split_hidden r11 0x200121 122 .section .note.GNU-stack,"",@progbits123 .section .note.GNU-split-stack,"",@progbits124