Skip to content

Commit 207b8a9

Browse files
committed
---
yaml --- r: 64676 b: refs/heads/snap-stage3 c: af78e23 h: refs/heads/master v: v3
1 parent 6dc112b commit 207b8a9

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 359755a39a1d216a03a4e4d0b14e64e6610bbf91
4+
refs/heads/snap-stage3: af78e23006d9795bca32267a31e6f3cb9e73a6e1
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/middle/trans/base.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2449,7 +2449,7 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::node_id) -> ValueRef {
24492449
let val = match item {
24502450
ast_map::node_item(i, pth) => {
24512451
let my_path = vec::append((*pth).clone(), [path_name(i.ident)]);
2452-
match i.node {
2452+
let v = match i.node {
24532453
ast::item_static(_, m, expr) => {
24542454
let typ = ty::node_id_to_type(ccx.tcx, i.id);
24552455
let s = mangle_exported_name(ccx, my_path, typ);
@@ -2481,7 +2481,16 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::node_id) -> ValueRef {
24812481
llfn
24822482
}
24832483
_ => fail!("get_item_val: weird result in table")
2484+
};
2485+
match (attr::first_attr_value_str_by_name(i.attrs, "link_section")) {
2486+
Some(sect) => unsafe {
2487+
do sect.as_c_str |buf| {
2488+
llvm::LLVMSetSection(v, buf);
2489+
}
2490+
},
2491+
None => ()
24842492
}
2493+
v
24852494
}
24862495
ast_map::node_trait_method(trait_method, _, pth) => {
24872496
debug!("get_item_val(): processing a node_trait_method");
Lines changed: 34 additions & 0 deletions
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)