From 325804055e99dbf40af5e6fa546320b821d9d821 Mon Sep 17 00:00:00 2001 From: Pratyush Anand Date: Wed, 17 May 2017 14:51:42 +0900 Subject: kexec: generalize and rename get_kernel_stext_sym() get_kernel_stext_sym() has been defined for both arm and i386. Other architecture might need some other kernel symbol address. Therefore rewrite this function as generic function to get any kernel symbol address. More over, kallsyms is not arch specific representation, therefore have common function for all arches. Signed-off-by: Pratyush Anand [created symbols.c] Signed-off-by: AKASHI Takahiro Tested-by: David Woodhouse Tested-by: Pratyush Anand Signed-off-by: Simon Horman --- kexec/arch/arm/crashdump-arm.c | 40 +--------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) (limited to 'kexec/arch/arm/crashdump-arm.c') diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c index ac76e0a..daa4788 100644 --- a/kexec/arch/arm/crashdump-arm.c +++ b/kexec/arch/arm/crashdump-arm.c @@ -73,48 +73,10 @@ static struct crash_elf_info elf_info = { extern unsigned long long user_page_offset; -/* Retrieve kernel _stext symbol virtual address from /proc/kallsyms */ -static unsigned long long get_kernel_stext_sym(void) -{ - const char *kallsyms = "/proc/kallsyms"; - const char *stext = "_stext"; - char sym[128]; - char line[128]; - FILE *fp; - unsigned long long vaddr = 0; - char type; - - fp = fopen(kallsyms, "r"); - if (!fp) { - fprintf(stderr, "Cannot open %s\n", kallsyms); - return 0; - } - - while(fgets(line, sizeof(line), fp) != NULL) { - unsigned long long addr; - - if (sscanf(line, "%Lx %c %s", &addr, &type, sym) != 3) - continue; - - if (strcmp(sym, stext) == 0) { - dbgprintf("kernel symbol %s vaddr = %#llx\n", stext, addr); - vaddr = addr; - break; - } - } - - fclose(fp); - - if (vaddr == 0) - fprintf(stderr, "Cannot get kernel %s symbol address\n", stext); - - return vaddr; -} - static int get_kernel_page_offset(struct kexec_info *info, struct crash_elf_info *elf_info) { - unsigned long long stext_sym_addr = get_kernel_stext_sym(); + unsigned long long stext_sym_addr = get_kernel_sym("_stext"); if (stext_sym_addr == 0) { if (user_page_offset != (-1ULL)) { elf_info->page_offset = user_page_offset; -- cgit