#ifndef _KXLD_SYMBOL_H_
#define _KXLD_SYMBOL_H_
#include <sys/types.h>
#if KERNEL
#include <libkern/kxld_types.h>
#else
#include "kxld_types.h"
#endif
struct kxld_sect;
struct nlist;
struct nlist_64;
typedef struct kxld_sym KXLDSym;
typedef boolean_t (*KXLDSymPredicateTest)(const KXLDSym *sym);
struct kxld_sym {
char *name; char *alias; kxld_addr_t base_addr; kxld_addr_t link_addr; kxld_addr_t got_addr; uint16_t desc;
uint8_t type;
uint8_t sectnum; uint8_t relocated_sectnum;
u_int is_absolute:1, is_section:1, is_undefined:1, is_indirect:1, is_common:1, is_external:1, is_stab:1, is_weak:1, is_resolved:1, is_obsolete:1, is_replaced:1, is_got:1, is_cxx:1, is_pure_virtual:1, is_class_vtable:1, is_meta_vtable:1, is_padslot:1, is_metaclass:1, is_super_metaclass_pointer:1, is_thumb:1; };
#if KXLD_USER_OR_ILP32
kern_return_t kxld_sym_init_from_macho32(KXLDSym *sym, char *strtab,
const struct nlist *src) __attribute__((nonnull, visibility("hidden")));
#endif
#if KXLD_USER_OR_LP64
kern_return_t kxld_sym_init_from_macho64(KXLDSym *sym, char *strtab,
const struct nlist_64 *src) __attribute__((nonnull, visibility("hidden")));
#endif
void kxld_sym_init_absolute(KXLDSym *sym, char *name, kxld_addr_t link_addr)
__attribute__((nonnull, visibility("hidden")));
void kxld_sym_deinit(KXLDSym *sym)
__attribute__((nonnull, visibility("hidden")));
void kxld_sym_destroy(KXLDSym *sym)
__attribute__((nonnull, visibility("hidden")));
boolean_t kxld_sym_is_absolute(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_section(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_defined(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_defined_locally(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_external(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_exported(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_undefined(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_indirect(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_replaced(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_common(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_unresolved(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_obsolete(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
#if KXLD_USER_OR_GOT
boolean_t kxld_sym_is_got(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
#endif
boolean_t kxld_sym_is_stab(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_weak(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_cxx(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_pure_virtual(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_vtable(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_class_vtable(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_metaclass_vtable(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_padslot(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_metaclass(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_is_super_metaclass_pointer(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_name_is_pure_virtual(const char *name)
__attribute__((pure, nonnull, visibility("hidden")));
boolean_t kxld_sym_name_is_padslot(const char *name)
__attribute__((pure, nonnull, visibility("hidden")));
u_int kxld_sym_get_section_offset(const KXLDSym *sym,
const struct kxld_sect *sect)
__attribute__((pure, nonnull, visibility("hidden")));
#if KXLD_USER_OR_COMMON
kxld_size_t kxld_sym_get_common_size(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
u_int kxld_sym_get_common_align(const KXLDSym *sym)
__attribute__((pure, nonnull, visibility("hidden")));
#endif
kern_return_t kxld_sym_get_class_name_from_metaclass(const KXLDSym *sym,
char class_name[], u_long class_name_len)
__attribute__((nonnull, visibility("hidden")));
kern_return_t kxld_sym_get_class_name_from_super_metaclass_pointer(
const KXLDSym *sym, char class_name[], u_long class_name_len)
__attribute__((nonnull, visibility("hidden")));
kern_return_t kxld_sym_get_class_name_from_vtable(const KXLDSym *sym,
char class_name[], u_long class_name_len)
__attribute__((nonnull, visibility("hidden")));
kern_return_t kxld_sym_get_class_name_from_vtable_name(const char *vtable_name,
char class_name[], u_long class_name_len)
__attribute__((nonnull, visibility("hidden")));
kern_return_t kxld_sym_get_vtable_name_from_class_name(const char *class_name,
char vtable_name[], u_long vtable_name_len)
__attribute__((nonnull, visibility("hidden")));
kern_return_t kxld_sym_get_meta_vtable_name_from_class_name(const char *class_name,
char meta_vtable_name[], u_long meta_vtable_name_len)
__attribute__((nonnull, visibility("hidden")));
kern_return_t kxld_sym_get_final_sym_name_from_class_name(const char *class_name,
char final_sym_name[], u_long final_sym_name_len)
__attribute__((nonnull, visibility("hidden")));
u_long kxld_sym_get_function_prefix_from_class_name(const char *class_name,
char function_prefix[], u_long function_prefix_len)
__attribute__((nonnull, visibility("hidden")));
#if KXLD_USER_OR_ILP32
kern_return_t kxld_sym_export_macho_32(const KXLDSym *sym, u_char *nl,
char *strtab, u_long *stroff, u_long strsize)
__attribute__((nonnull, visibility("hidden")));
#endif
#if KXLD_USER_OR_LP64
kern_return_t kxld_sym_export_macho_64(const KXLDSym *sym, u_char *nl,
char *strtab, u_long *stroff, u_long strsize)
__attribute__((nonnull, visibility("hidden")));
#endif
void kxld_sym_relocate(KXLDSym *sym, const struct kxld_sect *sect)
__attribute__((nonnull, visibility("hidden")));
#if KXLD_USER_OR_GOT
void kxld_sym_set_got(KXLDSym *sym)
__attribute__((nonnull, visibility("hidden")));
#endif
kern_return_t kxld_sym_resolve(KXLDSym *sym, const kxld_addr_t addr)
__attribute__((nonnull, visibility("hidden")));
#if KXLD_USER_OR_COMMON
kern_return_t kxld_sym_resolve_common(KXLDSym *sym, u_int sectnum,
kxld_addr_t base_addr)
__attribute__((nonnull, visibility("hidden")));
#endif
void kxld_sym_delete(KXLDSym *sym)
__attribute__((nonnull, visibility("hidden")));
void kxld_sym_patch(KXLDSym *sym)
__attribute__((nonnull, visibility("hidden")));
void kxld_sym_mark_private(KXLDSym *sym)
__attribute__((nonnull, visibility("hidden")));
#endif