From b76ebd328db6a4fc424c5bef50053151b99ace4f Mon Sep 17 00:00:00 2001 From: jdh8d <jdh8d@git.zephyr-software.com> Date: Tue, 11 Oct 2016 18:38:09 +0000 Subject: [PATCH] fixed bug with vdso Former-commit-id: 5fbb13db0c012fbe4bd63cbded482822263523c9 --- tools/selective_cfi/zest_cfi_runtime/dispatch.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/selective_cfi/zest_cfi_runtime/dispatch.c b/tools/selective_cfi/zest_cfi_runtime/dispatch.c index 69c8adb56..91de07bac 100644 --- a/tools/selective_cfi/zest_cfi_runtime/dispatch.c +++ b/tools/selective_cfi/zest_cfi_runtime/dispatch.c @@ -100,14 +100,13 @@ static ElfW(Addr) find_symtab_entry(const char* tofind, const ElfW(Sym) *symtab, // we've probably exceeded the symbol table's size. for(i=1; 1 ; i++) { - // note: st_name is ElfW(Word) which maps to uint32_t or uint64_t depending on architecture. // thus, no lower bound check is necessary bcause it has to be >=0. if(symtab[i].st_name>=strtabsz) return 0; const char* symstring=strtab+symtab[i].st_name; -#if 0 +#if DEBUG write_str("Checking symbol: "); write_str(symstring); write_str("\n"); @@ -141,6 +140,10 @@ int dl_iterate_phdr_callback (struct dl_phdr_info *info, size_t size, void *data } const ElfW(Sym) *symtab=(ElfW(Sym)*)find_dynamic_entry(info,DT_SYMTAB, dynamic_start); + // apparently some modules don't have a reloc for their symtab pointer properly entry. + if(!ptload_for_target_exists(info, phdr_start, phnum, (ElfW(Addr))symtab)) + symtab=(ElfW(Addr))symtab+(ElfW(Addr))info->dlpi_addr; + if(!symtab) { write_str("Couldn't find symtab start. "); @@ -148,6 +151,9 @@ int dl_iterate_phdr_callback (struct dl_phdr_info *info, size_t size, void *data } const char* strtab=(const char*)find_dynamic_entry(info,DT_STRTAB, dynamic_start); + // apparently some modules don't have a reloc for their symtab pointer properly entry. + if(!ptload_for_target_exists(info, phdr_start, phnum, (ElfW(Addr))strtab)) + strtab=(ElfW(Addr))strtab+(ElfW(Addr))info->dlpi_addr; if(!strtab) { write_str("Couldn't find strtab start. "); -- GitLab