I’m working on building kexec as an external kernel module, using the Android NDK. I know I have all my environment variables set correctly.
The module is based on code from an android forum, which is based on the kexec.c that linux normally would build into the kernel. The eventual goal is to bypass the locked bootloader by loading a second kernel after the initial one.
I’m running into multiple errors, most likely all related to stuff in the .h file. My C skills are really rusty, but here are the top several errors:
make -C /media/disk/android/kernel/omap3 M=/media/disk/android/kexec modules
make[1]: Entering directory `/media/disk/android/kernel/omap3'
CC [M] /media/disk/android/kexec/kexec.o
/media/disk/android/kexec/kexec.c:52: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
/media/disk/android/kexec/kexec.c:55: error: 'VMCOREINFO_BYTES' undeclared here (not in a function)
/media/disk/android/kexec/kexec.c:56: error: 'VMCOREINFO_NOTE_SIZE' undeclared here (not in a function)
/media/disk/android/kexec/kexec.c:115: warning: 'struct kimage' declared inside parameter list
/media/disk/android/kexec/kexec.c:115: warning: its scope is only this definition or declaration,
which is probably not what you want
/media/disk/android/kexec/kexec.c:118: warning: 'struct kimage' declared inside parameter list
/media/disk/android/kexec/kexec.c:122: warning: 'struct kimage' declared inside parameter list
/media/disk/android/kexec/kexec.c: In function 'do_kimage_alloc':
/media/disk/android/kexec/kexec.c:131: error: dereferencing pointer to incomplete type
Anyway, the offending snippet is below, and there are also the following links to the pastebined full source of kexec.c and kexec.h.
- complete error log: http://pastebin.com/bf5XTEmS
- kexec.c http://pastebin.com/zqbbSfLk
- kexec.h http://pastebin.com/M1Mpp6YX
Thanks!
MODULE_LICENSE("GPL");
/* Syscall table */
void **sys_call_table;
/* original and new reboot syscall */
asmlinkage long (*original_reboot)(int magic1, int magic2, unsigned int cmd, void __user *arg);
extern asmlinkage long reboot(int magic1, int magic2, unsigned int cmd, void __user *arg);
/* Per cpu memory for storing cpu states in case of system crash. */
note_buf_t *crash_notes;
/* vmcoreinfo stuff */
unsigned char vmcoreinfo_data[VMCOREINFO_BYTES];
u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];
size_t vmcoreinfo_size;
size_t vmcoreinfo_max_size = sizeof(vmcoreinfo_data);
/* Location of the reserved area for the crash kernel */
struct resource crashk_res = {
.name = "Crash kernel",
.start = 0,
.end = 0,
.flags = IORESOURCE_BUSY | IORESOURCE_MEM
};
Try defining
CONFIG_KEXEC. Without this define all relevant defintions inkexec.hare not included, which then in turn leads to at least some of the error messages you get.To do so you might add
-DCONFIG_KEXECtoCFLAGSor any approriate enviroment variable, or just edit theMakefile.