mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-30 22:18:21 +00:00
fix elf stack issues and interrupt gsbase stuff
This commit is contained in:
+14
-5
@@ -20,7 +20,15 @@ section .text
|
||||
push rbx
|
||||
push rax
|
||||
|
||||
|
||||
|
||||
mov rax, ds
|
||||
|
||||
cmp rax,0x43
|
||||
je .noswapgs
|
||||
swapgs
|
||||
.noswapgs:
|
||||
|
||||
push rax
|
||||
mov rax, es
|
||||
push rax
|
||||
@@ -28,12 +36,13 @@ section .text
|
||||
push rax
|
||||
mov rax, gs
|
||||
push rax
|
||||
|
||||
; now use kernel segments for data
|
||||
|
||||
cmp rax,0x43
|
||||
jmp .noswapgs
|
||||
swapgs
|
||||
.noswapgs:
|
||||
|
||||
mov rax, 0x30
|
||||
mov ds, rax
|
||||
mov es, rax
|
||||
mov ss, rax
|
||||
mov rdi,cr2
|
||||
push rdi
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ __attribute((noreturn)) void _panic(char* reason, arch_regs *reg){
|
||||
|
||||
printf("Panic location: %p\n", reg->rip);
|
||||
|
||||
if(reg->rbp != 0){
|
||||
if(reg->rbp != 0 && reg->cs == 0x28){
|
||||
printf("Stack trace:\n");
|
||||
tracestack((uint64_t**)reg->rbp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user