#ifndef _KXLD_RELOC_H
#define _KXLD_RELOC_H
#include <mach/machine.h>
#include <sys/types.h>
#if KERNEL
#include <libkern/kxld_types.h>
#else
#include "kxld_types.h"
#endif
struct kxld_array;
struct kxld_sym;
struct kxld_symtab;
typedef struct kxld_relocator KXLDRelocator;
typedef struct kxld_reloc KXLDReloc;
typedef boolean_t (*RelocHasPair)(u_int r_type);
typedef boolean_t (*RelocIsPair)(u_int r_type, u_int prev_r_type);
typedef boolean_t (*RelocHasGot)(u_int r_type);
typedef kern_return_t(*ProcessReloc)(u_char *instruction, u_int length, u_int pcrel,
kxld_addr_t base_pc, kxld_addr_t link_pc, kxld_addr_t link_disp, u_int type,
kxld_addr_t target, kxld_addr_t pair_target, boolean_t swap);
struct kxld_relocator {
RelocHasPair reloc_has_pair;
RelocIsPair reloc_is_pair;
RelocHasGot reloc_has_got;
ProcessReloc process_reloc;
boolean_t is_32_bit;
boolean_t swap;
};
struct kxld_reloc {
u_int address;
u_int target;
u_int pair_target;
u_int target_type:3;
u_int pair_target_type:3;
u_int reloc_type:4;
u_int length:2;
u_int pcrel:1;
};
struct kxld_array;
struct kxld_sect;
struct kxld_seg;
struct kxld_symtab;
struct relocation_info;
kern_return_t kxld_relocator_init(KXLDRelocator *relocator, cpu_type_t cputype,
cpu_subtype_t cpusubtype, boolean_t swap)
__attribute__((nonnull,visibility("hidden")));
kern_return_t kxld_reloc_create_macho(struct kxld_array *relocarray,
const KXLDRelocator *relocator, const struct relocation_info *srcs,
u_int nsrcs) __attribute__((nonnull, visibility("hidden")));
void kxld_relocator_clear(KXLDRelocator *relocator)
__attribute__((nonnull, visibility("hidden")));
boolean_t kxld_relocator_has_pair(const KXLDRelocator *relocator, u_int r_type)
__attribute__((pure, nonnull,visibility("hidden")));
boolean_t kxld_relocator_is_pair(const KXLDRelocator *relocator, u_int r_type,
u_int last_r_type)
__attribute__((pure, nonnull,visibility("hidden")));
boolean_t kxld_relocator_has_got(const KXLDRelocator *relocator, u_int r_type)
__attribute__((pure, nonnull,visibility("hidden")));
struct kxld_sym * kxld_reloc_get_symbol(const KXLDRelocator *relocator,
const KXLDReloc *reloc, u_char *data,
const struct kxld_symtab *symtab)
__attribute__((pure, nonnull(1,2,4), visibility("hidden")));
kern_return_t kxld_reloc_get_reloc_index_by_offset(const struct kxld_array *relocs,
kxld_size_t offset, u_int *idx)
__attribute__((nonnull, visibility("hidden")));
KXLDReloc * kxld_reloc_get_reloc_by_offset(const struct kxld_array *relocs,
kxld_addr_t offset)
__attribute__((pure, nonnull, visibility("hidden")));
kern_return_t kxld_reloc_update_symindex(KXLDReloc *reloc, u_int symindex)
__attribute__((nonnull,visibility("hidden")));
kern_return_t kxld_relocator_process_sect_reloc(const KXLDRelocator *relocator,
const KXLDReloc *reloc, const struct kxld_sect *sect,
const struct kxld_array *sectarray, const struct kxld_symtab *symtab)
__attribute__((nonnull,visibility("hidden")));
kern_return_t kxld_relocator_process_table_reloc(const KXLDRelocator *relocator,
const KXLDReloc *reloc, const struct kxld_seg *seg, u_char *file,
const struct kxld_array *sectarray,
const struct kxld_symtab *symtab)
__attribute__((nonnull,visibility("hidden")));
#endif