Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions modules/axhal/linker.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ SECTIONS

.text : ALIGN(4K) {
_stext = .;
; for unwind
__executable_start = .;
*(.text.boot)
*(.text .text.*)
. = ALIGN(4K);
_etext = .;
; for unwind
__etext = .;
}

_srodata = .;
Expand All @@ -23,6 +27,20 @@ SECTIONS
*(.sdata2 .sdata2.*)
}

.gcc_except_table : ALIGN(4K){
*(.gcc_except_table .gcc_except_table.*)
}

.eh_frame_hdr : ALIGN(4K){
PROVIDE(__GNU_EH_FRAME_HDR = .);
KEEP(*(.eh_frame_hdr .eh_frame_hdr.*))
}

.eh_frame : ALIGN(4K){
PROVIDE(__eh_frame = .);
KEEP(*(.eh_frame .eh_frame.*))
}

.init_array : ALIGN(0x10) {
__init_array_start = .;
*(.init_array .init_array.*)
Expand Down
1 change: 0 additions & 1 deletion modules/axruntime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ rtc = ["dep:chrono"]

[dependencies]
axalloc = { workspace = true, optional = true }
axbacktrace = { workspace = true }
axconfig = { workspace = true }
axdisplay = { workspace = true, optional = true }
axinput = { workspace = true, optional = true }
Expand Down
17 changes: 15 additions & 2 deletions modules/axruntime/src/lang_items.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
use core::panic::PanicInfo;

#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
fn panic(info: &core::panic::PanicInfo) -> ! {
unsafe extern "Rust" {
pub fn __arceos_panic_handler(info: &core::panic::PanicInfo) -> !;
}
unsafe {
__arceos_panic_handler(info);
}
}

/// The default panic handler for ArceOS based kernels.
///
/// The user can override it by defining their own panic handler with the macro
/// `#[axmacros::panic_handler]`.
#[linkage = "weak"]
fn __arceos_panic_handler(info: &PanicInfo) -> ! {
ax_println!("{}", info);
ax_println!("{}", axbacktrace::Backtrace::capture());
axhal::power::system_off()
}
26 changes: 1 addition & 25 deletions modules/axruntime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#![cfg_attr(not(test), no_std)]
#![feature(doc_auto_cfg)]

#![feature(linkage)]
#[macro_use]
extern crate axlog;

Expand Down Expand Up @@ -122,15 +122,13 @@ pub fn rust_main(cpu_id: usize, arg: usize) -> ! {
target = {}
build_mode = {}
log_level = {}
backtrace = {}
smp = {}
"},
axconfig::ARCH,
axconfig::PLATFORM,
option_env!("AX_TARGET").unwrap_or(""),
option_env!("AX_MODE").unwrap_or(""),
option_env!("AX_LOG").unwrap_or(""),
axbacktrace::is_enabled(),
axconfig::plat::CPU_NUM,
);
#[cfg(feature = "rtc")]
Expand Down Expand Up @@ -159,28 +157,6 @@ pub fn rust_main(cpu_id: usize, arg: usize) -> ! {
#[cfg(feature = "alloc")]
init_allocator();

{
use core::ops::Range;

unsafe extern "C" {
safe static _stext: [u8; 0];
safe static _etext: [u8; 0];
safe static _edata: [u8; 0];
}

let ip_range = Range {
start: _stext.as_ptr() as usize,
end: _etext.as_ptr() as usize,
};

let fp_range = Range {
start: _edata.as_ptr() as usize,
end: usize::MAX,
};

axbacktrace::init(ip_range, fp_range);
}

#[cfg(feature = "paging")]
axmm::init_memory_management();

Expand Down
7 changes: 2 additions & 5 deletions scripts/make/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ else ifneq ($(filter $(or $(MAKECMDGOALS), $(.DEFAULT_GOAL)), all build run just
$(if $(V), $(info CFLAGS: "$(CFLAGS)") $(info LDFLAGS: "$(LDFLAGS)"))
else ifeq ($(APP_TYPE), rust)
RUSTFLAGS += $(RUSTFLAGS_LINK_ARGS)
ifeq ($(BACKTRACE), y)
RUSTFLAGS += -C force-frame-pointers -C debuginfo=2 -C strip=none
ifneq ($(ARCH), loongarch64)
RUSTFLAGS += -Cforce-unwind-tables=yes -Cpanic=unwind -Clink-arg=--eh-frame-hdr
endif
ifeq ($(MYPLAT), axplat-loongarch64-2k1000la)
RUSTFLAGS += -C target-feature=-ual
Expand All @@ -56,9 +56,6 @@ ifeq ($(APP_TYPE), rust)
else ifeq ($(APP_TYPE), c)
$(call cargo_build,ulib/axlibc,$(AX_FEAT) $(LIB_FEAT))
endif
ifeq ($(BACKTRACE), y)
$(call run_cmd,./scripts/make/dwarf.sh,$(OUT_ELF) $(OBJCOPY))
endif

$(OUT_DIR):
$(call run_cmd,mkdir,-p $@)
Expand Down
Loading