aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Bucur <stefanb@zytor.com>2008-07-28 21:50:20 -0700
committerStefan Bucur <stefan@stefan-ubumac.(none)>2009-03-15 10:10:50 +0200
commit2783da3f00a39e174466c79e7d282f398f15984c (patch)
tree8cd8f30110a427b057c5d391e65d43ee2fb3fe99
parent7d735c335492a84ca4219a886754ba1cde2f415a (diff)
downloadsyslinux-elf-2783da3f00a39e174466c79e7d282f398f15984c.tar.gz
syslinux-elf-2783da3f00a39e174466c79e7d282f398f15984c.tar.xz
syslinux-elf-2783da3f00a39e174466c79e7d282f398f15984c.zip
Implemented module unloading functionality.
-rw-r--r--com32/elflink/elf_module.c7
-rw-r--r--com32/elflink/test_com32.c24
2 files changed, 29 insertions, 2 deletions
diff --git a/com32/elflink/elf_module.c b/com32/elflink/elf_module.c
index fedebf7f..64c7b977 100644
--- a/com32/elflink/elf_module.c
+++ b/com32/elflink/elf_module.c
@@ -842,8 +842,8 @@ int module_load(struct elf_module *module) {
// The file image is no longer needed
image_unload(module);
- DBG_PRINT("MODULE %s LOADED SUCCESSFULLY (&init@0x%08X, &exit@0x%08X)\n",
- module->name, module->init_func, module->exit_func);
+ DBG_PRINT("MODULE %s LOADED SUCCESSFULLY (init@0x%08X, exit@0x%08X)\n",
+ module->name, *(module->init_func), *(module->exit_func));
return 0;
@@ -917,6 +917,9 @@ int module_unload(struct elf_module *module) {
// Release the loaded segments or sections
elf_free(module->module_addr);
+
+ DBG_PRINT("%s MODULE %s UNLOADED\n", module->shallow ? "SHALLOW" : "",
+ module->name);
// Release the module structure
free(module);
diff --git a/com32/elflink/test_com32.c b/com32/elflink/test_com32.c
index b9f20bd2..8404864f 100644
--- a/com32/elflink/test_com32.c
+++ b/com32/elflink/test_com32.c
@@ -63,6 +63,24 @@ int modules_com32_load(char *name) {
return res;
}
+void modules_com32_unload(char *name) {
+ char full_name[MODULE_NAME_SIZE];
+
+ strcpy(full_name, ELF_DIRECTORY);
+ strcat(full_name, name);
+
+ struct elf_module *module = module_find(full_name);
+
+ if (module != NULL) {
+ if (*(module->exit_func) != NULL) {
+ (*(module->exit_func))();
+ }
+ module_unload(module);
+ } else {
+ printf("Cannot find module %s for unloading\n", full_name);
+ }
+}
+
void print_usage() {
printf("Usage: test_com32 module ...\n");
printf("Where:\n");
@@ -91,10 +109,16 @@ int main(int argc, char **argv) {
// Initializing the module subsystem
res = modules_com32_setup();
+ // Load the modules...
for (i = 0; i < argc; i++) {
modules_com32_load(argv[i]);
}
+ // ...then unload them
+ for (i = argc-1; i >= 0; i--) {
+ modules_com32_unload(argv[i]);
+ }
+
modules_com32_finalize();
return 0;