I have to take a relocatable ELF file and fix the addresses in a MSP430-F5529 with red hat compiler (not TI). However, I don't understand how the relocations have to be made as I don't get the notation used.
Here are the types and their details.
Let's take this one for example.
- Name : R_MSP430X_ABS20_ADR_DST
- Signedness : Unsigned
- ContainerSize : 32
- Field : [0,4]+[16,16]
And the following generated ASM :
0C60 0000 : MOVA R12, &0x00000
If we search the MOVA
opcode in Wikipedia we see that the structure of the opcode is as it follows:
Offset : [7] [6] [5] [4] [3] [2] [1] [0]
Hex Value : [0] [dst] [6] [src] [src] [src] [src] [src]
We now know that dst C stands for R12 and that the last 20 bits are for the address to be replaced (last 4 bits plus another 16 bits - last 4 0s-).
I know need to understand how to interpret [0,4]+[16,16]
. Looks like the [0,4]
references to the last 4 bits on the first 2 bytes (0060 0000), but how does it work ? And how should I read the [16,16]
?
Here is the quote of the explanation on the PDF in case someone understands.
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.