240 lines · plain
1@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \2@ RUN: | llvm-readobj -S --sd - | FileCheck %s3 4@ Check for .setfp directive.5 6@ The .setfp directive will track the offset between the frame pointer and7@ the stack pointer. This is required for the function that will change8@ the stack pointer out of the function prologue. If the exception is thrown,9@ then libunwind will reconstruct the stack pointer from the frame pointer.10@ The reconstruction code is implemented by two different unwind opcode:11@ (i) the unwind opcode to copy stack offset from the other register, and12@ (ii) the unwind opcode to add or subtract the stack offset.13@14@ This file includes several cases separated by different range of -offset15@16@ (-offset) < 0x0017@ (-offset) == 0x0018@ 0x04 <= (-offset) <= 0x10019@ 0x104 <= (-offset) <= 0x20020@ 0x204 <= (-offset)21 22 23 .syntax unified24 25@-------------------------------------------------------------------------------26@ TEST127@-------------------------------------------------------------------------------28 .section .TEST129 .globl func130 .align 231 .type func1,%function32 .fnstart33func1:34 .setfp fp, sp, #035 add fp, sp, #036 sub sp, fp, #037 bx lr38 .personality __gxx_personality_v039 .handlerdata40 .fnend41 42@-------------------------------------------------------------------------------43@ The assembler should emit 0x9B to copy stack pointer from r11.44@-------------------------------------------------------------------------------45@ CHECK: Section {46@ CHECK: Name: .ARM.extab.TEST147@ CHECK: SectionData (48@ CHECK: 0000: 00000000 B0B09B00 |........|49@ CHECK: )50@ CHECK: }51 52 53 54@-------------------------------------------------------------------------------55@ TEST256@-------------------------------------------------------------------------------57 .section .TEST258 .globl func2a59 .align 260 .type func2a,%function61 .fnstart62func2a:63 .setfp fp, sp, #-464 add fp, sp, #465 sub sp, fp, #466 bx lr67 .personality __gxx_personality_v068 .handlerdata69 .fnend70 71 .globl func2b72 .align 273 .type func2b,%function74 .fnstart75func2b:76 .setfp fp, sp, #-0x10077 add fp, sp, #0x10078 sub sp, fp, #0x10079 bx lr80 .personality __gxx_personality_v081 .handlerdata82 .fnend83 84@-------------------------------------------------------------------------------85@ The assembler should emit 0x9B to copy stack pointer from r11.86@ The assembler should emit ((-offset - 4) >> 2) for offset.87@-------------------------------------------------------------------------------88@ CHECK: Section {89@ CHECK: Name: .ARM.extab.TEST290@ CHECK: SectionData (91@ CHECK: 0000: 00000000 B0009B00 00000000 B03F9B00 |.............?..|92@ CHECK: )93@ CHECK: }94 95 96 97@-------------------------------------------------------------------------------98@ TEST399@-------------------------------------------------------------------------------100 .section .TEST3101 .globl func3a102 .align 2103 .type func3a,%function104 .fnstart105func3a:106 .setfp fp, sp, #-0x104107 sub fp, sp, #0x104108 add sp, fp, #0x104109 bx lr110 .personality __gxx_personality_v0111 .handlerdata112 .fnend113 114 .globl func3b115 .align 2116 .type func3b,%function117 .fnstart118func3b:119 .setfp fp, sp, #-0x200120 sub fp, sp, #0x200121 add sp, fp, #0x200122 bx lr123 .personality __gxx_personality_v0124 .handlerdata125 .fnend126 127@-------------------------------------------------------------------------------128@ The assembler should emit 0x9B to copy stack pointer from r11.129@ The assembler should emit 0x3F and ((-offset - 0x104) >> 2) for offset.130@-------------------------------------------------------------------------------131@ CHECK: Section {132@ CHECK: Name: .ARM.extab.TEST3133@ CHECK: SectionData (134@ CHECK: 0000: 00000000 3F009B00 00000000 3F3F9B00 |....?.......??..|135@ CHECK: )136@ CHECK: }137 138 139 140@-------------------------------------------------------------------------------141@ TEST4142@-------------------------------------------------------------------------------143 .section .TEST4144 .globl func4a145 .align 2146 .type func4a,%function147 .fnstart148func4a:149 .setfp fp, sp, #-0x204150 sub fp, sp, #0x204151 add sp, fp, #0x204152 bx lr153 .personality __gxx_personality_v0154 .handlerdata155 .fnend156 157 .globl func4b158 .align 2159 .type func4b,%function160 .fnstart161func4b:162 .setfp fp, sp, #-0x580163 sub fp, sp, #0x580164 add sp, fp, #0x580165 bx lr166 .personality __gxx_personality_v0167 .handlerdata168 .fnend169 170@-------------------------------------------------------------------------------171@ The assembler should emit 0x9B to copy stack pointer from r11.172@ The assembler should emit 0xB2 and the ULEB128 encoding of173@ ((-offset - 0x204) >> 2) for offset.174@-------------------------------------------------------------------------------175@ CHECK: Section {176@ CHECK: Name: .ARM.extab.TEST4177@ CHECK: SectionData (178@ CHECK: 0000: 00000000 00B29B00 00000000 DFB29B01 |................|179@ CHECK: 0010: B0B0B001 |....|180@ CHECK: )181@ CHECK: }182 183 184 185@-------------------------------------------------------------------------------186@ TEST5187@-------------------------------------------------------------------------------188 .section .TEST5189 .globl func5a190 .align 2191 .type func5a,%function192 .fnstart193func5a:194 .setfp fp, sp, #0x4195 add fp, sp, #0x4196 sub sp, fp, #0x4197 bx lr198 .personality __gxx_personality_v0199 .handlerdata200 .fnend201 202 .globl func5b203 .align 2204 .type func5b,%function205 .fnstart206func5b:207 .setfp fp, sp, #0x104208 add fp, sp, #0x104209 sub sp, fp, #0x104210 bx lr211 .personality __gxx_personality_v0212 .handlerdata213 .fnend214 215 .globl func5c216 .align 2217 .type func5c,%function218 .fnstart219func5c:220 .setfp fp, sp, #0x204221 add fp, sp, #0x204222 sub sp, fp, #0x204223 bx lr224 .personality __gxx_personality_v0225 .handlerdata226 .fnend227 228@-------------------------------------------------------------------------------229@ The assembler should emit 0x9B to copy stack pointer from r11.230@ The assembler should emit (0x40 | (offset - 4)) >> 2 for offset.231@ If (offset - 4) is greater than 0x3f, then multiple 0x7f should be emitted.232@-------------------------------------------------------------------------------233@ CHECK: Section {234@ CHECK: Name: .ARM.extab.TEST5235@ CHECK: SectionData (236@ CHECK: 0000: 00000000 B0409B00 00000000 7F409B00 |.....@.......@..|237@ CHECK: 0010: 00000000 7F409B01 B0B0B07F |.....@......|238@ CHECK: )239@ CHECK: }240