fix elf stack issues and interrupt gsbase stuff

This commit is contained in:
Matheus
2022-08-16 19:12:16 -03:00
parent 432e85b837
commit 7a540ca1e1
9 changed files with 37 additions and 13 deletions
+6 -1
View File
@@ -28,7 +28,12 @@ $(KERNEL): srcdir $(KERNELSRCDEPS) kernel.ld
mkdir -p $(ISO)
$(CC) $(LDFLAGS) -o $@ $(call rwildcard,bin,*.o)
$(INITRD): initrd
.phony: rebuildinitrd
rebuildinitrd:
rm $(INITRD)
cd initrd;tar -cf $(INITRD) *
$(INITRD): $(shell find initrd)
cd initrd;tar -cf $(INITRD) *
sysdisk.iso: $(ISO) $(INITRD)
BIN
View File
Binary file not shown.
+14 -5
View File
@@ -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
+1 -1
View File
@@ -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);
}
+1 -1
View File
@@ -68,7 +68,7 @@ static int tmpfs_read(int *error, vnode_t* node, void* buff, size_t count, size_
}
static int tmpfs_unmount(fs_t* fs) UNIMPLEMENTED
static int tmpfs_open(dirnode_t* parent, char* name) UNIMPLEMENTED
static int tmpfs_open(dirnode_t* parent, char* name){ return ENOENT;} // tmpfs open should never be called if a file exists
static int tmpfs_close(vnode_t* node) UNIMPLEMENTED
static int tmpfs_mkdir(dirnode_t* parent, char* name, mode_t mode){
+2 -1
View File
@@ -8,6 +8,7 @@
#define ENOSYS 5
#define EEXIST 6
#define ENOENT 7
#define EACCES 8
#define EAGAIN 9
#endif
+1 -1
View File
@@ -24,7 +24,7 @@ typedef struct {
gid_t st_gid;
dev_t st_rdev;
off_t st_size;
blksize_t st_blksize;
blkcnt_t st_blocks;
} stat;
+1 -1
View File
@@ -14,7 +14,7 @@ typedef id_t pid_t;
typedef id_t uid_t;
typedef id_t tid_t;
typedef size_t ino_t;
typedef size_t mode_t;
typedef int mode_t;
typedef int dev_t;
typedef ssize_t off_t;
typedef size_t nlink_t;
+11 -2
View File
@@ -100,12 +100,17 @@ static void* stacksetup(char* interp, char** argv, char** env){
char** argstart = (void*)envstart - (argc + 1)*sizeof(char*);
if(interp)
--argstart;
size_t* argcptr = (void*)argstart - sizeof(size_t);
char*** envpptr = (void*)argstart - sizeof(char**);
char*** argvptr = (void*)envpptr - sizeof(char**);
size_t* argcptr = (void*)argvptr - sizeof(size_t);
// XXX auxv
// copy the data
*envpptr = envstart;
*argvptr = argstart;
if(interp){
strcpy(argdatastart, interp);
*argstart++ = argdatastart;
@@ -126,9 +131,13 @@ static void* stacksetup(char* interp, char** argv, char** env){
envdatastart += strlen(env[i]) + 1;
}
*envstart = NULL;
if(interp)
argc++;
*argcptr = argc;
return argcptr;