Changeset 2958 for trunk


Ignore:
Timestamp:
Feb 9, 2007, 6:12:22 AM (19 years ago)
Author:
bird
Message:

Relocations (generic only - x86 is generic).

Location:
trunk/kLdr
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/kLdr/kLdr.h

    r2956 r2958  
    541541    KLDRENDIAN_32BIT_HACK = 0x7fffffff
    542542} KLDRENDIAN;
     543
     544
     545/** @def KLDR_LITTLE_ENDIAN
     546 * The kLdr build is for a little endian target. */
     547/** @def KLDR_BIG_ENDIAN
     548 * The kLdr build is for a big endian target. */
     549#if !defined(KLDR_LITTLE_ENDIAN) && !defined(KLDR_BIG_ENDIAN)
     550# define KLDR_LITTLE_ENDIAN
     551#endif
     552#ifdef __DOXYGEN__
     553# define KLDR_BIG_ENDIAN
     554#endif
    543555
    544556
  • trunk/kLdr/kLdrHlp.h

    r2955 r2958  
    8686/** @def KLDRHLP_BE2H_U64
    8787 * Unsigned 64-bit big-endian to host endian. */
    88 #if 1
     88#ifdef KLDR_LITTLE_ENDIAN
    8989# define KLDRHLP_LE2H_U16(u16)  ((uint16_t)(u16))
    9090# define KLDRHLP_LE2H_U32(u32)  ((uint32_t)(u32))
     
    9393# define KLDRHLP_BE2H_U32(u32)  KLDRHLP_E2E_U32(u32)
    9494# define KLDRHLP_BE2H_U64(u64)  KLDRHLP_E2E_U64(u64)
    95 #else
     95#elif defined(KLDR_BIG_ENDIAN)
    9696# define KLDRHLP_LE2H_U16(u16)  KLDRHLP_E2E_U16(u16)
    9797# define KLDRHLP_LE2H_U32(u32)  KLDRHLP_E2E_U32(u32)
     
    100100# define KLDRHLP_BE2H_U32(u32)  ((uint32_t)(u32))
    101101# define KLDRHLP_BE2H_U64(u64)  ((uint32_t)(u32))
     102#else
     103# error "KLDR_BIG_ENDIAN or KLDR_LITTLE_ENDIAN is supposed to be defined."
    102104#endif
    103105
  • trunk/kLdr/kLdrModMachO.h

    r2957 r2958  
    66#ifndef __kLdrModMachO_h__
    77#define __kLdrModMachO_h__
     8
     9/** @defgroup grp_mach_o    The Mach-O Structures, Types, and Defines.
     10 * @{
     11 */
    812
    913
     
    273277/** @} */
    274278
     279
     280
     281/** @defgroup grp_macho_o_lc        Load Commands
     282 * @{ */
    275283
    276284/**
     
    624632/** @todo fvmfile_command (LC_FVMFILE) */
    625633
    626 
    627 
    628 
    629 
     634/** @} */
     635
     636
     637
     638/** @defgroup grp_macho_o_syms  Symbol Table
     639 * @{ */
    630640
    631641/**
     
    804814/** @} */
    805815
     816/** @} */
     817
     818
     819/** @defgroup grp_macho_o_relocs    Relocations
     820 * @{ */
     821
     822/**
     823 * Relocation entry.
     824 *
     825 * Differs from a.out in the meaning of r_symbolnum when r_extern=0 and
     826 * that r_pad is made into r_type.
     827 *
     828 * @remark  This structure and type has been prefixed with macho_ to avoid
     829 *          confusion with the original a.out type.
     830 */
     831typedef struct macho_relocation_info
     832{
     833    int32_t     r_address;          /**< Section relative address of the fixup.
     834                                         The top bit (signed) indicates that this is a scattered
     835                                         relocation if set, see scattered_relocation_info_t. */
     836    uint32_t    r_symbolnum : 24,   /**< r_extern=1: Symbol table index, relocate with the address of this symbol.
     837                                         r_extern=0: Section ordinal, relocate with the address of this section. */
     838                r_pcrel : 1,        /**< PC (program counter) relative fixup; subtract the fixup address. */
     839                r_length : 2,       /**< Fixup length: 0=uint8_t, 1=uint16_t, 2=uint32_t, 3=uint64_t. */
     840                r_extern : 1,       /**< External or internal fixup, decides the r_symbolnum interpretation.. */
     841                r_type : 4;         /**< Relocation type; 0 is standard, non-zero are machine specific. */
     842} macho_relocation_info_t;
     843
     844/** Special section ordinal value for absolute relocations. */
     845#define R_ABS           0
     846
     847/** Flag in r_address indicating that the relocation is of the
     848 * scattered_relocation_info_t kind and not macho_relocation_info_t. */
     849#define R_SCATTERED     UINT32_C(0x80000000)
     850
     851/**
     852 * Scattered relocation.
     853 *
     854 * This is a hack mainly for RISC machines which restricts section size
     855 * to 16MB among other things.
     856 *
     857 * The reason for the big/little endian differences here is of course because
     858 * of the R_SCATTERED mask and the way bitfields are implemented by the
     859 * C/C++ compilers.
     860 */
     861typedef struct scattered_relocation_info
     862{
     863#ifdef KLDR_LITTLE_ENDIAN
     864    uint32_t    r_address : 24,     /**< Section relative address of the fixup. (macho_relocation_info_t::r_address) */
     865                r_type : 4,         /**< Relocation type; 0 is standard, non-zero are machine specific. (macho_relocation_info_t::r_type) */
     866                r_length : 2,       /**< Fixup length: 0=uint8_t, 1=uint16_t, 2=uint32_t, 3=uint64_t. (macho_relocation_info_t::r_length) */
     867                r_pcrel : 1,        /**< PC (program counter) relative fixup; subtract the fixup address. (macho_relocation_info_t::r_pcrel) */
     868                r_scattered : 1;    /**< Set if scattered relocation, clear if normal relocation. */
     869#elif defined(KLDR_BIG_ENDIAN)
     870    uint32_t    r_scattered : 1,    /**< Set if scattered relocation, clear if normal relocation. */
     871                r_pcrel : 1,        /**< PC (program counter) relative fixup; subtract the fixup address. (macho_relocation_info_t::r_pcrel) */
     872                r_length : 2,       /**< Fixup length: 0=uint8_t, 1=uint16_t, 2=uint32_t, 3=uint64_t. (macho_relocation_info_t::r_length) */
     873                r_type : 4,         /**< Relocation type; 0 is standard, non-zero are machine specific. (macho_relocation_info_t::r_type) */
     874                r_address : 24;     /**< Section relative address of the fixup. (macho_relocation_info_t::r_address) */
     875#else
     876# error "Neither KLDR_LITTLE_ENDIAN nor KLDR_BIG_ENDIAN is defined!"
    806877#endif
    807 
     878    int32_t     r_value;            /**< The value the fixup is refering to (Without offset added). */
     879} scattered_relocation_info_t;
     880
     881/**
     882 * Relocation type values for a generic implementation (for r_type).
     883 */
     884typedef enum reloc_type_generic
     885{
     886    GENERIC_RELOC_VANILLA = 0,      /**< Standard relocation. */
     887    GENERIC_RELOC_PAIR,             /**< Follows GENERIC_RELOC_SECTDIFF. */
     888    GENERIC_RELOC_SECTDIFF,         /**< ??? */
     889    GENERIC_RELOC_PB_LA_PTR,        /**< Prebound lazy pointer whatever that. */
     890    GENERIC_RELOC_LOCAL_SECTDIFF    /**< ??? */
     891} reloc_type_generic_t;
     892
     893/** @} */
     894
     895
     896/** @} */
     897#endif
     898
Note: See TracChangeset for help on using the changeset viewer.