Unresolved symbol handling
This commit is contained in:
parent
ed03c517ad
commit
e9e892bae5
@ -623,6 +623,11 @@ static int shell_mod(fs_node_t * tty, int argc, char * argv[]) {
|
||||
|
||||
fs_printf(tty, "Okay, going to load a module!\n");
|
||||
module_defs * mod_info = module_load(argv[1]);
|
||||
if (!mod_info) {
|
||||
fs_printf(tty, "Something went wrong, failed to load module: %s\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fs_printf(tty, "Loaded %s!\n", mod_info->name);
|
||||
|
||||
return 0;
|
||||
|
@ -102,7 +102,9 @@ void * module_load(char * filename) {
|
||||
char * name = (char *)((uintptr_t)symstrtab + table->st_name);
|
||||
if (table->st_shndx == 0) {
|
||||
if (!hashmap_get(symboltable, name)) {
|
||||
debug_print(WARNING, "Unresolved symbol in module: %s", name);
|
||||
debug_print(ERROR, "Unresolved symbol in module: %s", name);
|
||||
debug_print(ERROR, "Did you forget to load a dependency?");
|
||||
goto mod_load_error;
|
||||
}
|
||||
} else {
|
||||
Elf32_Shdr * s = NULL;
|
||||
|
@ -8,13 +8,12 @@ extern char * special_thing;
|
||||
char test_module_string[] = "I am a char[] in the module.";
|
||||
char * test_module_string_ptr = "I am a char * in the module.";
|
||||
|
||||
static int a_function(void) {
|
||||
debug_print(WARNING, ("I am a static function in the module."));
|
||||
int a_function(void) {
|
||||
debug_print(WARNING, ("I am an exported function in the module."));
|
||||
return 42;
|
||||
}
|
||||
|
||||
int b_function(void) {
|
||||
debug_print(NOTICE, "I am a global function in a module!");
|
||||
static int hello(void) {
|
||||
debug_print(NOTICE, special_thing);
|
||||
a_function();
|
||||
debug_print(NOTICE, test_module_string);
|
||||
@ -33,10 +32,10 @@ int b_function(void) {
|
||||
return 25;
|
||||
}
|
||||
|
||||
int goodbye(void) {
|
||||
static int goodbye(void) {
|
||||
debug_print(NOTICE, "Goodbye!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
MODULE_DEF(test, b_function, goodbye);
|
||||
MODULE_DEF(test, hello, goodbye);
|
||||
|
||||
|
20
modules/testb.c
Normal file
20
modules/testb.c
Normal file
@ -0,0 +1,20 @@
|
||||
#include <system.h>
|
||||
#include <hashmap.h>
|
||||
#include <module.h>
|
||||
#include <logging.h>
|
||||
|
||||
extern int a_function(void);
|
||||
|
||||
static int hello(void) {
|
||||
debug_print(NOTICE, "Calling a_function from other module.");
|
||||
a_function();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int goodbye(void) {
|
||||
debug_print(NOTICE, "Goodbye!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
MODULE_DEF(testb, hello, goodbye);
|
||||
|
Loading…
Reference in New Issue
Block a user