Add error conditions to linker
This commit is contained in:
parent
fd41251869
commit
75f7d35ee2
@ -401,8 +401,13 @@ static void object_find_copy_relocations(elf_t * object) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char * last_error = NULL;
|
||||||
|
|
||||||
static void * object_find_symbol(elf_t * object, const char * symbol_name) {
|
static void * object_find_symbol(elf_t * object, const char * symbol_name) {
|
||||||
if (!object->dyn_symbol_table) return NULL;
|
if (!object->dyn_symbol_table) {
|
||||||
|
last_error = "lib does not have a symbol table";
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Elf32_Sym * table = object->dyn_symbol_table;
|
Elf32_Sym * table = object->dyn_symbol_table;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
@ -414,6 +419,7 @@ static void * object_find_symbol(elf_t * object, const char * symbol_name) {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
last_error = "symbol not found in library";
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,6 +429,11 @@ static void * dlopen_ld(const char * filename, int flags) {
|
|||||||
|
|
||||||
elf_t * lib = open_object(filename);
|
elf_t * lib = open_object(filename);
|
||||||
|
|
||||||
|
if (!lib) {
|
||||||
|
last_error = "could not open library (not found, or other failure)";
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
size_t lib_size = object_calculate_size(lib);
|
size_t lib_size = object_calculate_size(lib);
|
||||||
|
|
||||||
if (lib_size < 4096) {
|
if (lib_size < 4096) {
|
||||||
@ -460,7 +471,9 @@ static int dlclose_ld(elf_t * lib) {
|
|||||||
|
|
||||||
static char * dlerror_ld(void) {
|
static char * dlerror_ld(void) {
|
||||||
/* TODO actually do this */
|
/* TODO actually do this */
|
||||||
return NULL;
|
char * this_error = last_error;
|
||||||
|
last_error = NULL;
|
||||||
|
return this_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user