diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2013-01-17 16:52:20 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2013-01-17 16:52:20 -0800 |
commit | 14fe8af6c11e71619de9be1afd4556ebbc770db3 (patch) | |
tree | d8e01ae34a8d32e66c41f91d7edc0ff3e5249da7 /com32/lib/sys | |
parent | 5361540973da90c1dbde3b4c6c0dab46f997491e (diff) | |
download | syslinux-14fe8af6c11e71619de9be1afd4556ebbc770db3.tar.gz |
elf: remove long-since-obsolete shallow module machinery
Meant to handle symbols exported from the core, but we just
pregenerate the dynamic section instead.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'com32/lib/sys')
-rw-r--r-- | com32/lib/sys/module/exec.c | 24 | ||||
-rw-r--r-- | com32/lib/sys/module/shallow_module.c | 161 |
2 files changed, 0 insertions, 185 deletions
diff --git a/com32/lib/sys/module/exec.c b/com32/lib/sys/module/exec.c index ac9ca79a..2b3a4c09 100644 --- a/com32/lib/sys/module/exec.c +++ b/com32/lib/sys/module/exec.c @@ -18,32 +18,8 @@ #define DBG_PRINT(fmt, args...) dprintf("[EXEC] " fmt, ##args) -static struct elf_module *mod_root = NULL; struct elf_module *__syslinux_current = NULL; -int exec_init(void) -{ - int res; - - res = modules_init(); - if (res != 0) - return res; - - // Load the root module - mod_root = module_alloc(EXEC_ROOT_NAME); - - if (mod_root == NULL) - return -1; - - res = module_load_shallow(mod_root, 0); - if (res != 0) { - mod_root = NULL; - return res; - } - - return 0; -} - int get_module_type(struct elf_module *module) { if(module->main_func) return EXEC_MODULE; diff --git a/com32/lib/sys/module/shallow_module.c b/com32/lib/sys/module/shallow_module.c deleted file mode 100644 index 8a88e403..00000000 --- a/com32/lib/sys/module/shallow_module.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * shallow_module.c - * - * Created on: Aug 11, 2008 - * Author: Stefan Bucur <stefanb@zytor.com> - */ - - -#include <string.h> -#include <sys/module.h> - -#include "common.h" -#include "elfutils.h" - - -static int check_header_shallow(Elf32_Ehdr *elf_hdr) { - int res; - - res = check_header_common(elf_hdr); - - if (res != 0) - return res; - - if (elf_hdr->e_shoff == 0x00000000) { - DBG_PRINT("SHT missing\n"); - return -1; - } - - return 0; -} - -static int load_shallow_sections(struct elf_module *module, Elf32_Ehdr *elf_hdr) { - int i; - int res = 0; - char *sht = NULL; - char *buffer = NULL; - Elf32_Shdr *crt_sht; - Elf32_Off buff_offset; - - Elf32_Off min_offset = 0xFFFFFFFF; - Elf32_Off max_offset = 0x00000000; - Elf32_Word max_align = 0x1; - - Elf32_Off sym_offset = 0xFFFFFFFF; - Elf32_Off str_offset = 0xFFFFFFFF; - - - char *sh_strtable; - - // We buffer the data up to the SHT - buff_offset = module->u.l._cr_offset; - - buffer = malloc(elf_hdr->e_shoff - buff_offset); - // Get to the SHT - image_read(buffer, elf_hdr->e_shoff - buff_offset, module); - - // Load the SHT - sht = malloc(elf_hdr->e_shnum * elf_hdr->e_shentsize); - image_read(sht, elf_hdr->e_shnum * elf_hdr->e_shentsize, module); - - // Get the string table of the section names - crt_sht = (Elf32_Shdr*)(sht + elf_hdr->e_shstrndx * elf_hdr->e_shentsize); - sh_strtable = (char*)(buffer + (crt_sht->sh_offset - buff_offset)); - - for (i = 0; i < elf_hdr->e_shnum; i++) { - crt_sht = (Elf32_Shdr*)(sht + i*elf_hdr->e_shentsize); - - if (strcmp(".symtab", sh_strtable + crt_sht->sh_name) == 0) { - // We found the symbol table - min_offset = MIN(min_offset, crt_sht->sh_offset); - max_offset = MAX(max_offset, crt_sht->sh_offset + crt_sht->sh_size); - max_align = MAX(max_align, crt_sht->sh_addralign); - - sym_offset = crt_sht->sh_offset; - - module->syment_size = crt_sht->sh_entsize; - module->symtable_size = crt_sht->sh_size / crt_sht->sh_entsize; - } - if (strcmp(".strtab", sh_strtable + crt_sht->sh_name) == 0) { - // We found the string table - min_offset = MIN(min_offset, crt_sht->sh_offset); - max_offset = MAX(max_offset, crt_sht->sh_offset + crt_sht->sh_size); - max_align = MAX(max_align, crt_sht->sh_addralign); - - str_offset = crt_sht->sh_offset; - - module->strtable_size = crt_sht->sh_size; - } - } - - if (elf_malloc(&module->module_addr, max_align, - max_offset - min_offset) != 0) { - DBG_PRINT("Could not allocate sections\n"); - goto out; - } - - // Copy the data - image_seek(min_offset, module); - image_read(module->module_addr, max_offset - min_offset, module); - - // Setup module information - module->module_size = max_offset - min_offset; - module->str_table = (char *)module->module_addr + (str_offset - min_offset); - module->sym_table = (char *)module->module_addr + (sym_offset - min_offset); - -out: - // Release the SHT - if (sht != NULL) - free(sht); - - // Release the buffer - if (buffer != NULL) - free(buffer); - - return res; -} - - -int module_load_shallow(struct elf_module *module, Elf32_Addr base_addr) { - int res; - Elf32_Ehdr elf_hdr; - - // Do not allow duplicate modules - if (module_find(module->name) != NULL) { - DBG_PRINT("Module already loaded.\n"); - return -1; - } - - res = image_load(module); - - if (res < 0) - return res; - - module->shallow = 1; - - CHECKED(res, image_read(&elf_hdr, sizeof(Elf32_Ehdr), module), error); - - // Checking the header signature and members - CHECKED(res, check_header_shallow(&elf_hdr), error); - - CHECKED(res, load_shallow_sections(module, &elf_hdr), error); - module->base_addr = base_addr; - - // Check the symbols for duplicates / missing definitions - CHECKED(res, check_symbols(module), error); - - // Add the module at the beginning of the module list - list_add(&module->list, &modules_head); - - // The file image is no longer needed - image_unload(module); - - DBG_PRINT("SHALLOW MODULE %s LOADED SUCCESSFULLY\n", module->name); - - return 0; - -error: - image_unload(module); - - return res; -} |