__relocate_kernel: pie

本文详细解析了ARM64架构下如何通过在内核中使用重定位表来实现内核的动态地址转换,使内核能够在不同的虚拟地址上运行。文章深入介绍了重定位过程中的关键指令及其实现细节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#ifdef CONFIG_RELOCATABLE
__relocate_kernel:
    /*
     * Iterate over each entry in the relocation table, and apply the
     * relocations in place.
     */
    ldr w9, =__rela_offset      // offset to reloc table
    ldr w10, =__rela_size       // size of reloc table

    mov_q   x11, KIMAGE_VADDR       // default virtual offset
    add x11, x11, x23           // actual virtual offset
    add x9, x9, x11         // __va(.rela)
    add x10, x9, x10            // __va(.rela) + sizeof(.rela)

0:  cmp x9, x10
    b.hs    1f
    ldp x11, x12, [x9], #24
    ldr x13, [x9, #-8]
    cmp w12, #R_AARCH64_RELATIVE
    b.ne    0b
    add x13, x13, x23           // relocate
    str x13, [x11, x23]
    b   0b
1:  ret
ENDPROC(__relocate_kernel)
#endif

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值