aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--com32/include/sys/module.h11
-rw-r--r--com32/lib/sys/module/common.c8
-rw-r--r--com32/lib/sys/module/common.h5
-rw-r--r--com32/lib/sys/module/elf_module.c2
-rw-r--r--com32/lib/sys/module/shallow_module.c2
5 files changed, 17 insertions, 11 deletions
diff --git a/com32/include/sys/module.h b/com32/include/sys/module.h
index 66008d2f..2c9ce9d4 100644
--- a/com32/include/sys/module.h
+++ b/com32/include/sys/module.h
@@ -160,6 +160,17 @@ struct module_dep {
#define MODULE_ELF_MAIN_PTR "__module_main_ptr" // Entry pointer symbol name
/**
+ * modules_head - A global linked list containing all the loaded modules.
+ */
+extern struct list_head modules_head;
+
+
+/**
+ * for_each_module -
+ */
+#define for_each_module(m) list_for_each_entry(m, &modules_head, list)
+
+/**
* modules_init - initialize the module subsystem.
*
* This function must be called before any module operation is to be performed.
diff --git a/com32/lib/sys/module/common.c b/com32/lib/sys/module/common.c
index 8a685130..9934a7a4 100644
--- a/com32/lib/sys/module/common.c
+++ b/com32/lib/sys/module/common.c
@@ -19,7 +19,7 @@
/**
* The one and only list of loaded modules
*/
-LIST_HEAD(modules);
+LIST_HEAD(modules_head);
// User-space debugging routines
#ifdef ELF_DEBUG
@@ -166,7 +166,7 @@ struct module_dep *module_dep_alloc(struct elf_module *module) {
struct elf_module *module_find(const char *name) {
struct elf_module *cr_module;
- list_for_each_entry(cr_module, &modules, list) {
+ for_each_module(cr_module) {
if (strcmp(cr_module->name, name) == 0)
return cr_module;
}
@@ -282,7 +282,7 @@ int check_symbols(struct elf_module *module) {
strong_count = 0;
weak_count = 0;
- list_for_each_entry(crt_module, &modules, list) {
+ for_each_module(crt_module) {
ref_sym = module_find_symbol(crt_name, crt_module);
// If we found a definition for our symbol...
@@ -470,7 +470,7 @@ Elf32_Sym *global_find_symbol(const char *name, struct elf_module **module) {
Elf32_Sym *crt_sym = NULL;
Elf32_Sym *result = NULL;
- list_for_each_entry(crt_module, &modules, list) {
+ for_each_module(crt_module) {
crt_sym = module_find_symbol(name, crt_module);
if (crt_sym != NULL && crt_sym->st_shndx != SHN_UNDEF) {
diff --git a/com32/lib/sys/module/common.h b/com32/lib/sys/module/common.h
index d46dcc38..8aafe513 100644
--- a/com32/lib/sys/module/common.h
+++ b/com32/lib/sys/module/common.h
@@ -34,11 +34,6 @@
#define DBG_PRINT(fmt, args...) // Expand to nothing
#endif
-/**
- * modules - A global linked list containing all the loaded modules.
- */
-extern struct list_head modules;
-
// User-space debugging routines
#ifdef ELF_DEBUG
diff --git a/com32/lib/sys/module/elf_module.c b/com32/lib/sys/module/elf_module.c
index 58f94d04..2952e617 100644
--- a/com32/lib/sys/module/elf_module.c
+++ b/com32/lib/sys/module/elf_module.c
@@ -449,7 +449,7 @@ int module_load(struct elf_module *module) {
CHECKED(res, extract_operations(module), error);
// Add the module at the beginning of the module list
- list_add(&module->list, &modules);
+ list_add(&module->list, &modules_head);
// Perform the relocations
resolve_symbols(module);
diff --git a/com32/lib/sys/module/shallow_module.c b/com32/lib/sys/module/shallow_module.c
index ed196cd9..64e2679b 100644
--- a/com32/lib/sys/module/shallow_module.c
+++ b/com32/lib/sys/module/shallow_module.c
@@ -142,7 +142,7 @@ int module_load_shallow(struct elf_module *module) {
CHECKED(res, check_symbols(module), error);
// Add the module at the beginning of the module list
- list_add(&module->list, &modules);
+ list_add(&module->list, &modules_head);
// The file image is no longer needed
image_unload(module);