diff --git a/base/usr/include/kernel/module.h b/base/usr/include/kernel/module.h index 5ecaf9dd..42dfe3ec 100644 --- a/base/usr/include/kernel/module.h +++ b/base/usr/include/kernel/module.h @@ -11,6 +11,8 @@ struct Module { struct LoadedModule { struct Module * metadata; uintptr_t baseAddress; + size_t fileSize; + size_t loadedSize; }; hashmap_t * modules_get_list(void); diff --git a/kernel/misc/elf64.c b/kernel/misc/elf64.c index 364946fd..551df361 100644 --- a/kernel/misc/elf64.c +++ b/kernel/misc/elf64.c @@ -162,6 +162,10 @@ int elf_module(const char * path) { struct LoadedModule * loadedData = malloc(sizeof(struct LoadedModule)); loadedData->metadata = moduleData; loadedData->baseAddress = (uintptr_t)module_load_address; + loadedData->fileSize = file->length; + loadedData->loadedSize = (uintptr_t)mmu_map_module(0) - (uintptr_t)module_load_address; + + close_fs(file); hashmap_set(_modules_table, moduleData->name, loadedData); diff --git a/kernel/vfs/procfs.c b/kernel/vfs/procfs.c index 0e4f2308..49472feb 100644 --- a/kernel/vfs/procfs.c +++ b/kernel/vfs/procfs.c @@ -482,8 +482,10 @@ static ssize_t modules_func(fs_node_t *node, off_t offset, size_t size, uint8_t foreach(_key, hash_keys) { char * key = (char *)_key->value; struct LoadedModule * mod_info = hashmap_get(modules_get_list(), key); - soffset += snprintf(&buf[soffset], 100, "%#zx %s\n", + soffset += snprintf(&buf[soffset], 100, "%#zx %zu %zu %s\n", mod_info->baseAddress, + mod_info->fileSize, + mod_info->loadedSize, key); } free(hash_keys);