Skip to content

Commit 58759b2

Browse files
committed
[WIP] Support used(linker)
1 parent 50aaa77 commit 58759b2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/constant.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
363363
continue;
364364
}
365365

366+
let mut data = DataDescription::new();
367+
366368
let (data_id, alloc, section_name) = match todo_item {
367369
TodoItem::Alloc(alloc_id) => {
368370
let alloc = match tcx.global_alloc(alloc_id) {
@@ -381,7 +383,10 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
381383
(data_id, alloc, None)
382384
}
383385
TodoItem::Static(def_id) => {
384-
let section_name = tcx.codegen_fn_attrs(def_id).link_section;
386+
let codegen_fn_attrs = tcx.codegen_fn_attrs(def_id);
387+
let section_name = codegen_fn_attrs.link_section;
388+
389+
data.set_used(codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER));
385390

386391
let alloc = tcx.eval_static_initializer(def_id).unwrap();
387392

@@ -396,7 +401,6 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
396401
}
397402
};
398403

399-
let mut data = DataDescription::new();
400404
let alloc = alloc.inner();
401405
data.set_align(alloc.align.bytes());
402406

0 commit comments

Comments
 (0)