arm64 linux 支持内核起始地址随机化
kallsymbols 得到的符号地址大都是编译阶段就可以决定的,决定于lds链接obj文件的顺序,编译生成obj时会把不同类型的变量放到固定的section内,如下实例 编译环境是cygwin64下的gcc:
uboot 命令:addboot nokaslr
linux 命令: echo 1 > /proc/sys/kernel/kptr_restrict
cat /proc/kallsymbols |grep "XXX"
多次重启得到的symbol的地址相同即验证成功
====================================================================
nokaslr 源码位置 :/arch/arm64/kernel/kaslr.c
kaslr_early_init 函数会判断cmdline中有无kaslr参数 如果没有就不进行随机起始地址的计算
说明如下:
/*
* This routine will be executed with the kernel mapped at its default virtual* address, and if it returns successfully, the kernel will be remapped, and
* start_kernel() will be executed from a randomized virtual offset. The
* relocation will result in all absolute references (e.g., static variables
* containing function pointers) to be reinitialized, and zero-initialized
* .bss variables will be reset to 0.
*/