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.
Содержание TMS320C54x
Страница 38: ......
Страница 39: ......
Страница 40: ......
Страница 41: ......
Страница 42: ......
Страница 43: ......
Страница 44: ......
Страница 45: ......
Страница 46: ......
Страница 47: ......
Страница 48: ......
Страница 49: ......
Страница 50: ......
Страница 51: ......
Страница 52: ......
Страница 53: ......
Страница 54: ......
Страница 55: ......
Страница 56: ......
Страница 57: ......
Страница 58: ......
Страница 59: ......
Страница 60: ......
Страница 61: ......
Страница 62: ......
Страница 276: ......
Страница 277: ......
Страница 278: ......
Страница 279: ......
Страница 280: ......
Страница 281: ......
Страница 282: ......
Страница 283: ......
Страница 284: ......
Страница 285: ......
Страница 286: ......
Страница 287: ......
Страница 288: ......
Страница 289: ......
Страница 290: ......
Страница 291: ......
Страница 292: ......
Страница 293: ......
Страница 294: ......
Страница 295: ......
Страница 296: ......
Страница 297: ......
Страница 298: ......
Страница 299: ......
Страница 300: ......
Страница 301: ......
Страница 302: ......