]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/link-section.rs
Imported Upstream version 1.0.0~beta
[rustc.git] / src / test / run-pass / link-section.rs
CommitLineData
1a4d82fc
JJ
1// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11#[cfg(not(target_os = "macos"))]
12#[link_section=".moretext"]
13fn i_live_in_more_text() -> &'static str {
14 "knock knock"
15}
16
17#[cfg(not(target_os = "macos"))]
18#[link_section=".imm"]
c34b1796 19static magic: usize = 42;
1a4d82fc
JJ
20
21#[cfg(not(target_os = "macos"))]
22#[link_section=".mut"]
c34b1796 23static mut frobulator: usize = 0xdeadbeef;
1a4d82fc
JJ
24
25#[cfg(target_os = "macos")]
26#[link_section="__TEXT,__moretext"]
27fn i_live_in_more_text() -> &'static str {
28 "knock knock"
29}
30
31#[cfg(target_os = "macos")]
32#[link_section="__RODATA,__imm"]
c34b1796 33static magic: usize = 42;
1a4d82fc
JJ
34
35#[cfg(target_os = "macos")]
36#[link_section="__DATA,__mut"]
c34b1796 37static mut frobulator: usize = 0xdeadbeef;
1a4d82fc
JJ
38
39pub fn main() {
40 unsafe {
41 frobulator = 0xcafebabe;
42 println!("{} {} {}", i_live_in_more_text(), magic, frobulator);
43 }
44}