#ifndef _STUFF_OFILE_H_
#define _STUFF_OFILE_H_
#if defined(__MWERKS__) && !defined(__private_extern__)
#define __private_extern__ __declspec(private_extern)
#endif
#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
#ifdef LTO_SUPPORT
,
OFILE_LLVM_BITCODE
#endif
};
struct ofile {
char *file_name;
char *file_addr;
uint64_t file_size;
uint64_t file_mtime;
enum ofile_type file_type;
struct fat_header *fat_header;
struct fat_arch *fat_archs;
uint32_t narch;
enum ofile_type arch_type;
struct arch_flag arch_flag;
char *toc_addr;
uint32_t toc_size;
struct ar_hdr *toc_ar_hdr;
char *toc_name;
uint32_t toc_name_size;
struct ranlib *toc_ranlibs;
uint32_t toc_nranlibs;
char *toc_strings;
uint32_t toc_strsize;
enum bool toc_bad;
uint32_t member_offset;
char *member_addr;
uint32_t member_size;
struct ar_hdr *member_ar_hdr;
char *member_name;
uint32_t 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;
uint32_t nmodtab;
struct dylib_module
*dylib_module;
struct dylib_module_64
*dylib_module64;
char *dylib_module_name;
enum bool headers_swapped;
char *object_addr;
uint32_t 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;
void *lto;
cpu_type_t lto_cputype;
cpu_subtype_t lto_cpusubtype;
};
__private_extern__ void ofile_process(
char *name,
struct arch_flag *arch_flags,
uint32_t 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,
uint64_t size,
const char *file_name,
uint64_t mtime,
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__ uint32_t size_ar_name(
const struct ar_hdr *ar_hdr);
__private_extern__ int32_t ofile_get_word(
uint64_t addr,
uint32_t *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
;
#ifdef LTO_SUPPORT
__private_extern__ int is_llvm_bitcode(
struct ofile *ofile,
char *addr,
size_t size);
#endif
#endif