Changeset 2952


Ignore:
Timestamp:
Jan 30, 2007, 4:02:06 AM (19 years ago)
Author:
bird
Message:

Mach-O in process (very early).

Location:
trunk/kLdr
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/kLdr/Makefile.kmk

    r2944 r2952  
    7676 kLdr_LDFLAGS = -Entry:DllMain@12 -Debug
    7777 kLdr_DEFS = __WIN__
    78  kLdr_SDKS.x86 = LIBSDL WIN32SDK W2K3DDKX86
     78 kLdr_SDKS.x86 = WIN32SDK W2K3DDKX86
    7979 kLdr_SDKS.amd64 = WIN64SDK W2K3DDKAMD64
    8080 kLdr_LIBS = \
     
    113113        kLdrModLX.c \
    114114        kLdrModPE.c \
     115        kLdrModMachO.c \
    115116        kLdrModNative.c
    116117kLdr_SOURCES.os2 = \
  • trunk/kLdr/kLdr.h

    r2948 r2952  
    3232#endif
    3333
    34 /* 
    35  * kLdr depend on size_t, [u]intNN_t, [u]intptr_t and some related constants. 
     34/*
     35 * kLdr depend on size_t, [u]intNN_t, [u]intptr_t and some related constants.
    3636 * If KLDR_NO_KLDR_H_INCLUDES is defined, these has already been defined.
    3737 */
     
    5353#  define UINT32_C(c)           (c ## U)
    5454#  define UINT64_C(c)           (c ## ULL)
     55#  define INT16_C(c)            (c)
     56#  define INT32_C(c)            (c)
     57#  define INT64_C(c)            (c ## LL)
    5558# else
    5659#  include <stdint.h>
     
    415418     * Primarily a way for the user to specify selectors for the LX/LE and NE interpreters. */
    416419    uint16_t        SelFlat;
    417     /** The 16-bit selector to use for the segment. 
     420    /** The 16-bit selector to use for the segment.
    418421     * Primarily a way for the user to specify selectors for the LX/LE and NE interpreters. */
    419422    uint16_t        Sel16bit;
     
    448451
    449452
    450 /** @name Segment flags 
     453/** @name Segment flags
    451454 * @{ */
    452455/** The segment is 16-bit. When not set the default of the target architecture is assumed. */
     
    476479    /** The LX loader. */
    477480    KLDRFMT_LX,
    478     /** The mach-o loader. */
     481    /** The Mach-O loader. */
    479482    KLDRFMT_MACHO,
    480     /** The LX loader. */
     483    /** The PE loader. */
    481484    KLDRFMT_PE,
    482485    /** The end of the valid format values (exclusive). */
     
    721724 * @param   idName      The resource id. NIL_KLDRMOD_RSRC_NAME_ID if no id.
    722725 * @param   pszName     The resource name. NULL if no name.
    723  * @param   idLang      The language id. 
     726 * @param   idLang      The language id.
    724727 * @param   AddrRsrc    The address value for the resource.
    725728 * @param   cbRsrc      The size of the resource.
    726729 * @param   pvUser      The user parameter specified to kLdrModEnumDbgInfo.
    727730 */
    728 typedef int FNKLDRENUMRSRC(PKLDRMOD pMod, uint32_t idType, const char *pszType, uint32_t idName, const char *pszName, 
     731typedef int FNKLDRENUMRSRC(PKLDRMOD pMod, uint32_t idType, const char *pszType, uint32_t idName, const char *pszName,
    729732                           uint32_t idLang, KLDRADDR AddrRsrc, KLDRSIZE cbRsrc, void *pvUser);
    730733/** Pointer to a resource enumerator callback. */
     
    736739#define NIL_KLDRMOD_RSRC_TYPE_ID    ( ~(uint32_t)0 )
    737740/** @name Language ID
    738  * 
    739  * Except for the special IDs #defined here, the values are considered 
     741 *
     742 * Except for the special IDs #defined here, the values are considered
    740743 * format specific for now since it's only used by the PE resources.
    741  * 
     744 *
    742745 * @{ */
    743746/** NIL language ID. */
     
    767770
    768771int     kLdrModQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t iSymbol,
    769                            const char *pchSymbol, size_t cchSymbol, const char *pszVersion, 
     772                           const char *pchSymbol, size_t cchSymbol, const char *pszVersion,
    770773                           PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, uint32_t *pfKind);
    771774int     kLdrModEnumSymbols(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress,
     
    778781int     kLdrModQueryResource(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t idType, const char *pszType,
    779782                             uint32_t idName, const char *pszName, uint32_t idLang, PKLDRADDR pAddrRsrc, size_t *pcbRsrc);
    780 int     kLdrModEnumResources(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t idType, const char *pszType, 
     783int     kLdrModEnumResources(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t idType, const char *pszType,
    781784                             uint32_t idName, const char *pszName, uint32_t idLang, PFNKLDRENUMRSRC pfnCallback, void *pvUser);
    782785int     kLdrModEnumDbgInfo(PKLDRMOD pMod, const void *pvBits, PFNKLDRENUMDBG pfnCallback, void *pvUser);
     
    842845    /** @copydoc kLdrModQuerySymbol */
    843846    int (* pfnQuerySymbol)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t iSymbol,
    844                            const char *pchSymbol, size_t cchSymbol, const char *pszVersion, 
     847                           const char *pchSymbol, size_t cchSymbol, const char *pszVersion,
    845848                           PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, uint32_t *pfKind);
    846849    /** @copydoc kLdrModEnumSymbols */
     
    861864                             uint32_t idName, const char *pszName, uint32_t idLang, PKLDRADDR pAddrRsrc, size_t *pcbRsrc);
    862865    /** @copydoc kLdrModEnumResources */
    863     int (* pfnEnumResources)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t idType, const char *pszType, 
     866    int (* pfnEnumResources)(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, uint32_t idType, const char *pszType,
    864867                             uint32_t idName, const char *pszName, uint32_t idLang, PFNKLDRENUMRSRC pfnCallback, void *pvUser);
    865868    /** @copydoc kLdrModEnumDbgInfo */
     
    975978int     kLdrDyldGetName(HKLDRMOD hMod, char *pszName, size_t cchName);
    976979int     kLdrDyldGetFilename(HKLDRMOD hMod, char *pszFilename, size_t cchFilename);
    977 int     kLdrDyldQuerySymbol(HKLDRMOD hMod, uint32_t uSymbolOrdinal, const char *pszSymbolName, 
     980int     kLdrDyldQuerySymbol(HKLDRMOD hMod, uint32_t uSymbolOrdinal, const char *pszSymbolName,
    978981                            const char *pszSymbolVersion, uintptr_t *pValue, uint32_t *pfKind);
    979 int     kLdrDyldQueryResource(HKLDRMOD hMod, uint32_t idType, const char *pszType, uint32_t idName, 
     982int     kLdrDyldQueryResource(HKLDRMOD hMod, uint32_t idType, const char *pszType, uint32_t idName,
    980983                              const char *pszName, uint32_t idLang, void **pvRsrc, size_t *pcbRsrc);
    981 int     kLdrDyldEnumResources(HKLDRMOD hMod, uint32_t idType, const char *pszType, uint32_t idName, 
     984int     kLdrDyldEnumResources(HKLDRMOD hMod, uint32_t idType, const char *pszType, uint32_t idName,
    982985                              const char *pszName, uint32_t idLang, PFNKLDRENUMRSRC pfnCallback, void *pvUser);
    983986
     
    12311234/** @} */
    12321235
     1236/** @name
     1237 * @{ */
     1238#define KLDR_ERR_MACHO_BASE                                 (KLDR_ERR_LX_BASE + 12)
     1239/** Only native endian MACH-O files are supported. */
     1240#define KLDR_ERR_MACHO_OTHER_ENDIAN_NOT_SUPPORTED           (KLDR_ERR_MACHO_BASE + 0)
     1241/** 64-bit MACH-O files aren't supported yet. */
     1242#define KLDR_ERR_MACHO_64BIT_NOT_SUPPORTED                  (KLDR_ERR_MACHO_BASE + 1)
     1243/** The MACH-O header is bad or contains new and unsupported features. */
     1244#define KLDR_ERR_MACHO_BAD_HEADER                           (KLDR_ERR_MACHO_BASE + 2)
     1245/** The file type isn't supported. */
     1246#define KLDR_ERR_MACHO_UNSUPPORTED_FILE_TYPE                (KLDR_ERR_MACHO_BASE + 3)
     1247/** The machine (cputype / cpusubtype combination) isn't supported. */
     1248#define KLDR_ERR_MACHO_UNSUPPORTED_MACHINE                  (KLDR_ERR_MACHO_BASE + 4)
     1249/** @} */
     1250
    12331251/** End of the valid kLdr status codes. */
    12341252#define KLDR_ERR_END                                        (KLDR_ERR_LX_BASE + 12)
  • trunk/kLdr/kLdrModMachO.h

    r2951 r2952  
    4141
    4242
    43 #ifdef IMAGE_MACHO32_SIGNATURE
     43#ifndef IMAGE_MACHO32_SIGNATURE
    4444/** The 32-bit Mach-O signature. */
    4545# define IMAGE_MACHO32_SIGNATURE        UINT32_C(0xfeedface)
    4646#endif
    47 #ifdef IMAGE_MACHO32_SIGNATURE_OE
     47#ifndef IMAGE_MACHO32_SIGNATURE_OE
    4848/** The 32-bit Mach-O signature, other endian. */
    4949# define IMAGE_MACHO32_SIGNATURE_OE     UINT32_C(0xcefaedfe)
     
    7070
    7171
    72 #ifdef IMAGE_MACHO64_SIGNATURE
     72#ifndef IMAGE_MACHO64_SIGNATURE
    7373/** The 64-bit Mach-O signature. */
    7474# define IMAGE_MACHO64_SIGNATURE        UINT32_C(0xfeedfacf)
    7575#endif
    76 #ifdef IMAGE_MACHO64_SIGNATURE_OE
     76#ifndef IMAGE_MACHO64_SIGNATURE_OE
    7777/** The 64-bit Mach-O signature, other endian. */
    7878# define IMAGE_MACHO64_SIGNATURE_OE     UINT32_C(0xfefaedfe)
     
    137137#define MH_BINDS_TO_WEAK            UINT32_C(0x00010000) /**< The (finally) linked image uses weak symbols. */
    138138#define MH_ALLOW_STACK_EXECUTION    UINT32_C(0x00020000) /**< Task: allow stack execution. (MH_EXECUTE only) */
     139#define MH_VALID_FLAGS              UINT32_C(0x0003ffff) /**< Mask containing the defined flags. */
    139140/** @} */
    140141
Note: See TracChangeset for help on using the changeset viewer.