mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:48:11 +00:00
Kernel: Have modules export their name in a "module_name" string
This will show up in /proc/modules, and is also the name you can pass to the module_unload() syscall for unloading the module.
This commit is contained in:
parent
86c61218a7
commit
ef32c71683
2 changed files with 6 additions and 1 deletions
|
@ -3407,7 +3407,6 @@ int Process::sys$module_load(const char* path, size_t path_length)
|
||||||
HashMap<String, u8*> section_storage_by_name;
|
HashMap<String, u8*> section_storage_by_name;
|
||||||
|
|
||||||
auto module = make<Module>();
|
auto module = make<Module>();
|
||||||
module->name = "FIXME";
|
|
||||||
|
|
||||||
elf_image->for_each_section_of_type(SHT_PROGBITS, [&](const ELFImage::Section& section) {
|
elf_image->for_each_section_of_type(SHT_PROGBITS, [&](const ELFImage::Section& section) {
|
||||||
auto section_storage = KBuffer::copy(section.raw_data(), section.size());
|
auto section_storage = KBuffer::copy(section.raw_data(), section.size());
|
||||||
|
@ -3463,6 +3462,10 @@ int Process::sys$module_load(const char* path, size_t path_length)
|
||||||
module->module_init = (ModuleInitPtr)(text_base + symbol.value());
|
module->module_init = (ModuleInitPtr)(text_base + symbol.value());
|
||||||
} else if (!strcmp(symbol.name(), "module_fini")) {
|
} else if (!strcmp(symbol.name(), "module_fini")) {
|
||||||
module->module_fini = (ModuleFiniPtr)(text_base + symbol.value());
|
module->module_fini = (ModuleFiniPtr)(text_base + symbol.value());
|
||||||
|
} else if (!strcmp(symbol.name(), "module_name")) {
|
||||||
|
const u8* storage = section_storage_by_name.get(symbol.section().name()).value_or(nullptr);
|
||||||
|
if (storage)
|
||||||
|
module->name = String((const char*)(storage + symbol.value()));
|
||||||
}
|
}
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include <Kernel/kstdio.h>
|
#include <Kernel/kstdio.h>
|
||||||
#include <Kernel/Process.h>
|
#include <Kernel/Process.h>
|
||||||
|
|
||||||
|
extern "C" const char module_name[] = "TestModule";
|
||||||
|
|
||||||
extern "C" void module_init()
|
extern "C" void module_init()
|
||||||
{
|
{
|
||||||
kprintf("TestModule has booted!\n");
|
kprintf("TestModule has booted!\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue