Skip to content

Commit

Permalink
[chore] put .init_array with rodata sections
Browse files Browse the repository at this point in the history
  • Loading branch information
Azure-stars committed Feb 11, 2025
1 parent 3cfc4ac commit 2f5c368
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 43 deletions.
5 changes: 1 addition & 4 deletions api/arceos_posix_api/src/imp/fd_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use flatten_objects::FlattenObjects;
use spin::RwLock;

use crate::ctypes;
use crate::imp::stdio::{stdin, stdout};

pub const AX_FILE_LIMIT: usize = 1024;

Expand Down Expand Up @@ -123,11 +124,7 @@ pub fn sys_fcntl(fd: c_int, cmd: c_int, arg: usize) -> c_int {
}

#[ctor_bare::register_ctor]
#[cfg(feature = "fd")]
fn init_stdio() {
use crate::imp::fd_ops::FD_TABLE;
use crate::imp::stdio::{stdin, stdout};
use alloc::sync::Arc;
let mut fd_table = flatten_objects::FlattenObjects::new();
fd_table
.add_at(0, Arc::new(stdin()) as _)
Expand Down
4 changes: 0 additions & 4 deletions api/arceos_posix_api/src/imp/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ fn console_read_bytes(buf: &mut [u8]) -> AxResult<usize> {
}

fn console_write_bytes(buf: &[u8]) -> AxResult<usize> {
#[cfg(feature = "uspace")]
// We need to copy the buffer to the kernel space because SBI can't access user space.
axhal::console::write_bytes(buf.to_vec().as_slice());
#[cfg(not(feature = "uspace"))]
axhal::console::write_bytes(buf);
Ok(buf.len())
}
Expand Down
2 changes: 1 addition & 1 deletion modules/axfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ axdriver = { workspace = true, features = ["block", "ramdisk"] }
axdriver_block = { git = "https://github.com/arceos-org/axdriver_crates.git", tag = "v0.1.0", features = ["ramdisk"] }
axsync = { workspace = true, features = ["multitask"] }
axtask = { workspace = true, features = ["test"] }
axns = { workspace = true, features = ["thread-local"] }
axns = { workspace = true, features = [] }
crate_interface = "0.1"
2 changes: 0 additions & 2 deletions modules/axfs/src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ use lazyinit::LazyInit;
use crate::{api::FileType, fs, mounts};

def_resource! {
#[allow(non_camel_case_types)]
static CURRENT_DIR_PATH: ResArc<Mutex<String>> = ResArc::new();
#[allow(non_camel_case_types)]
static CURRENT_DIR: ResArc<Mutex<VfsNodeRef>> = ResArc::new();
}

Expand Down
20 changes: 10 additions & 10 deletions modules/axhal/linker.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,22 @@ SECTIONS
_etext = .;
}

_srodata = .;
.rodata : ALIGN(4K) {
_srodata = .;
*(.rodata .rodata.*)
*(.srodata .srodata.*)
*(.sdata2 .sdata2.*)
. = ALIGN(4K);
_erodata = .;
}

.init_array : ALIGN(0x10) {
__init_array_start = .;
*(.init_array .init_array.*)
__init_array_end = .;
}

. = ALIGN(4K);
_erodata = .;

.data : ALIGN(4K) {
_sdata = .;
*(.data.boot_page_table)
Expand All @@ -40,13 +47,6 @@ SECTIONS
_etdata = .;
}

.init_array : ALIGN(4K) {
__init_array_start = .;
*(.init_array .init_array.*)
__init_array_end = .;
. = ALIGN(4K);
}

.tbss : ALIGN(0x10) {
_stbss = .;
*(.tbss .tbss.*)
Expand Down
44 changes: 22 additions & 22 deletions modules/axhal/src/arch/aarch64/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,29 +127,29 @@ impl UspaceContext {
unsafe {
core::arch::asm!(
"
mov sp, x1
ldp x30, x9, [x0, 30 * 8]
ldp x10, x11, [x0, 32 * 8]
msr sp_el0, x9
msr elr_el1, x10
msr spsr_el1, x11
mov sp, x1
ldp x30, x9, [x0, 30 * 8]
ldp x10, x11, [x0, 32 * 8]
msr sp_el0, x9
msr elr_el1, x10
msr spsr_el1, x11
ldp x28, x29, [x0, 28 * 8]
ldp x26, x27, [x0, 26 * 8]
ldp x24, x25, [x0, 24 * 8]
ldp x22, x23, [x0, 22 * 8]
ldp x20, x21, [x0, 20 * 8]
ldp x18, x19, [x0, 18 * 8]
ldp x16, x17, [x0, 16 * 8]
ldp x14, x15, [x0, 14 * 8]
ldp x12, x13, [x0, 12 * 8]
ldp x10, x11, [x0, 10 * 8]
ldp x8, x9, [x0, 8 * 8]
ldp x6, x7, [x0, 6 * 8]
ldp x4, x5, [x0, 4 * 8]
ldp x2, x3, [x0, 2 * 8]
ldp x0, x1, [x0]
eret",
ldp x28, x29, [x0, 28 * 8]
ldp x26, x27, [x0, 26 * 8]
ldp x24, x25, [x0, 24 * 8]
ldp x22, x23, [x0, 22 * 8]
ldp x20, x21, [x0, 20 * 8]
ldp x18, x19, [x0, 18 * 8]
ldp x16, x17, [x0, 16 * 8]
ldp x14, x15, [x0, 14 * 8]
ldp x12, x13, [x0, 12 * 8]
ldp x10, x11, [x0, 10 * 8]
ldp x8, x9, [x0, 8 * 8]
ldp x6, x7, [x0, 6 * 8]
ldp x4, x5, [x0, 4 * 8]
ldp x2, x3, [x0, 2 * 8]
ldp x0, x1, [x0]
eret",
in("x0") &self.0,
in("x1") kstack_top.as_usize() ,
options(noreturn),
Expand Down
1 change: 1 addition & 0 deletions modules/axns/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ pub unsafe fn current_namespace_base() -> *mut u8 {
macro_rules! def_resource {
( $( $(#[$attr:meta])* $vis:vis static $name:ident: $ty:ty = $default:expr; )+ ) => {
$(
$(#[$attr])*
#[allow(non_camel_case_types)]
$vis struct $name { __value: () }

Expand Down

0 comments on commit 2f5c368

Please sign in to comment.