Linux内核 - 为什么一个函数在System.map的地址是一个字节$ P $如实时看到pceding它的地址? [英] Linux Kernel - why a function's address in System.map is one byte preceding its address as seen in real time?

查看:283
本文介绍了Linux内核 - 为什么一个函数在System.map的地址是一个字节$ P $如实时看到pceding它的地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux内核源代码code,加入 tasklet_action code此行:

In linux kernel source code, added this lines in tasklet_action code:

printk("tasklet_action = %p\n" , *tasklet_action);
printk("tasklet_action = %p\n" , &tasklet_action);
printk("tasklet_action = %p\n" , tasklet_action);

在输出我得到:

tasklet_action = c03441a1
tasklet_action = c03441a1
tasklet_action = c03441a1

但在搜索时它的System.map 文件中的 tasklet_action 地址为 c03441a0 所以1个字节的偏移。

But when searching it in the system.map file the tasklet_action address is at c03441a0 so there is an offset of 1 byte.


  • 为什么我有这个偏移?

  • 是不是总是一个字节偏移?

推荐答案

我的猜测是,你是在ARM的在Thumb模式的运行,或者在使用该功能的底位其他一些架构指针以指示在运行的模式。

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.

如果这样,答案是你的函数的真正位于地址System.map可能

If so, the answer is that your function really is located at the address in the system.map.

您在运行时获取的值是位置的和模式

The value you get at run time is the location and the mode.

说明,在这类架构的,总是要2或4字节对齐,这会使底部位始终为零。当结构增长一个额外的模式,设计师利用了'浪费'位为en​​ code模式。它很聪明,但令人困惑,而不是只为你:很多的软件,如调试器,打破了很多讨厌的方式时,这是第一次发明了

Instructions, on these kinds of architectures, always must be 2- or 4-byte aligned, which would leave the bottom bit always zero. 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.

这个概念是谁使用可变长度的指令与任何随机排列的x86编程特别混乱。

The concept is particularly confusing for x86 programmers who are used to variable-length instructions with any random alignment.

这篇关于Linux内核 - 为什么一个函数在System.map的地址是一个字节$ P $如实时看到pceding它的地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆