diff options
| author | dianqk <dianqk@dianqk.net> | 2025-06-30 19:23:17 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-30 19:23:17 +0800 |
| commit | 0952f86de31f90b0e9f2bc700243fcc711990aa9 (patch) | |
| tree | 3fd1ced5b745ab0c85c5b6a5d9fe26e69d7319d9 /tests/ui/linkage-attr | |
| parent | a94f0a4af8a1c11c1934ee8ba44d59fb5da77d4b (diff) | |
| parent | 580bc128441236345a5f3d5022af5a60091451ac (diff) | |
| download | rust-0952f86de31f90b0e9f2bc700243fcc711990aa9.tar.gz rust-0952f86de31f90b0e9f2bc700243fcc711990aa9.zip | |
Rollup merge of #143118 - Kivooeo:tf15, r=tgross35
`tests/ui`: A New Order [15/N] > [!NOTE] > > Intermediate commits are intended to help review, but will be squashed prior to merge. Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895. r? `@jieyouxu`
Diffstat (limited to 'tests/ui/linkage-attr')
| -rw-r--r-- | tests/ui/linkage-attr/link-section-placement.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/ui/linkage-attr/link-section-placement.rs b/tests/ui/linkage-attr/link-section-placement.rs new file mode 100644 index 00000000000..6a143bfedb4 --- /dev/null +++ b/tests/ui/linkage-attr/link-section-placement.rs @@ -0,0 +1,41 @@ +//! Test placement of functions and statics in custom link sections + +//@ run-pass + +// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +#![allow(static_mut_refs)] +#![allow(non_upper_case_globals)] +#[cfg(not(target_vendor = "apple"))] +#[link_section = ".moretext"] +fn i_live_in_more_text() -> &'static str { + "knock knock" +} + +#[cfg(not(target_vendor = "apple"))] +#[link_section = ".imm"] +static magic: usize = 42; + +#[cfg(not(target_vendor = "apple"))] +#[link_section = ".mut"] +static mut frobulator: usize = 0xdeadbeef; + +#[cfg(target_vendor = "apple")] +#[link_section = "__TEXT,__moretext"] +fn i_live_in_more_text() -> &'static str { + "knock knock" +} + +#[cfg(target_vendor = "apple")] +#[link_section = "__RODATA,__imm"] +static magic: usize = 42; + +#[cfg(target_vendor = "apple")] +#[link_section = "__DATA,__mut"] +static mut frobulator: usize = 0xdeadbeef; + +pub fn main() { + unsafe { + frobulator = 0x12345678; + println!("{} {} {}", i_live_in_more_text(), magic, frobulator); + } +} |
