2011年11月30日 星期三

libelf for arm

對於 arm 的 object file 使用 elfutils-libelf 時

取用 Symbol 需要注意 Symbol address 的部份

在 ELF for the ARM®  Architecture 的第 4.6.3 的部份有提到

Symbol Values 
  • In addition to the normal rules for symbol values the following rules shall also apply to symbols of type STT_FUNC: If the symbol addresses an ARM instruction, its value is the address of the instruction (in a relocatable object, the offset of the instruction from the start of the section containing it). 
  • If the symbol addresses a Thumb instruction, its value is the address of the instruction with bit zero set (in a relocatable object, the section offset with bit zero set). 
  • For the purposes of relocation the value used shall be the address of the instruction (st_value & ~1).
ARM 跟 thumb 的 Symbol 區別方式是看 Symbol Table 中 Symbol Address 的最低位元來判斷, 所以取用請記得 st_value & ~1, 免得取到的 Address 差一.

沒有留言:

張貼留言