brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · 08e37bf Raw
116 lines · plain
1# REQUIRES: hexagon2# RUN: rm -rf %t && split-file %s %t && cd %t3# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf main.s -o main.o4# RUN: ld.lld main.o -o test5# RUN: llvm-objdump -d --no-show-raw-insn test | FileCheck %s6 7## Test thunk range scenarios for Hexagon R_HEX_B22_PCREL relocations.8## R_HEX_B22_PCREL has a range of +/- 8MB (0x800000 bytes).9 10#--- main.s11.globl _start12.type _start, %function13_start:14  call target_within_range_max15  call target_beyond_range16  call target_within_range_min17  call target_beyond_range_min18  call target_multiple_calls19  call target_multiple_calls20  call target_close21  jumpr r3122 23target_close:24  jumpr r3125 26## Target at maximum positive range (8MB - 4 bytes from _start)27## We need to account for the instructions above: 7 calls + 1 jumpr = 8 * 4 = 32 bytes28.skip 0X7fffbc29.globl target_within_range_max30.type target_within_range_max, %function31target_within_range_max:32  jumpr r3133 34## Target just beyond maximum positive range (needs thunk)35.skip 836.globl target_beyond_range37.type target_beyond_range, %function38target_beyond_range:39  call target_within_range_max40  jumpr r3141 42## Target for multiple calls test43.skip 0x10000044.globl target_multiple_calls45.type target_multiple_calls, %function46target_multiple_calls:47  jumpr r3148 49## Now place targets at maximum negative range50## We'll put these before _start in memory layout51.section .text_negative, "ax", %progbits52 53## Target at maximum negative range (-8MB + 4 bytes from _start)54.globl target_within_range_min55.type target_within_range_min, %function56target_within_range_min:57  call target_close58  jumpr r3159 60.skip 0X7ffff461 62## Target beyond maximum negative range (needs thunk)63.globl target_beyond_range_min64.type target_beyond_range_min, %function65target_beyond_range_min:66  jumpr r3167 68## Verify thunk generation for targets beyond B22_PCREL range69# CHECK:       <__hexagon_thunk_target_within_range_min_from_.text.thunk>:70# CHECK-NEXT:    200b4: { immext(#0x900000)71# CHECK-NEXT:             jump 0x9200cc <target_within_range_min> }72 73# CHECK:       <__hexagon_thunk_target_beyond_range_min_from_.text.thunk>:74# CHECK-NEXT:    200bc: { immext(#0x1100000)75# CHECK-NEXT:             jump 0x11200c8 <target_beyond_range_min> }76 77# CHECK:       <__hexagon_thunk_target_multiple_calls_from_.text.thunk>:78# CHECK-NEXT:    200c4: { immext(#0x8fffc0)79# CHECK-NEXT:             jump 0x9200c0 <target_multiple_calls> }80 81## Verify _start calls - some direct, some via thunks82# CHECK:       <_start>:83# CHECK-NEXT:    200cc: { call 0x8200ac <target_within_range_max> }84# CHECK-NEXT:           { call 0x8200b8 <target_beyond_range> }85# CHECK-NEXT:           { call 0x200b4 <__hexagon_thunk_target_within_range_min_from_.text.thunk> }86# CHECK-NEXT:           { call 0x200bc <__hexagon_thunk_target_beyond_range_min_from_.text.thunk> }87# CHECK-NEXT:           { call 0x200c4 <__hexagon_thunk_target_multiple_calls_from_.text.thunk> }88# CHECK-NEXT:           { call 0x200c4 <__hexagon_thunk_target_multiple_calls_from_.text.thunk> }89# CHECK-NEXT:           { call 0x200ec <target_close> }90 91# CHECK:      <target_close>:92# CHECK-NEXT:    200ec: { jumpr r31 }93 94## Verify targets at maximum positive range (direct calls, no thunks needed)95# CHECK:      <target_within_range_max>:96# CHECK-NEXT:  8200ac: { jumpr r31 }97 98# CHECK:      <target_beyond_range>:99# CHECK-NEXT:  8200b8: { call 0x8200ac <target_within_range_max> }100# CHECK-NEXT:          { jumpr r31 }101 102# CHECK:      <target_multiple_calls>:103# CHECK-NEXT:  9200c0: { jumpr r31 }104 105## Verify targets in negative section and thunk for calling back to main section106# CHECK:      <__hexagon_thunk__from_.text.thunk>:107# CHECK-NEXT:  9200c4: { immext(#0xff700000)108# CHECK-NEXT:            jump 0x200cc <_start> }109 110# CHECK:      <target_within_range_min>:111# CHECK-NEXT:  9200cc: { call 0x9200c4 <__hexagon_thunk__from_.text.thunk> }112# CHECK-NEXT:          { jumpr r31 }113 114# CHECK:      <target_beyond_range_min>:115# CHECK-NEXT: 11200c8: { jumpr r31 }116