2024-02-16 20:02:50 +00:00
|
|
|
//@ run-pass
|
2019-07-26 21:54:25 +00:00
|
|
|
|
2024-08-24 03:49:09 +00:00
|
|
|
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
|
|
|
|
#![allow(static_mut_refs)]
|
|
|
|
|
2018-09-14 10:20:28 +00:00
|
|
|
#![allow(non_upper_case_globals)]
|
2024-05-27 13:17:18 +00:00
|
|
|
#[cfg(not(target_vendor = "apple"))]
|
|
|
|
#[link_section = ".moretext"]
|
2013-07-23 21:23:22 +00:00
|
|
|
fn i_live_in_more_text() -> &'static str {
|
|
|
|
"knock knock"
|
|
|
|
}
|
|
|
|
|
2024-05-27 13:17:18 +00:00
|
|
|
#[cfg(not(target_vendor = "apple"))]
|
|
|
|
#[link_section = ".imm"]
|
2015-03-26 00:06:52 +00:00
|
|
|
static magic: usize = 42;
|
2013-07-23 21:23:22 +00:00
|
|
|
|
2024-05-27 13:17:18 +00:00
|
|
|
#[cfg(not(target_vendor = "apple"))]
|
|
|
|
#[link_section = ".mut"]
|
2015-03-26 00:06:52 +00:00
|
|
|
static mut frobulator: usize = 0xdeadbeef;
|
2013-07-23 21:23:22 +00:00
|
|
|
|
2024-05-27 13:17:18 +00:00
|
|
|
#[cfg(target_vendor = "apple")]
|
|
|
|
#[link_section = "__TEXT,__moretext"]
|
2013-07-23 21:23:22 +00:00
|
|
|
fn i_live_in_more_text() -> &'static str {
|
|
|
|
"knock knock"
|
|
|
|
}
|
|
|
|
|
2024-05-27 13:17:18 +00:00
|
|
|
#[cfg(target_vendor = "apple")]
|
|
|
|
#[link_section = "__RODATA,__imm"]
|
2015-03-26 00:06:52 +00:00
|
|
|
static magic: usize = 42;
|
2013-07-23 21:23:22 +00:00
|
|
|
|
2024-05-27 13:17:18 +00:00
|
|
|
#[cfg(target_vendor = "apple")]
|
|
|
|
#[link_section = "__DATA,__mut"]
|
2015-03-26 00:06:52 +00:00
|
|
|
static mut frobulator: usize = 0xdeadbeef;
|
2013-07-23 21:23:22 +00:00
|
|
|
|
2013-09-25 07:43:37 +00:00
|
|
|
pub fn main() {
|
2013-07-23 21:23:22 +00:00
|
|
|
unsafe {
|
2022-01-01 05:13:07 +00:00
|
|
|
frobulator = 0x12345678;
|
2013-09-25 05:16:43 +00:00
|
|
|
println!("{} {} {}", i_live_in_more_text(), magic, frobulator);
|
2013-07-23 21:23:22 +00:00
|
|
|
}
|
|
|
|
}
|