From: Michael Gernoth Date: Tue, 24 May 2011 22:29:31 +0000 (+0200) Subject: parse System.map for memory locations X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/ms2-kexec/commitdiff_plain/4f8bca6642175fb93e3830028e31519f50f8323f?ds=inline parse System.map for memory locations This removes static memory addresses of sys_call_table and kernel_restart_prepare and makes it easier to compile for a new target --- diff --git a/Makefile b/Makefile index aea8202..544acff 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,10 @@ ARCH=arm CROSS_COMPILE=arm-eabi- CROSS_PATH=$(PWD)/../prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin -EXTRA_CFLAGS += -DCONFIG_KEXEC -Wall +SYS_CALL_TABLE := $(shell grep ' T sys_call_table$$' $(KDIR)/System.map | cut -f1 -d' ') +KERNEL_RESTART_PREPARE := $(shell grep ' T kernel_restart_prepare$$' $(KDIR)/System.map | cut -f1 -d' ') + +EXTRA_CFLAGS += -DCONFIG_KEXEC -Wall -DSYS_CALL_TABLE=0x$(SYS_CALL_TABLE) -DKERNEL_RESTART_PREPARE=0x$(KERNEL_RESTART_PREPARE) obj-m += kexec_load.o kexec_load-objs := kexec.o machine_kexec.o mmu.o sys.o core.o relocate_kernel.o \ diff --git a/kexec.c b/kexec.c index 2f98d32..1efad11 100644 --- a/kexec.c +++ b/kexec.c @@ -1457,6 +1457,7 @@ unsigned long **find_sys_call_table(void) { static int __init kexec_module_init(void) { +#if 0 sys_call_table=(void **)find_sys_call_table(); if(sys_call_table==NULL) { printk(KERN_ERR "Cannot find the system call address\n"); @@ -1464,9 +1465,9 @@ static int __init kexec_module_init(void) } printk(KERN_INFO "kexec: Found sys_call_table at: %p\n", sys_call_table); +#endif - //sys_call_table=(void **)0xc003d004; - sys_call_table=(void **)0xc00350c4; + sys_call_table=(void **)SYS_CALL_TABLE; printk(KERN_INFO "kexec: Force sys_call_table at: %p\n", sys_call_table); /* Set kexec_load() syscall. */ diff --git a/sys.c b/sys.c index fd71e4f..e631609 100644 --- a/sys.c +++ b/sys.c @@ -59,8 +59,7 @@ BLOCKING_NOTIFIER_HEAD(notifier_head); void kernel_restart_prepare(char *cmd) { -#warning assuming kernel_restart_prepare is at 0xc00779cc - void (*original_kernel_restart_prepare)(char *) = (void (*)(char *))0xc00779cc; + void (*original_kernel_restart_prepare)(char *) = (void (*)(char *))KERNEL_RESTART_PREPARE; return original_kernel_restart_prepare(cmd); #if 0 register_reboot_notifier(&dummy_notifier_reboot);