diff options
author | Fabian Groffen <grobian@gentoo.org> | 2008-09-08 07:02:56 +0000 |
---|---|---|
committer | Fabian Groffen <grobian@gentoo.org> | 2008-09-08 07:02:56 +0000 |
commit | b14fee9febef245dc43042a0feaa8620dbcc02ee (patch) | |
tree | ea12455d0f2c7d6cc029172cb3425656f52647e1 /paxmacho.h | |
parent | - add OSABI/EABI support to scanelf --osabi/--eabi to scanelf. Update elf.h (diff) | |
download | pax-utils-b14fee9febef245dc43042a0feaa8620dbcc02ee.tar.gz pax-utils-b14fee9febef245dc43042a0feaa8620dbcc02ee.tar.bz2 pax-utils-b14fee9febef245dc43042a0feaa8620dbcc02ee.zip |
Initial commit of Mach-O related files. (bug #236512)
- added macho.h (Mach-O definitions) and scanmacho.c (the scanelf
equivalent for Mach-O files)
- changed the Makefile to compile scanmacho (tested compilation on
Darwin and Solaris)
- changed paxinc.h to include macho.h and paxmacho.h
- extended paxmacho.[ch] with relevant code to read meta information
from Mach-O files
Diffstat (limited to 'paxmacho.h')
-rw-r--r-- | paxmacho.h | 51 |
1 files changed, 39 insertions, 12 deletions
@@ -1,10 +1,11 @@ /* * Copyright 2005-2007 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxmacho.h,v 1.3 2007/05/23 22:27:27 solar Exp $ + * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxmacho.h,v 1.4 2008/09/08 07:02:56 grobian Exp $ * * Copyright 2005-2007 Ned Ludd - <solar@gentoo.org> * Copyright 2005-2007 Mike Frysinger - <vapier@gentoo.org> + * 2008 Fabian Groffen - <grobian@gentoo.org> * * Make sure all of the common mach-o stuff is setup as we expect */ @@ -12,18 +13,44 @@ #ifndef _PAX_MACHO_H #define _PAX_MACHO_H +#include "macho.h" + +typedef struct _fatobj { + char *data; /* mmapped image of the whole file */ + size_t len; /* length of data (file length) */ + int fd; /* open filedescriptor to the file */ + const char *filename; /* full filename */ + const char *base_filename; /* basename of filename (don't free) */ + char swapped; /* whether values need to be swapped */ + char ismach64; /* whether mach_header_64 is in use */ + char isbigendian; /* whether the byte order is big-endian */ + union { + struct mach_header *hdr32; /* pointer to arch Mach-O header */ + struct mach_header_64 *hdr64; /* 64-bits variant */ + } mhdr; + char *mhdata; /* pointer to the image of the mach_header */ + struct _fatobj *next; /* pointer to the next arch */ +} fatobj; + typedef struct { - void *mhdr; - char *data; - uint32_t macho_class; - off_t len; - int fd; - const char *filename; - const char *base_filename; -} machoobj; + char *data; /* pointer to the current command header */ + struct load_command* lcmd; /* the load command */ + uint32_t cleft; /* load commands left */ + uint32_t align; /* alignment size in bytes */ + char swapped; /* whether values need to be swapped */ +} loadcmd; -machoobj *readmacho(const char *filename); -void unreadmacho(machoobj *macho); -const char *get_machomhtype(int mh_type); +const char *get_machomhtype(fatobj *fobj); +void get_machomhflags(fatobj *fobj, char **ret, size_t *ret_len); +const char *get_machocputype(fatobj *fobj); +const char *get_machosubcputype(fatobj *fobj); +fatobj *readmacho(const char *filename); +fatobj *readmacho_fd(const char *filename, int fd, size_t len); +fatobj *readmacho_buffer(const char *filename, char *buffer, size_t buffer_len); +void unreadmacho(fatobj *macho); +loadcmd *firstloadcmd(fatobj *fobj); +int nextloadcmd(loadcmd* lcmd); +const char *get_machoendian(fatobj *fobj); +const char *get_machomtype(fatobj *fobj); #endif /* _PAX_MACHO_H */ |