#ifndef _STUFF_OFILE_H_
#define _STUFF_OFILE_H_
#if defined(__MWERKS__) && !defined(__private_extern__)
#define __private_extern__ __declspec(private_extern)
#endif
#include "stuff/target_arch.h"
#import <ar.h>
#ifndef AR_EFMT1
#define AR_EFMT1 "#1/"
#endif
#import <mach-o/loader.h>
#ifdef OFI
#import <mach-o/dyld.h>
#endif
#import "stuff/bytesex.h"
#import "stuff/bool.h"
#import "stuff/arch.h"
enum ofile_type {
OFILE_UNKNOWN,
OFILE_FAT,
OFILE_ARCHIVE,
OFILE_Mach_O
};
struct ofile {
char *file_name;
char *file_addr;
unsigned long file_size;
enum ofile_type file_type;
struct fat_header *fat_header;
struct fat_arch *fat_archs;
unsigned long narch;
enum ofile_type arch_type;
struct arch_flag arch_flag;
unsigned long member_offset;
char *member_addr;
unsigned long member_size;
struct ar_hdr *member_ar_hdr;
char *member_name;
unsigned long member_name_size;
enum ofile_type member_type;
cpu_type_t archive_cputype;
cpu_subtype_t
archive_cpusubtype;
struct dylib_module *modtab;
struct dylib_module_64 *modtab64;
unsigned long nmodtab;
struct dylib_module
*dylib_module;
struct dylib_module_64
*dylib_module64;
char *dylib_module_name;
char *object_addr;
unsigned long object_size;
enum byte_sex object_byte_sex;
struct mach_header *mh;
struct mach_header_64 *mh64;
struct load_command
*load_commands;
cpu_type_t mh_cputype;
cpu_subtype_t mh_cpusubtype;
uint32_t mh_filetype;
};
__private_extern__ void ofile_process(
char *name,
struct arch_flag *arch_flags,
unsigned long narch_flags,
enum bool all_archs,
enum bool process_non_objects,
enum bool dylib_flat,
enum bool use_member_syntax,
void (*processor)(struct ofile *ofile, char *arch_name, void *cookie),
void *cookie);
#ifdef OFI
__private_extern__ NSObjectFileImageReturnCode ofile_map(
#else
__private_extern__ enum bool ofile_map(
#endif
const char *file_name,
const struct arch_flag *arch_flag,
const char *object_name,
struct ofile *ofile,
enum bool archives_with_fat_objects);
#ifdef OFI
__private_extern__ NSObjectFileImageReturnCode ofile_map_from_memory(
#else
__private_extern__ enum bool ofile_map_from_memory(
#endif
char *addr,
unsigned long size,
const char *file_name,
const struct arch_flag *arch_flag,
const char *object_name,
struct ofile *ofile,
enum bool archives_with_fat_objects);
__private_extern__ void ofile_unmap(
struct ofile *ofile);
__private_extern__ enum bool ofile_first_arch(
struct ofile *ofile);
__private_extern__ enum bool ofile_next_arch(
struct ofile *ofile);
__private_extern__ enum bool ofile_first_member(
struct ofile *ofile);
__private_extern__ enum bool ofile_next_member(
struct ofile *ofile);
__private_extern__ enum bool ofile_specific_member(
const char *object_name,
struct ofile *ofile);
__private_extern__ enum bool ofile_first_module(
struct ofile *ofile);
__private_extern__ enum bool ofile_next_module(
struct ofile *ofile);
__private_extern__ enum bool ofile_specific_module(
const char *module_name,
struct ofile *ofile);
__private_extern__ void ofile_print(
struct ofile *ofile);
__private_extern__ unsigned long size_ar_name(
const struct ar_hdr *ar_hdr);
__private_extern__ long ofile_get_word(
unsigned long addr,
unsigned long *word,
void *get_word_data );
__private_extern__ void archive_error(
struct ofile *ofile,
const char *format, ...)
#ifndef __MWERKS__
__attribute__ ((format (printf, 2, 3)))
#endif
;
__private_extern__ void archive_member_error(
struct ofile *ofile,
const char *format, ...)
#ifndef __MWERKS__
__attribute__ ((format (printf, 2, 3)))
#endif
;
__private_extern__ void Mach_O_error(
struct ofile *ofile,
const char *format, ...)
#ifndef __MWERKS__
__attribute__ ((format (printf, 2, 3)))
#endif
;
#endif