aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/core/kmain.c
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2016-07-13 23:11:55 +0200
committerAlex Auvolat <alex@adnab.me>2016-07-13 23:11:55 +0200
commitd09f8a08bdd9477bd463a2de03397ff56b5ce75d (patch)
tree4818750ff1fccd02f24e6f2089937190d2e6724b /src/kernel/core/kmain.c
parent8a89ad4b01bafcdb64349e81fb4883a6c5f45187 (diff)
downloadkogata-d09f8a08bdd9477bd463a2de03397ff56b5ce75d.tar.gz
kogata-d09f8a08bdd9477bd463a2de03397ff56b5ce75d.zip
Add delta wrt. function in stack dump
Diffstat (limited to 'src/kernel/core/kmain.c')
-rw-r--r--src/kernel/core/kmain.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/kernel/core/kmain.c b/src/kernel/core/kmain.c
index 99ad0d7..38336a9 100644
--- a/src/kernel/core/kmain.c
+++ b/src/kernel/core/kmain.c
@@ -125,6 +125,20 @@ void kmain(multiboot_info_t *mbd, int32_t mb_magic) {
setup_syscall_table();
dbg_printf("System calls setup ok.\n");
+ // If we have a kernel map, load it now
+ for (unsigned i = 0; i < mbd->mods_count; i++) {
+ char* modname = (char*)mods[i].string;
+ size_t len = mods[i].mod_end - mods[i].mod_start;
+
+ if (strlen(modname) > 4 && strcmp(modname + strlen(modname) - 4, ".map") == 0) {
+ // Copy data to somewhere safe, as it will be modified
+ void* dup_data = malloc(len + 1);
+ memcpy(dup_data, (void*)mods[i].mod_start, len);
+
+ load_kernel_symbol_map((char*)dup_data, len);
+ }
+ }
+
// enter multi-threading mode
// interrupts are enabled at this moment, so all
// code run from now on should be preemtible (ie thread-safe)
@@ -249,12 +263,6 @@ fs_t *setup_iofs(multiboot_info_t *mbd) {
ASSERT(nullfs_add_ram_file(iofs, name,
(char*)mods[i].mod_start,
len, FM_READ | FM_MMAP));
-
- if (strlen(modname) > 4 && strcmp(modname + strlen(modname) - 4, ".map") == 0) {
- // remark: load_kernel_symbol_map modifies the data region,
- // which is not a problem because nullfs_add_ram_file copied the thing already
- load_kernel_symbol_map((char*)mods[i].mod_start, len);
- }
}
return iofs;