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