一个关于arm64汇编语言的问题。
例如,在linux 5.9.15源代码中,在arch/arm64/kernel/vmlinux.lds.S(链接描述文件)中,有一行idmap_pg_dir = .;
。所以 idmap_pg_dir 是一个地址。现在,在 arch/arm64/kernel/head.S 中,有一行 adrp x0, idmap_pg_dir
。这是不是意味着
1) x0 = PC + idmap_pg_dir or
2) x0 = idmap_pg_dir ?
我认为当我们执行adrp x0, addr1
时,通常addr1
是PC相对地址偏移,x0变成PC + addr
。但链接器脚本似乎说 idmap_pg_dir 只是一个绝对地址。 (不是吗?)所以我很困惑。请有人纠正我。
最佳答案
在 ARMv8 架构引用手册的 ADRP 指令部分,它说:
Is the program label whose 4KB page address is to be calculated. Its offset from the page address of this instruction, in the range +/-4GB, is encoded as "immhi:immlo" times 4096.
因此编译器“计算”到“标签”的“偏移量”。因此使用当前指令的“偏移量”而不是标签的绝对地址。
关于assembly - 在arm64汇编中, "adrp x0, idmap_pg_dir;"指令是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64554716/