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.
Fields
r_address: i32,
offset in the section to what is being relocated
r_symbolnum: u24,
symbol index if r_extern == 1 or section ordinal if r_extern == 0
r_pcrel: u1,
was relocated pc relative already
r_length: u2,
0=byte, 1=word, 2=long, 3=quad
r_extern: u1,
does not include value of sym referenced
r_type: u4,
if not 0, machine specific relocation type