modules: track loaded sizes so we can free modules later
This commit is contained in:
parent
ae7cdb00c2
commit
d406a6948f
@ -11,6 +11,8 @@ struct Module {
|
|||||||
struct LoadedModule {
|
struct LoadedModule {
|
||||||
struct Module * metadata;
|
struct Module * metadata;
|
||||||
uintptr_t baseAddress;
|
uintptr_t baseAddress;
|
||||||
|
size_t fileSize;
|
||||||
|
size_t loadedSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
hashmap_t * modules_get_list(void);
|
hashmap_t * modules_get_list(void);
|
||||||
|
@ -162,6 +162,10 @@ int elf_module(const char * path) {
|
|||||||
struct LoadedModule * loadedData = malloc(sizeof(struct LoadedModule));
|
struct LoadedModule * loadedData = malloc(sizeof(struct LoadedModule));
|
||||||
loadedData->metadata = moduleData;
|
loadedData->metadata = moduleData;
|
||||||
loadedData->baseAddress = (uintptr_t)module_load_address;
|
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);
|
hashmap_set(_modules_table, moduleData->name, loadedData);
|
||||||
|
|
||||||
|
@ -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) {
|
foreach(_key, hash_keys) {
|
||||||
char * key = (char *)_key->value;
|
char * key = (char *)_key->value;
|
||||||
struct LoadedModule * mod_info = hashmap_get(modules_get_list(), key);
|
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->baseAddress,
|
||||||
|
mod_info->fileSize,
|
||||||
|
mod_info->loadedSize,
|
||||||
key);
|
key);
|
||||||
}
|
}
|
||||||
free(hash_keys);
|
free(hash_keys);
|
||||||
|
Loading…
Reference in New Issue
Block a user