brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · c10b229 Raw
71 lines · plain
1// REQUIRES: arm2// RUN: llvm-mc -filetype=obj -triple=thumbv7-windows %s -o %t.obj3// RUN: lld-link -entry:main -subsystem:console %t.obj -out:%t.exe -verbose 2>&1 | FileCheck -check-prefix=VERBOSE %s4// RUN: llvm-objdump --no-print-imm-hex -d %t.exe --start-address=0x403000 --stop-address=0x403008 | FileCheck --check-prefix=FUNC01 %s5// RUN: llvm-objdump --no-print-imm-hex -d %t.exe --start-address=0x404ffa --stop-address=0x405012 | FileCheck --check-prefix=FUNC01-THUNKS %s6 7// VERBOSE: Added {{.*}} thunks with margin 204800 in 2 passes8 9    .syntax unified10    .globl main11    .text12main:13    b  func0114    bx lr15 16.irp i, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 1817    .section .text$\i\()a, "xr"18    .balign 819219func\i:20    bne far_func\i21    bne func_within_margin\i22    // Originally, the first section is less than 8192 bytes large, and the23    // second one follows almost directly. After adding one thunk after24    // the first section, the second one will move forward by 8192 bytes25    // due to the alignment.26    .space 8192 - 8 - 427 28    .section .text$\i\()b, "xr"29    .balign 819230align\i:31    nop32.endr33 34    .section .text$999, "xr"35tail:36    .space 0x100000 - 100*1024 - 18*8192*237    // Initially, these symbols are within range from all the sections above,38    // even when taking the initial margin into account. After adding thunks39    // to all the sections above, some of these are also out of range, forcing40    // running a second pass.41.irp i, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 1842func_within_margin\i:43    nop44.endr45    .space 0x10000046 47    // These are always out of range.48.irp i, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 1849far_func\i:50    nop51.endr52    bx lr53 54// FUNC01: 403000:       f041 87fc       bne.w   0x404ffc <.text+0x3ffc>55// FUNC01: 403004:       f041 87ff       bne.w   0x405006 <.text+0x4006>56 57// Check that we only have two thunks here, even if we created the first58// thunk twice (once in the first pass, then thrown away and recreated59// in the second pass).60 61// FUNC01-THUNKS: 404ffa:       0000            movs    r0,  r062// The instruction above is padding from the .space63// FUNC01-THUNKS: 404ffc:       f247 0c1e       movw    r12, #2870264// FUNC01-THUNKS: 405000:       f2c0 0c20       movt    r12, #3265// FUNC01-THUNKS: 405004:       44e7            add     pc,  r1266// FUNC01-THUNKS: 405006:       f646 7cf0       movw    r12, #2865667// FUNC01-THUNKS: 40500a:       f2c0 0c10       movt    r12, #1668// FUNC01-THUNKS: 40500e:       44e7            add     pc, r1269// The instruction below is padding from the .balign70// FUNC01-THUNKS: 405010:       0000            movs    r0, r071