mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-24 18:03:25 +00:00
Solve the haunting i386 data layout in Linux legacy boot
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
68793d28c5
commit
f703d915cd
@ -1,6 +1,6 @@
|
||||
{
|
||||
"llvm-target": "i386-unknown-none",
|
||||
"data-layout": "e-m:e-i32:32-f80:128-n8:16:32-S128-p:32:32",
|
||||
"data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128",
|
||||
"cpu": "i386",
|
||||
"arch": "x86",
|
||||
"dynamic-linking": false,
|
||||
|
@ -15,23 +15,7 @@ fn get_rela_array() -> &'static [Elf64Rela] {
|
||||
}
|
||||
let start = __rela_dyn_start as *const Elf64Rela;
|
||||
let end = __rela_dyn_end as *const Elf64Rela;
|
||||
// FIXME: 2023/11/29
|
||||
// There should be a Rust compiler bug that makes the calculation of len incorrect.
|
||||
// The most sound implementation only works in debug mode.
|
||||
// let len = unsafe { end.offset_from(start) } as usize;
|
||||
// The inline asm solution is a workaround.
|
||||
let len = unsafe {
|
||||
let len: usize;
|
||||
core::arch::asm!("
|
||||
mov {len}, {end}
|
||||
sub {len}, {start}
|
||||
",
|
||||
len = out(reg) len,
|
||||
end = in(reg) end,
|
||||
start = in(reg) start,
|
||||
);
|
||||
len / core::mem::size_of::<Elf64Rela>()
|
||||
};
|
||||
let len = unsafe { end.offset_from(start) } as usize;
|
||||
#[cfg(feature = "debug_print")]
|
||||
unsafe {
|
||||
use crate::console::{print_hex, print_str};
|
||||
|
Reference in New Issue
Block a user