DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Common Object File Format (COFF)

Relocation information

Object files have one relocation entry for each relocatable reference in the text or data. The relocation information consists of entries with the format described in ``Relocation section contents''.

Relocation section contents

Bytes Declaration Name Description
0-3 long int r_vaddr (Virtual) address of reference
4-7 long int r_symndx Symbol table index
8-9 unsigned short r_type Relocation type

The first 4 bytes of the entry are the virtual address of the text or data to which this entry applies. The next field is the index, counted from 0, of the symbol table entry that is being referenced. The type field indicates the type of relocation to be applied.

As the link editor reads each input section and performs relocation, the relocation entries are read. They direct how references found within the input section are treated. The currently recognized relocation types are given in ``Relocation types''.

Relocation types

Mnemonic Flag Meaning
R_ABS 0 Reference is absolute; no relocation is necessary. The entry will be ignored.
R_DIR16 * 01 Direct, 16-bit reference to a symbol's virtual address.
R_REL16 * 02 ``PC-relative'', 16-bit reference to a symbol's virtual address. Relative references occur in instructions such as jumps and calls.
R_DIR32 06 Direct 32-bit reference to the symbol's virtual address.
R_SEG12 * 011 Direct, 16-bit reference to the segment-selector bits of a 32-bit virtual address.
R_PCRLONG + 024 ``PC-relative'', 32-bit reference to a symbol's virtual address.
*  80286 Computer only.
+  80386 Computer only.

Relocation entry declaration

The structure declaration for relocation entries is shown below. This declaration may be found in the header file reloc.h.

   struct reloc
   {
     long            r_vaddr;   /* virtual address of reference */
     long            r_symndx;  /* index into symbol table */
     unsigned short  r_type;    /* relocation type */
   };
   

#define RELOC struct reloc #define RELSZ 10


Next topic: Line numbers
Previous topic: Sections

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003