Skip to content

Commit 507b609

Browse files
committed
make naked functions always have external linkage
1 parent 7af3c76 commit 507b609

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,14 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
109109
sym::rustc_allocator_zeroed => {
110110
codegen_fn_attrs.flags |= CodegenFnAttrFlags::ALLOCATOR_ZEROED
111111
}
112-
sym::naked => codegen_fn_attrs.flags |= CodegenFnAttrFlags::NAKED,
112+
sym::naked => {
113+
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NAKED;
114+
115+
// naked functions are generated as an extern function, and a global asm block that
116+
// contains the naked function's body. In order to link these together, the linkage
117+
// of the extern function must be external.
118+
codegen_fn_attrs.linkage = Some(Linkage::External);
119+
}
113120
sym::no_mangle => {
114121
if tcx.opt_item_name(did.to_def_id()).is_some() {
115122
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_MANGLE

0 commit comments

Comments
 (0)