Skip to content

Commit

Permalink
Set correct segment from #[link_section] for MachO
Browse files Browse the repository at this point in the history
  • Loading branch information
eggyal committed Apr 30, 2021
1 parent ddd4ce2 commit 95e6481
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/constant.rs
Expand Up @@ -374,8 +374,19 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
data_ctx.set_align(alloc.align.bytes());

if let Some(section_name) = section_name {
// FIXME set correct segment for Mach-O files
data_ctx.set_segment_section("", &*section_name);
let (segment_name, section_name) = if tcx.sess.target.is_like_osx {
if let Some(names) = section_name.split_once(',') {
names
} else {
tcx.sess.fatal(&format!(
"#[link_section = \"{}\"] is not valid for macos target: must be segment and section separated by comma",
section_name
));
}
} else {
("", &*section_name)
};
data_ctx.set_segment_section(segment_name, section_name);
}

let bytes = alloc.inspect_with_uninit_and_ptr_outside_interpreter(0..alloc.len()).to_vec();
Expand Down

0 comments on commit 95e6481

Please sign in to comment.