[英]Linux Kernel - why a function's address in System.map is one byte preceding its address as seen in real time?
In linux kernel source code, added this lines in tasklet_action
code: 在linux内核源代码中,在
tasklet_action
代码中添加了以下行:
printk("tasklet_action = %p\n" , *tasklet_action);
printk("tasklet_action = %p\n" , &tasklet_action);
printk("tasklet_action = %p\n" , tasklet_action);
In the output I get: 在输出中我得到:
tasklet_action = c03441a1
tasklet_action = c03441a1
tasklet_action = c03441a1
But when searching it in the system.map
file the tasklet_action
address is at c03441a0
so there is an offset of 1 byte. 但是当在
system.map
文件中搜索它时, tasklet_action
地址位于c03441a0
因此存在1个字节的偏移量。
My guess is that you are running on ARM in Thumb mode , or on some other architecture that uses the bottom bit of the function pointer to indicate which mode to run in. 我的猜测是你在Thumb模式下运行ARM,或者在使用函数指针底部位的其他一些架构上运行,以指示运行哪种模式。
If so, the answer is that your function really is located at the address in the system.map . 如果是这样,答案是您的函数确实位于system.map中的地址 。
The value you get at run time is the location and the mode . 运行时获得的值是位置和模式 。
Instructions, on these kinds of architectures, always must be 2- or 4-byte aligned, which would leave the bottom bit always zero. 在这些类型的体系结构上,指令必须始终为2或4字节对齐,这样底部位始终为零。 When the architecture grew an extra mode the designers made use of the 'wasted' bit to encode the mode.
当架构发展为额外模式时,设计人员利用“浪费”位对模式进行编码。 It's clever, but confusing, and not just for you: a lot of software, like debuggers, broke in many nasty ways when this was first invented.
它很聪明,但令人困惑,而且不只是为了你:很多软件,比如调试器,在最初发明时会以许多令人讨厌的方式破解。
The concept is particularly confusing for x86 programmers who are used to variable-length instructions with any random alignment. 对于习惯于任意随机对齐的可变长度指令的x86程序员来说,这个概念尤其令人困惑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.