#include <mach-o/reloc.h>

mach-o/reloc.h

$NetBSD: exec.h,v 1.6 1994/10/27 04:16:05 cgd Exp $
includes: stdint.h
2 structs · 2 macros · 1 enum

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.
size 8, align 4
int32_tr_addressoffset in the section to what is being relocated
uint32_t:24r_symbolnumsymbol index if r_extern == 1 or section ordinal if r_extern == 0
uint32_t:1r_pcrelwas relocated pc relative already
uint32_t:2r_length0=byte, 1=word, 2=long, 3=quad
uint32_t:1r_externdoes not include value of sym referenced
uint32_t:4r_typeif not 0, machine specific relocation type

macroR_ABS

#define R_ABS 0
absolute relocation type for Mach-O files

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

size 8, align 4
uint32_t:24r_addressoffset in the section to what is being relocated
uint32_t:4r_typeif not 0, machine specific relocation type
uint32_t:2r_length0=byte, 1=word, 2=long, 3=quad
uint32_t:1r_pcrelwas relocated pc relative already
uint32_t:1r_scattered1=scattered, 0=non-scattered (see above)
int32_tr_valuethe 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.
underlying type unsigned int
GENERIC_RELOC_VANILLA0generic relocation as discribed above
GENERIC_RELOC_PAIR1Only follows a GENERIC_RELOC_SECTDIFF
GENERIC_RELOC_SECTDIFF2
GENERIC_RELOC_PB_LA_PTR3prebound lazy pointer
GENERIC_RELOC_LOCAL_SECTDIFF4
GENERIC_RELOC_TLV5thread local variables