Skip to content

Commit 346ed79

Browse files
committed
[WIP] Support used(linker)
1 parent 8213acb commit 346ed79

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
@@ -356,6 +356,8 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
356356
continue;
357357
}
358358

359+
let mut data = DataDescription::new();
360+
359361
let (data_id, alloc, section_name) = match todo_item {
360362
TodoItem::Alloc(alloc_id) => {
361363
let alloc = match tcx.global_alloc(alloc_id) {
@@ -373,7 +375,10 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
373375
(data_id, alloc, None)
374376
}
375377
TodoItem::Static(def_id) => {
376-
let section_name = tcx.codegen_fn_attrs(def_id).link_section;
378+
let codegen_fn_attrs = tcx.codegen_fn_attrs(def_id);
379+
let section_name = codegen_fn_attrs.link_section;
380+
381+
data.set_used(codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER));
377382

378383
let alloc = tcx.eval_static_initializer(def_id).unwrap();
379384

@@ -388,7 +393,6 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
388393
}
389394
};
390395

391-
let mut data = DataDescription::new();
392396
let alloc = alloc.inner();
393397
data.set_align(alloc.align.bytes());
394398

0 commit comments

Comments
 (0)