Skip to content

Commit 1da0c72

Browse files
committed
Fix build with Rust 1.88
1 parent 30f16c9 commit 1da0c72

File tree

3 files changed

+43
-51
lines changed

3 files changed

+43
-51
lines changed

src/arch.rs

Lines changed: 43 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -145,67 +145,61 @@ pub const ENTRY_TRAMPOLINE: Option<unsafe extern "C" fn() -> !> = Some(entry_tra
145145
pub const ENTRY_TRAMPOLINE: Option<unsafe extern "C" fn() -> !> = Some(entry_trampoline);
146146

147147
#[cfg(target_arch = "x86_64")]
148-
#[naked]
148+
#[unsafe(naked)]
149149
unsafe extern "C" fn entry_trampoline() -> ! {
150-
unsafe {
151-
core::arch::naked_asm!(
152-
"lea r10, [rip + {context}]",
153-
"mov r11, [r10 + {size} * 1]", // .env_entry
154-
"test r11, r11",
155-
"jz 2f",
156-
"mov r10, [r10 + {size} * 2]", // .env_string
157-
"mov [r11], r10",
158-
"2:",
159-
"jmp [rip + {context}]",
160-
context = sym TRAMPOLINE_CONTEXT,
161-
size = const core::mem::size_of::<*const u8>(),
162-
)
163-
}
150+
core::arch::naked_asm!(
151+
"lea r10, [rip + {context}]",
152+
"mov r11, [r10 + {size} * 1]", // .env_entry
153+
"test r11, r11",
154+
"jz 2f",
155+
"mov r10, [r10 + {size} * 2]", // .env_string
156+
"mov [r11], r10",
157+
"2:",
158+
"jmp [rip + {context}]",
159+
context = sym TRAMPOLINE_CONTEXT,
160+
size = const core::mem::size_of::<*const u8>(),
161+
)
164162
}
165163

166164
#[cfg(target_arch = "aarch64")]
167165
pub const ENTRY_TRAMPOLINE: Option<unsafe extern "C" fn() -> !> = Some(entry_trampoline);
168166

169167
#[cfg(target_arch = "aarch64")]
170-
#[naked]
168+
#[unsafe(naked)]
171169
unsafe extern "C" fn entry_trampoline() -> ! {
172-
unsafe {
173-
core::arch::naked_asm!(
174-
"adrp x8, {context}",
175-
"ldr x9, [x8, {env_entry_off}]", // .env_entry
176-
"cbz x9, 2f",
177-
"ldr x10, [x8, {env_string_off}]", // .env_string
178-
"str x10, [x9]",
179-
"2:",
180-
"ldr x8, [x8]",
181-
"br x8",
182-
context = sym TRAMPOLINE_CONTEXT,
183-
env_entry_off = const TrampolineContext::ENV_ENTRY_OFFSET,
184-
env_string_off = const TrampolineContext::ENV_STRING_OFFSET,
185-
)
186-
}
170+
core::arch::naked_asm!(
171+
"adrp x8, {context}",
172+
"ldr x9, [x8, {env_entry_off}]", // .env_entry
173+
"cbz x9, 2f",
174+
"ldr x10, [x8, {env_string_off}]", // .env_string
175+
"str x10, [x9]",
176+
"2:",
177+
"ldr x8, [x8]",
178+
"br x8",
179+
context = sym TRAMPOLINE_CONTEXT,
180+
env_entry_off = const TrampolineContext::ENV_ENTRY_OFFSET,
181+
env_string_off = const TrampolineContext::ENV_STRING_OFFSET,
182+
)
187183
}
188184

189185
#[cfg(target_arch = "riscv64")]
190-
#[naked]
186+
#[unsafe(naked)]
191187
unsafe extern "C" fn entry_trampoline() -> ! {
192-
unsafe {
193-
core::arch::naked_asm!(
194-
"1:",
195-
"auipc t0, %pcrel_hi({context})",
196-
"addi t0, t0, %pcrel_lo(1b)",
197-
"ld t1, {env_entry_off}(t0)", // .env_entry
198-
"beqz t1, 2f",
199-
"ld t2, {env_string_off}(t0)", // .env_string
200-
"sd t2, 0(t1)",
201-
"2:",
202-
"ld t0, 0(t0)",
203-
"jr t0",
204-
context = sym TRAMPOLINE_CONTEXT,
205-
env_entry_off = const TrampolineContext::ENV_ENTRY_OFFSET,
206-
env_string_off = const TrampolineContext::ENV_STRING_OFFSET,
207-
)
208-
}
188+
core::arch::naked_asm!(
189+
"1:",
190+
"auipc t0, %pcrel_hi({context})",
191+
"addi t0, t0, %pcrel_lo(1b)",
192+
"ld t1, {env_entry_off}(t0)", // .env_entry
193+
"beqz t1, 2f",
194+
"ld t2, {env_string_off}(t0)", // .env_string
195+
"sd t2, 0(t1)",
196+
"2:",
197+
"ld t0, 0(t0)",
198+
"jr t0",
199+
context = sym TRAMPOLINE_CONTEXT,
200+
env_entry_off = const TrampolineContext::ENV_ENTRY_OFFSET,
201+
env_string_off = const TrampolineContext::ENV_STRING_OFFSET,
202+
)
209203
}
210204

211205
// !!!!

src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(naked_functions)]
21
#![feature(lang_items)]
32
#![no_std]
43
#![no_main]

src/sys.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,5 +181,4 @@ pub fn new_slice_leak(size: usize) -> Option<&'static mut [u8]> {
181181

182182
#[cfg(not(test))]
183183
#[lang = "eh_personality"]
184-
#[unsafe(no_mangle)]
185184
pub extern "C" fn rust_eh_personality() {}

0 commit comments

Comments
 (0)