]> git.lizzy.rs Git - rust.git/blob - tests/ui/link-section.rs
Rollup merge of #107740 - oli-obk:lock_tcx, r=petrochenkov
[rust.git] / tests / ui / link-section.rs
1 // run-pass
2
3 #![allow(non_upper_case_globals)]
4 #[cfg(not(target_os = "macos"))]
5 #[link_section=".moretext"]
6 fn i_live_in_more_text() -> &'static str {
7     "knock knock"
8 }
9
10 #[cfg(not(target_os = "macos"))]
11 #[link_section=".imm"]
12 static magic: usize = 42;
13
14 #[cfg(not(target_os = "macos"))]
15 #[link_section=".mut"]
16 static mut frobulator: usize = 0xdeadbeef;
17
18 #[cfg(target_os = "macos")]
19 #[link_section="__TEXT,__moretext"]
20 fn i_live_in_more_text() -> &'static str {
21     "knock knock"
22 }
23
24 #[cfg(target_os = "macos")]
25 #[link_section="__RODATA,__imm"]
26 static magic: usize = 42;
27
28 #[cfg(target_os = "macos")]
29 #[link_section="__DATA,__mut"]
30 static mut frobulator: usize = 0xdeadbeef;
31
32 pub fn main() {
33     unsafe {
34         frobulator = 0x12345678;
35         println!("{} {} {}", i_live_in_more_text(), magic, frobulator);
36     }
37 }