Skip to content

Commit c6c1472

Browse files
committed
Add simple link_section test to exercise it
1 parent 64ff30a commit c6c1472

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/test/run-pass/link-section.rs

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#[cfg(not(target_os = "macos"))]
2+
#[link_section=".moretext"]
3+
fn i_live_in_more_text() -> &'static str {
4+
"knock knock"
5+
}
6+
7+
#[cfg(not(target_os = "macos"))]
8+
#[link_section=".imm"]
9+
static magic: uint = 42;
10+
11+
#[cfg(not(target_os = "macos"))]
12+
#[link_section=".mut"]
13+
static mut frobulator: uint = 0xdeadbeef;
14+
15+
#[cfg(target_os = "macos")]
16+
#[link_section="__TEXT,__moretext"]
17+
fn i_live_in_more_text() -> &'static str {
18+
"knock knock"
19+
}
20+
21+
#[cfg(target_os = "macos")]
22+
#[link_section="__RODATA,__imm"]
23+
static magic: uint = 42;
24+
25+
#[cfg(target_os = "macos")]
26+
#[link_section="__DATA,__mut"]
27+
static mut frobulator: uint = 0xdeadbeef;
28+
29+
fn main() {
30+
unsafe {
31+
frobulator = 0xcafebabe;
32+
printfln!("%? %? %?", i_live_in_more_text(), magic, frobulator);
33+
}
34+
}

0 commit comments

Comments
 (0)