Structuring Relocation Information
A-10
A.5 Structuring Relocation Information
A COFF object file has one relocation entry for each relocatable reference.
The assembler automatically generates relocation entries. The linker reads
the relocation entries as it reads each input section and performs relocation.
The relocation entries determine how references within each input section are
treated.
COFF file relocation information entries use the 12-byte format shown in
Table A–7.
Table A–7. Relocation Entry Contents
Byte
Number
Type
Description
0–3
Long integer
Virtual address of the reference
4–7
Unsigned long integer
Symbol table index
8–9
Unsigned short integer
For COFF1 files: Reserved
For COFF2 files: Additional byte used for
extended address calculations
10–11
Unsigned short integer
Relocation type (see Table A–8)
The virtual address is the symbol’s address in the current section
before relo-
cation; it specifies
where a relocation must occur. (This is the address of the
field in the object code that must be patched.)
Following is an example of code that generates a relocation entry:
0002
.global
X
0003
0000
FF80
B
X
0001
0000!
In this example, the virtual address of the relocatable field is 0001.
The symbol table index is the index of the referenced symbol. In the
preceding example, this field would contain the index of X in the symbol table.
The amount of the relocation is the difference between the symbol’s current
address in the section and its assembly-time address. The relocatable field
must be relocated by the same amount as the referenced symbol. In the
example, X has a value of 0 before relocation. Suppose X is relocated to
address 2000h. This is the relocation amount (2000h – 0 = 2000h), so the
relocation field at address 1 is patched by adding 2000h to it.
You can determine a symbol’s relocated address if you know which section it
is defined in. For example, if X is defined in .data and .data is relocated by
2000h, X is relocated by 2000h.
Summary of Contents for TMS320C54x
Page 38: ......
Page 39: ......
Page 40: ......
Page 41: ......
Page 42: ......
Page 43: ......
Page 44: ......
Page 45: ......
Page 46: ......
Page 47: ......
Page 48: ......
Page 49: ......
Page 50: ......
Page 51: ......
Page 52: ......
Page 53: ......
Page 54: ......
Page 55: ......
Page 56: ......
Page 57: ......
Page 58: ......
Page 59: ......
Page 60: ......
Page 61: ......
Page 62: ......
Page 276: ......
Page 277: ......
Page 278: ......
Page 279: ......
Page 280: ......
Page 281: ......
Page 282: ......
Page 283: ......
Page 284: ......
Page 285: ......
Page 286: ......
Page 287: ......
Page 288: ......
Page 289: ......
Page 290: ......
Page 291: ......
Page 292: ......
Page 293: ......
Page 294: ......
Page 295: ......
Page 296: ......
Page 297: ......
Page 298: ......
Page 299: ......
Page 300: ......
Page 301: ......
Page 302: ......