Skip to content

Commit 0481a2f

Browse files
committed
add test for #[link_section]
1 parent 2136370 commit 0481a2f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/codegen/naked-fn/naked-functions.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,19 @@ pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize
129129
asm!("adds r0, r0, r1", "bx lr", options(noreturn))
130130
}
131131
}
132+
133+
// linux: .pushsection .text.some_different_name,\22ax\22, @progbits
134+
// macos: .pushsection .text.some_different_name,regular,pure_instructions
135+
// windows: .pushsection .text.some_different_name,\22xr\22
136+
// thumb: .pushsection .text.some_different_name,\22ax\22, %progbits
137+
// CHECK-LABEL: test_link_section:
138+
#[no_mangle]
139+
#[naked]
140+
#[link_section = ".text.some_different_name"]
141+
pub unsafe extern "C" fn test_link_section() {
142+
#[cfg(not(all(target_arch = "arm", target_feature = "thumb-mode")))]
143+
asm!("ret", options(noreturn));
144+
145+
#[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))]
146+
asm!("bx lr", options(noreturn));
147+
}

0 commit comments

Comments
 (0)