aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2020-06-17 18:06:59 +0200
committerMarvin Borner2020-06-17 18:06:59 +0200
commit49dfa1f4021026bf7c4d77817959c8aa24067016 (patch)
tree840132693191cfeeb2085062e2caa67f65ae6993
parentcca3879a03c2a983310e25bca6a64a979aa9c3ef (diff)
Some things
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/kernel/fs/elf.c18
-rw-r--r--src/kernel/tasks/process.c4
3 files changed, 15 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2cf6697..3c475a0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -68,6 +68,6 @@ foreach(loop_file ${user_sources})
get_filename_component(testname ${loop_file} NAME_WE)
add_executable(${testname} ${loop_file})
target_include_directories(${testname} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/userspace/libc/" "${CMAKE_CURRENT_SOURCE_DIR}/src/userspace/libgui/")
- target_link_libraries(${testname} userspace_libc userspace_libgui "-T ${CMAKE_CURRENT_SOURCE_DIR}/src/userspace/linker.ld")
+ target_link_libraries(${testname} userspace_libc userspace_libgui)
set_target_properties(${testname} PROPERTIES OUTPUT_NAME "${CMAKE_CURRENT_SOURCE_DIR}/build/user/${testname}")
endforeach(loop_file ${user_sources})
diff --git a/src/kernel/fs/elf.c b/src/kernel/fs/elf.c
index ec4bcc0..6585bb4 100644
--- a/src/kernel/fs/elf.c
+++ b/src/kernel/fs/elf.c
@@ -49,9 +49,10 @@ struct process *elf_load(char *path)
u32 image_high = 0;
// Parse ELF
+ u32 i = 0;
u32 j = 0;
- for (u32 i = 0; i < header->shentsize * header->shnum; i += header->shentsize) {
- struct elf_section_header *sh = (void *)header + (header->shoff + i);
+ while (i < header->shentsize * header->shnum) {
+ struct elf_section_header *sh = (void *)((u32)header + (header->shoff + i));
if (sh->addr != 0) {
log("%x", sh->addr);
/* for (u32 j = 0; j < sh->size; j += PAGE_SIZE) { */
@@ -64,10 +65,12 @@ struct process *elf_load(char *path)
j += 0x1000;
}
- if (sh->type == 8) // Is .bss
- memset(sh->addr, 0, sh->size);
+ if (sh->type == 8)
+ // section is .bss
+ memset((void *)sh->addr, 0, sh->size);
else
- memcpy(sh->addr, header + sh->offset, sh->size);
+ memcpy((void *)sh->addr, (void *)((u32)header + sh->offset),
+ sh->size);
if (sh->addr < image_low)
image_low = sh->addr;
@@ -75,6 +78,7 @@ struct process *elf_load(char *path)
if (sh->addr + sh->size > image_high)
image_high = sh->addr + sh->size;
}
+ i += header->shentsize;
}
// Stack
@@ -90,5 +94,7 @@ struct process *elf_load(char *path)
proc->regs.esp = proc->regs.useresp;
proc->regs.eip = header->entry;
+ debug("Loaded file");
+
return proc;
-} \ No newline at end of file
+}
diff --git a/src/kernel/tasks/process.c b/src/kernel/tasks/process.c
index ee657c4..8fd621d 100644
--- a/src/kernel/tasks/process.c
+++ b/src/kernel/tasks/process.c
@@ -186,7 +186,7 @@ struct process *process_make_new()
proc->regs.ds = 0x23;
proc->regs.ss = 0x23;
proc->regs.eip = no_entry;
- proc->cr3 = paging_make_dir();
+ proc->cr3 = (u32)paging_make_dir();
proc->pid = pid++;
return proc;
}
@@ -229,4 +229,4 @@ u32 uspawn(char *path)
log("Spawned");
process_force_switch();
return 0;
-} \ No newline at end of file
+}