103 lines · plain
1// REQUIRES: arm2// RUN: rm -rf %t && split-file %s %t && cd %t3// RUN: llvm-mc -filetype=obj -triple=armv7-none-eabi code.s -o code.o4// RUN: ld.lld -T unsigned1.ld code.o -o unsigned1.elf5// RUN: llvm-objdump --triple=armv7 --no-show-raw-insn -d unsigned1.elf | FileCheck %s --check-prefix=UNSIGNED16// RUN: ld.lld -T unsigned2.ld code.o -o unsigned2.elf7// RUN: llvm-objdump --triple=armv7 --no-show-raw-insn -d unsigned2.elf | FileCheck %s --check-prefix=UNSIGNED28// RUN: ld.lld -T signed1.ld code.o -o signed1.elf9// RUN: llvm-objdump --triple=armv7 --no-show-raw-insn -d signed1.elf | FileCheck %s --check-prefix=SIGNED110// RUN: ld.lld -T signed2.ld code.o -o signed2.elf11// RUN: llvm-objdump --triple=armv7 --no-show-raw-insn -d signed2.elf | FileCheck %s --check-prefix=SIGNED212 13/// The aim of this test is to ensure that a BL instruction near one end of the14/// address space can reach a function at the extreme other end, directly,15/// using a branch offset that makes the address wrap round. We check this at16/// both the unsigned wraparound point (one address near 0 and the other near17/// 0xFFFFFFFF) and the signed wraparound point (addresses either side of18/// 0x80000000), crossing the boundary in both directions. In all four cases we19/// expect a direct branch with no veneer.20 21// UNSIGNED1: Disassembly of section .text.lowaddr:22// UNSIGNED1: <func>:23// UNSIGNED1: 10000: bx lr24//25// UNSIGNED1: Disassembly of section .text.highaddr:26// UNSIGNED1: <_start>:27// UNSIGNED1: ffff0000: bl 0x1000028// UNSIGNED1-NEXT: bx lr29 30// UNSIGNED2: Disassembly of section .text.lowaddr:31// UNSIGNED2: <_start>:32// UNSIGNED2: 10000: bl 0xffff000033// UNSIGNED2-NEXT: bx lr34//35// UNSIGNED2: Disassembly of section .text.highaddr:36// UNSIGNED2: <func>:37// UNSIGNED2: ffff0000: bx lr38 39// SIGNED1: Disassembly of section .text.posaddr:40// SIGNED1: <_start>:41// SIGNED1: 7fff0000: bl 0x8001000042// SIGNED1-NEXT: bx lr43//44// SIGNED1: Disassembly of section .text.negaddr:45// SIGNED1: <func>:46// SIGNED1: 80010000: bx lr47 48// SIGNED2: Disassembly of section .text.posaddr:49// SIGNED2: <func>:50// SIGNED2: 7fff0000: bx lr51//52// SIGNED2: Disassembly of section .text.negaddr:53// SIGNED2: <_start>:54// SIGNED2: 80010000: bl 0x7fff000055// SIGNED2-NEXT: bx lr56 57//--- code.s58 59 .section .text.callee, "ax", %progbits60 .global func61 .type func, %function62func:63 bx lr64 65 .section .text.caller, "ax", %progbits66 .global _start67 .type _start, %function68_start:69 bl func70 bx lr71 72//--- unsigned1.ld73 74ENTRY(_start)75SECTIONS {76 .text.lowaddr 0x00010000 : AT(0x00010000) { *(.text.callee) }77 .text.highaddr 0xffff0000 : AT(0xffff0000) { *(.text.caller) }78}79 80//--- unsigned2.ld81 82ENTRY(_start)83SECTIONS {84 .text.lowaddr 0x00010000 : AT(0x00010000) { *(.text.caller) }85 .text.highaddr 0xffff0000 : AT(0xffff0000) { *(.text.callee) }86}87 88//--- signed1.ld89 90ENTRY(_start)91SECTIONS {92 .text.posaddr 0x7fff0000 : AT(0x7fff0000) { *(.text.caller) }93 .text.negaddr 0x80010000 : AT(0x80010000) { *(.text.callee) }94}95 96//--- signed2.ld97 98ENTRY(_start)99SECTIONS {100 .text.posaddr 0x7fff0000 : AT(0x7fff0000) { *(.text.callee) }101 .text.negaddr 0x80010000 : AT(0x80010000) { *(.text.caller) }102}103