Android:为 ARMv7 外部构建 kexec - 错误包括 'expected ' =', ' ,', ' ;', ' asm' 或 '__attribute__' token 之前的 '*'

标签 android c android-ndk kernel arm

我正在使用 Android NDK 将 kexec 构建为外部内核模块。我知道我已正确设置所有环境变量。

该模块基于来自 android 论坛的代码,该代码基于 Linux 通常构建到内核中的 kexec.c。最终目标是通过在第一个内核之后加载第二个内核来绕过锁定的引导加载程序。

我遇到了多个错误,很可能都与 .h 文件中的内容有关。我的 C 技能确实很生疏,但这里是最重要的几个错误:

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

无论如何,有问题的代码 fragment 在下面,并且还有以下链接到 kexec.c 和 kexec.h 的粘贴完整源代码。

谢谢!

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
};

最佳答案

尝试定义CONFIG_KEXEC。如果没有这个定义,kexec.h 中的所有相关定义都不会包含在内,这反过来会导致至少出现一些错误消息。

为此,您可以将 -DCONFIG_KEXEC 添加到 CFLAGS 或任何适当的环境变量,或者只编辑 Makefile

关于Android:为 ARMv7 外部构建 kexec - 错误包括 'expected ' =', ' ,', ' ;', ' asm' 或 '__attribute__' token 之前的 '*',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10222949/

相关文章:

android - 将 tess-two(Tesseract Tools for Android)库集成到 Android 工作室并构建 ndk

android - 如何解决“"Cannot access androidx.activity.contextaware.ContextAware'”?

c - msync 时出现段错误

c++ - 如何判断我使用的库、dll 和函数是否是 C++ Native

android - 在bluedroid Android HAL下是否仍然可以获得配对或连接的Android设备的RSSI?

android - 在 Android 上为 OpenCV 设置相机场景模式

android - 使用 android-Asynctask 连接但仍然出现错误

c# - Android 上的屏幕触摸模拟

android - 如何使用 Gson 解析 JSON 对象中的多个 JSON 数组?

android - Gradle 构建错误 :Cause: org. gradle.api.internal.ExtensibleDynamicObject