|
| 1 | +#![feature(no_core)] |
| 2 | +#![no_core] |
| 3 | +#![no_main] |
| 4 | + |
| 5 | +extern crate minicore; |
| 6 | +use minicore::*; |
| 7 | + |
| 8 | +#[unsafe(no_mangle)] |
| 9 | +fn entry() { |
| 10 | + arm(); |
| 11 | + thumb(); |
| 12 | +} |
| 13 | + |
| 14 | +#[unsafe(no_mangle)] |
| 15 | +pub fn arm() { |
| 16 | + // thumbv5te-LABEL: <arm>: |
| 17 | + // thumbv5te: blx {{0x[0-9a-f]+}} <main::arm_normalfn> |
| 18 | + // thumbv5te: blx {{0x[0-9a-f]+}} <arm_globalfn> |
| 19 | + // thumbv5te: blx {{0x[0-9a-f]+}} <main::arm_nakedfn> |
| 20 | + |
| 21 | + // thumbv4t-LABEL: <arm>: |
| 22 | + // thumbv4t: bl {{0x[0-9a-f]+}} <__Thumbv4ABSLongBXThunk__{{.*}}arm_normalfn> |
| 23 | + // thumbv4t: bl {{0x[0-9a-f]+}} <__Thumbv4ABSLongBXThunk_arm_globalfn> |
| 24 | + // thumbv4t: bl {{0x[0-9a-f]+}} <__Thumbv4ABSLongBXThunk__{{.*}}arm_nakedfn> |
| 25 | + |
| 26 | + // armv5te-LABEL: <arm>: |
| 27 | + // armv5te: bl {{0x[0-9a-f]+}} <main::arm_normalfn> |
| 28 | + // armv5te: bl {{0x[0-9a-f]+}} <arm_globalfn> |
| 29 | + // armv5te: bl {{0x[0-9a-f]+}} <main::arm_nakedfn> |
| 30 | + |
| 31 | + // armv4t-LABEL: <arm>: |
| 32 | + // armv4t: bl {{0x[0-9a-f]+}} <main::arm_normalfn> |
| 33 | + // armv4t: bl {{0x[0-9a-f]+}} <arm_globalfn> |
| 34 | + // armv4t: bl {{0x[0-9a-f]+}} <main::arm_nakedfn> |
| 35 | + arm_normalfn(); |
| 36 | + arm_globalfn(); |
| 37 | + arm_nakedfn(); |
| 38 | +} |
| 39 | + |
| 40 | +#[unsafe(no_mangle)] |
| 41 | +pub fn thumb() { |
| 42 | + // thumbv5te-LABEL: <thumb>: |
| 43 | + // thumbv5te: bl {{0x[0-9a-f]+}} <main::thumb_normalfn> |
| 44 | + // thumbv5te: bl {{0x[0-9a-f]+}} <thumb_globalfn> |
| 45 | + // thumbv5te: bl {{0x[0-9a-f]+}} <main::thumb_nakedfn> |
| 46 | + |
| 47 | + // thumbv4t-LABEL: <thumb>: |
| 48 | + // thumbv4t: bl {{0x[0-9a-f]+}} <main::thumb_normalfn> |
| 49 | + // thumbv4t: bl {{0x[0-9a-f]+}} <thumb_globalfn> |
| 50 | + // thumbv4t: bl {{0x[0-9a-f]+}} <main::thumb_nakedfn> |
| 51 | + |
| 52 | + // armv5te-LABEL: <thumb>: |
| 53 | + // armv5te: blx {{0x[0-9a-f]+}} <main::thumb_normalfn> |
| 54 | + // armv5te: blx {{0x[0-9a-f]+}} <thumb_globalfn> |
| 55 | + // armv5te: blx {{0x[0-9a-f]+}} <main::thumb_nakedfn> |
| 56 | + |
| 57 | + // armv4t-LABEL: <thumb>: |
| 58 | + // armv4t: bl {{0x[0-9a-f]+}} <__ARMv4ABSLongBXThunk__{{.*}}thumb_normalfn> |
| 59 | + // armv4t: bl {{0x[0-9a-f]+}} <__ARMv4ABSLongBXThunk_thumb_globalfn> |
| 60 | + // armv4t: bl {{0x[0-9a-f]+}} <__ARMv4ABSLongBXThunk__{{.*}}thumb_nakedfn> |
| 61 | + thumb_normalfn(); |
| 62 | + thumb_globalfn(); |
| 63 | + thumb_nakedfn(); |
| 64 | +} |
| 65 | + |
| 66 | +#[instruction_set(arm::t32)] |
| 67 | +extern "C" fn thumb_normalfn() { |
| 68 | + unsafe { asm!("nop") } |
| 69 | +} |
| 70 | + |
| 71 | +unsafe extern "C" { |
| 72 | + safe fn thumb_globalfn(); |
| 73 | +} |
| 74 | + |
| 75 | +global_asm!( |
| 76 | + r#" |
| 77 | + .thumb |
| 78 | + .global thumb_globalfn |
| 79 | + .type thumb_globalfn, %function |
| 80 | + thumb_globalfn: |
| 81 | + nop |
| 82 | + bx lr |
| 83 | + .size thumb_globalfn, . - thumb_globalfn |
| 84 | +"# |
| 85 | +); |
| 86 | + |
| 87 | +#[unsafe(naked)] |
| 88 | +#[instruction_set(arm::t32)] |
| 89 | +extern "C" fn thumb_nakedfn() { |
| 90 | + naked_asm!("nop", "bx lr",); |
| 91 | +} |
| 92 | + |
| 93 | +#[instruction_set(arm::a32)] |
| 94 | +extern "C" fn arm_normalfn() { |
| 95 | + unsafe { asm!("nop") } |
| 96 | +} |
| 97 | + |
| 98 | +unsafe extern "C" { |
| 99 | + safe fn arm_globalfn(); |
| 100 | +} |
| 101 | + |
| 102 | +global_asm!( |
| 103 | + r#" |
| 104 | + .arm |
| 105 | + .global arm_globalfn |
| 106 | + .type arm_globalfn, %function |
| 107 | + arm_globalfn: |
| 108 | + nop |
| 109 | + bx lr |
| 110 | + .size arm_globalfn, . - arm_globalfn |
| 111 | +"# |
| 112 | +); |
| 113 | + |
| 114 | +#[unsafe(naked)] |
| 115 | +#[instruction_set(arm::a32)] |
| 116 | +extern "C" fn arm_nakedfn() { |
| 117 | + naked_asm!("nop", "bx lr",); |
| 118 | +} |
0 commit comments