我必须采用可重定位的 ELF 文件并使用 Red Hat 编译器(不是 TI)修复 MSP430-F5529 中的地址。但是,我不明白如何进行重定位,因为我没有使用符号。
Here是类型及其详细信息。
我们以这个为例。
- 名称:R_MSP430X_ABS20_ADR_DST
- 签名:无签名
- 容器大小:32
- 字段:[0,4]+[16,16]
生成的 ASM 如下:
0C60 0000:MOVA R12,&0x00000
如果我们在Wikipedia中搜索MOVA
操作码我们看到操作码的结构如下:
偏移量:[7] [6] [5] [4] [3] [2] [1] [0]
十六进制值:[0] [dst] [6] [src] [src] [src] [src] [src]
我们现在知道 dst C 代表 R12,最后 20 位用于要替换的地址(最后 4 位加上另外 16 位 - 最后 4 位) 0s-)。
我知道需要了解如何解释[0,4]+[16,16]
。看起来像 [0,4]
引用前 2 个字节的最后 4 位 (0060 0000),但它是如何工作的?我应该如何阅读 [16,16]
?
这里引用了 PDF 上的解释,以防有人理解。
The field is specified using the tuple [CS, O, FS], where CS is the container size, O is the starting offset from the LSB of the container to the LSB of the field, and FS is the size of the field. All values are in bits. The notation [x,y]+[z,w] indicates that relocation occupies discontiguous bit ranges, which should be concatenated to form the field.
最佳答案
您的“偏移”值错误。
“ContainerSize: 32”意味着您必须将指令视为单个、小端、32 位值。
作为 32 位值,它将被写为 00000C60
。
这四个字节依次为 60
、0C
、00
和 00
。
位如下:
31302928272625242322212019181716151413121110 9 8 7 6 5 4 3 2 1 0
a a a a a a a a a a a a a a a a 0 0 0 0 s s s s 0 1 1 0 a a a a
关于microcontroller - MSP430 上的 ELF 重定位类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35042974/