microcontroller - MSP430 上的 ELF 重定位类型

标签 microcontroller elf msp430 relocation

我必须采用可重定位的 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。 这四个字节依次为 600C0000。 位如下:

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/

相关文章:

linux - 共享库卸载的钩子(Hook)函数

c - 对于可以在编译时允许的可变大小的通用队列实现有什么想法吗?

C 改变变量正在被跳过

arduino - boot_app0.bin 和 bootloader_dio_80m.bin 文件有什么用? (ESP32-Arduino 集成开发环境)

c - 使用 KEIL 编译器在 C 中标记多个字符串

linux - 相同 C 库版本的不同 GNU ABI 标签?

c++ - 如何防止用户读取存储在二进制文件中的字符串?

CC110L 拒绝包裹 - 只有重置有帮助

8 位微 Controller 可以使用 32 位整数吗? (反之亦然)

c - PIC18f2520 + HCSR04