Skip to content

Commit 8483461

Browse files
committed
Support used(linker)
1 parent 17f2c4d commit 8483461

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
@@ -372,6 +372,8 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
372372
continue;
373373
}
374374

375+
let mut data = DataDescription::new();
376+
375377
let (data_id, alloc, section_name) = match todo_item {
376378
TodoItem::Alloc(alloc_id) => {
377379
let alloc = match tcx.global_alloc(alloc_id) {
@@ -390,7 +392,10 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
390392
(data_id, alloc, None)
391393
}
392394
TodoItem::Static(def_id) => {
393-
let section_name = tcx.codegen_fn_attrs(def_id).link_section;
395+
let codegen_fn_attrs = tcx.codegen_fn_attrs(def_id);
396+
let section_name = codegen_fn_attrs.link_section;
397+
398+
data.set_used(codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER));
394399

395400
let alloc = tcx.eval_static_initializer(def_id).unwrap();
396401

@@ -405,7 +410,6 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
405410
}
406411
};
407412

408-
let mut data = DataDescription::new();
409413
let alloc = alloc.inner();
410414
data.set_align(alloc.align.bytes());
411415

0 commit comments

Comments
 (0)