#include <mach-o/reloc.h>
mach-o/reloc.h
$NetBSD: exec.h,v 1.6 1994/10/27 04:16:05 cgd Exp $
structrelocation_info
Format of a relocation entry of a Mach-O file. Modified from the 4.3BSD
format. The modifications from the original format were changing the value
of the r_symbolnum field for "local" (r_extern == 0) relocation entries.
This modification is required to support symbols in an arbitrary number of
sections not just the three sections (text, data and bss) in a 4.3BSD file.
Also the last 4 bits have had the r_type tag added to them.
| int32_t | r_address | offset in the section to what is being relocated |
| uint32_t:24 | r_symbolnum | symbol index if r_extern == 1 or section ordinal if r_extern == 0 |
| uint32_t:1 | r_pcrel | was relocated pc relative already |
| uint32_t:2 | r_length | 0=byte, 1=word, 2=long, 3=quad |
| uint32_t:1 | r_extern | does not include value of sym referenced |
| uint32_t:4 | r_type | if not 0, machine specific relocation type |
macroR_SCATTERED
#define R_SCATTERED 0x80000000
mask to be applied to the r_address field
of a relocation_info structure to tell that
is is really a scattered_relocation_info
stucture
structscattered_relocation_info
| uint32_t:24 | r_address | offset in the section to what is being relocated |
| uint32_t:4 | r_type | if not 0, machine specific relocation type |
| uint32_t:2 | r_length | 0=byte, 1=word, 2=long, 3=quad |
| uint32_t:1 | r_pcrel | was relocated pc relative already |
| uint32_t:1 | r_scattered | 1=scattered, 0=non-scattered (see above) |
| int32_t | r_value | the value the item to be relocated is refering to (without any offset added) |
enumreloc_type_generic
Relocation types used in a generic implementation. Relocation entries for
normal things use the generic relocation as discribed above and their r_type
is GENERIC_RELOC_VANILLA (a value of zero).
Another type of generic relocation, GENERIC_RELOC_SECTDIFF, is to support
the difference of two symbols defined in different sections. That is the
expression "symbol1 - symbol2 + constant" is a relocatable expression when
both symbols are defined in some section. For this type of relocation the
both relocations entries are scattered relocation entries. The value of
symbol1 is stored in the first relocation entry's r_value field and the
value of symbol2 is stored in the pair's r_value field.
A special case for a prebound lazy pointer is needed to beable to set the
value of the lazy pointer back to its non-prebound state. This is done
using the GENERIC_RELOC_PB_LA_PTR r_type. This is a scattered relocation
entry where the r_value feild is the value of the lazy pointer not prebound.
| GENERIC_RELOC_VANILLA | 0 | generic relocation as discribed above |
| GENERIC_RELOC_PAIR | 1 | Only follows a GENERIC_RELOC_SECTDIFF |
| GENERIC_RELOC_SECTDIFF | 2 | |
| GENERIC_RELOC_PB_LA_PTR | 3 | prebound lazy pointer |
| GENERIC_RELOC_LOCAL_SECTDIFF | 4 | |
| GENERIC_RELOC_TLV | 5 | thread local variables |