125 lines · plain
1// REQUIRES: arm2// RUN: llvm-mc -filetype=obj -triple=armv7a-linux-gnueabihf --arm-add-build-attributes %s -o %t.o3// RUN: ld.lld --fix-cortex-a8 -verbose %t.o -o %t24// RUN: llvm-objdump -d %t2 --start-address=0x21ffa --stop-address=0x22002 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE1 %s5// RUN: llvm-objdump -d %t2 --start-address=0x22ffa --stop-address=0x23002 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE2 %s6// RUN: llvm-objdump -d %t2 --start-address=0x23ffa --stop-address=0x24002 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE3 %s7// RUN: llvm-objdump -d %t2 --start-address=0x24ffa --stop-address=0x25006 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE4 %s8// RUN: llvm-objdump -d %t2 --start-address=0x25ffe --stop-address=0x26002 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE5 %s9// RUN: llvm-objdump -d %t2 --start-address=0x27000 --stop-address=0x28004 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE6 %s10// RUN: llvm-objdump -d %t2 --start-address=0x28002 --stop-address=0x29006 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE7 %s11 12/// Test boundary conditions of the cortex-a8 erratum. The following cases13/// should not trigger the Erratum14 .syntax unified15 .thumb16 .text17 .global _start18 .balign 409619 .thumb_func20_start:21 nop.w22 .space 408623 .thumb_func24target:25/// 32-bit branch spans 2 4KiB regions, preceded by a 32-bit branch so no patch26/// expected.27 b.w target28 b.w target29 30// CALLSITE1: 00021ffa <target>:31// CALLSITE1-NEXT: 21ffa: b.w 0x21ffa <target>32// CALLSITE1-NEXT: 21ffe: b.w 0x21ffa <target>33 34 .space 408835 .type target2, %function36target2:37/// 32-bit Branch and link spans 2 4KiB regions, preceded by a 16-bit38/// instruction so no patch expected.39 nop40 nop41 bl target242 43// CALLSITE2: 00022ffa <target2>:44// CALLSITE2-NEXT: 22ffa: nop45// CALLSITE2-NEXT: 22ffc: nop46// CALLSITE2-NEXT: 22ffe: bl 0x22ffa <target2>47 48 .space 408849 .type target3, %function50target3:51/// 32-bit conditional branch spans 2 4KiB regions, preceded by a 32-bit52/// non branch instruction, branch is backwards but outside 4KiB region. So53/// expect no patch.54 nop.w55 beq.w target256 57// CALLSITE3: 00023ffa <target3>:58// CALLSITE3-NEXT: 23ffa: nop.w59// CALLSITE3-NEXT: 23ffe: beq.w 0x22ffa <target2>60 61 .space 408862 .type source4, %function63source4:64/// 32-bit conditional branch spans 2 4KiB regions, preceded by a 32-bit65/// non branch instruction, branch is forwards to 2nd region so expect no patch.66 nop.w67 beq.w target468 .thumb_func69target4:70 nop.w71 72// CALLSITE4: 00024ffa <source4>:73// CALLSITE4-NEXT: 24ffa: nop.w74// CALLSITE4-NEXT: 24ffe: beq.w 0x25002 <target4>75// CALLSITE4: 00025002 <target4>:76// CALLSITE4-NEXT: 25002: nop.w77 78 .space 408279 .type target5, %function80 81target5:82/// 32-bit conditional branch spans 2 4KiB regions, preceded by the encoding of83/// a 32-bit thumb instruction, but in ARM state (illegal instruction), we84/// should not decode and match it as Thumb, expect no patch.85 .arm86 .short 0xbf00 // nop encoding in Thumb for alignment87 .inst 0xf3af8000 /// nop.w encoding in Thumb88 .thumb89 .thumb_func90source5:91 beq.w target592 93// CALLSITE5: 00025ffe <source5>:94// CALLSITE5-NEXT: 25ffe: beq.w 0x25ff8 <target5>95 96/// Edge case where two word sequence starts at offset 0xffc, check that97/// we don't match. In this case the branch will be completely in the 2nd98/// region and the branch will target the second region. This will pass a99/// branch destination in the same region test, but not the branch must have100/// and address of the form xxxxxffe.101 .space 4090102 .type target6, %function103 nop.w104/// Make sure target of branch is in the same 4KiB region as the branch.105target6:106 bl target6107 108// CALLSITE6: 00027000 <target6>:109// CALLSITE6-NEXT: 27000: bl 0x27000 <target6>110 111/// Edge case where two word sequence starts at offset 0xffe, check that112/// we don't match. In this case the branch will be completely in the 2nd113/// region and the branch will target the second region. This will pass a114/// branch destination in the same region test, but not the branch must have115/// and address of the form xxxxxffe.116 .space 4090117 .type target7, %function118 nop.w119/// Make sure target of branch is in the same 4KiB region as the branch.120target7:121 bl target7122 123// CALLSITE7: 00028002 <target7>:124// CALLSITE7: 28002: bl 0x28002 <target7>125