Ignore:
Timestamp:
Feb 13, 2007, 9:40:28 AM (19 years ago)
Author:
bird
Message:

Implemented generic fixups for 32-bit symbol tables.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kLdr/kLdrModMachO.h

    r2962 r2963  
    641641/**
    642642 * The 32-bit Mach-O version of the nlist structure.
    643  * 
    644  * This differs from the a.out nlist struct in that the unused n_other field 
     643 *
     644 * This differs from the a.out nlist struct in that the unused n_other field
    645645 * was renamed to n_sect and used for keeping the relevant section number.
    646646 * @remark  This structure is not name mach_nlist_32 in the Apple headers, but nlist.
     
    648648typedef struct macho_nlist_32
    649649{
    650     union 
     650    union
    651651    {
    652652        int32_t n_strx;         /**< Offset (index) into the string table. 0 means "". */
     
    665665typedef struct macho_nlist_64
    666666{
    667     union 
     667    union
    668668    {
    669669        uint32_t n_strx;        /**< Offset (index) into the string table. 0 means "". */
     
    676676
    677677
    678 /** @name Symbol Type Constants (macho_nlist_32_t::n_type, macho_nlist_64_t::n_type) 
    679  * 
     678/** @name Symbol Type Constants (macho_nlist_32_t::n_type, macho_nlist_64_t::n_type)
     679 *
    680680 * In the Mach-O world n_type is somewhat similar to a.out, meaning N_EXT, N_UNDF, N_ABS
    681681 * and the debug symbols are essentially the same, but the remaining stuff is different.
    682  * The main reason for this is that the encoding of section has been moved to n_sect 
    683  * to permit up to 255 sections instead of the fixed 3 a.out sections (not counting 
     682 * The main reason for this is that the encoding of section has been moved to n_sect
     683 * to permit up to 255 sections instead of the fixed 3 a.out sections (not counting
    684684 * the abs symbols and set vectors).
    685  * 
    686  * To avoid confusion with a.out the Mach-O constants has been fitted with a MACHO_ 
     685 *
     686 * To avoid confusion with a.out the Mach-O constants has been fitted with a MACHO_
    687687 * prefix here.
    688  * 
    689  * Common symbols (aka communal symbols and comdefs) are represented by 
    690  * n_type = MACHO_N_EXT | MACHO_N_UNDF, n_sect = NO_SECT and n_value giving 
     688 *
     689 * Common symbols (aka communal symbols and comdefs) are represented by
     690 * n_type = MACHO_N_EXT | MACHO_N_UNDF, n_sect = NO_SECT and n_value giving
    691691 * the size.
    692  * 
    693  * 
     692 *
     693 *
    694694 * Symbol table entries can be inserted directly in the assembly code using
    695695 * this notation:
     
    697697 *      .stabs "n_name", n_type, n_sect, n_desc, n_value
    698698 * @endcode
    699  * 
     699 *
    700700 * (1) The line number is optional, GCC doesn't set it.
    701701 * (2) The type is optional, GCC doesn't set it.
     
    729729#define MACHO_N_PC      UINT8_C(0x30)   /**< Global pascal symbol.  "name",, NO_SECT, subtype?, line (3) */
    730730    /* omits N_NSYMS, N_NOMAP and N_OBJ. */
    731 #define MACHO_N_OPT     UINT8_C(0x3c)   /**< Options for the debugger related to the language of the 
     731#define MACHO_N_OPT     UINT8_C(0x3c)   /**< Options for the debugger related to the language of the
    732732                                             source file.           "options?",,,, */
    733733#define MACHO_N_RSYM    UINT8_C(0x40)   /**< Register variable.     "name",, NO_SECT, type, register */
     
    758758#define MACHO_N_ECOMM   UINT8_C(0xe4)   /**< End common.            "name",, section, 0, 0 */
    759759#define MACHO_N_ECOML   UINT8_C(0xe8)   /**< End local common.           0,, section, 0, address */
    760 #define MACHO_N_LENG    UINT8_C(0xfe)   /**< Length-value of the preceding entry. 
     760#define MACHO_N_LENG    UINT8_C(0xfe)   /**< Length-value of the preceding entry.
    761761                                                                    "name",, NO_SECT, 0, length */
    762762
    763763/** @} */
    764764
    765 /** @name Symbol Description Bits (macho_nlist_32_t::n_desc, macho_nlist_64_t::n_desc) 
    766  * 
    767  * Mach-O puts the n_desc field to a number of uses, like lazy binding , library 
     765/** @name Symbol Description Bits (macho_nlist_32_t::n_desc, macho_nlist_64_t::n_desc)
     766 *
     767 * Mach-O puts the n_desc field to a number of uses, like lazy binding , library
    768768 * ordinal numbers for -twolevel_namespace, stripping and weak symbol handling.
    769  * 
    770  * @remark The REFERENCE_FLAGS_* are really not flags in the normal sense (bit), 
     769 *
     770 * @remark The REFERENCE_FLAGS_* are really not flags in the normal sense (bit),
    771771 *         they are more like enum values.
    772772 * @{
     
    802802/** Weak external symbol. Symbol can be missing, in which case it's will have the value 0. */
    803803#define N_WEAK_REF                      UINT16_C(0x0040)
    804 /** Weak symbol definition. The symbol can be overridden by another weak 
    805  * symbol already present or by a non-weak (strong) symbol definition. 
    806  * Currently only supported for coalesed symbols. 
     804/** Weak symbol definition. The symbol can be overridden by another weak
     805 * symbol already present or by a non-weak (strong) symbol definition.
     806 * Currently only supported for coalesed symbols.
    807807 * @remark This bit means something differently for undefined symbols, see N_REF_TO_WEAK.
    808808 */
     
    822822/**
    823823 * 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  * 
     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 *
    828828 * @remark  This structure and type has been prefixed with macho_ to avoid
    829829 *          confusion with the original a.out type.
    830830 */
    831 typedef 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 
     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
    835835                                         relocation if set, see scattered_relocation_info_t. */
    836836    uint32_t    r_symbolnum : 24,   /**< r_extern=1: Symbol table index, relocate with the address of this symbol.
     
    845845#define R_ABS           0
    846846
    847 /** Flag in r_address indicating that the relocation is of the 
     847/** Flag in r_address indicating that the relocation is of the
    848848 * scattered_relocation_info_t kind and not macho_relocation_info_t. */
    849849#define R_SCATTERED     UINT32_C(0x80000000)
     
    851851/**
    852852 * Scattered relocation.
    853  * 
    854  * This is a hack mainly for RISC machines which restricts section size 
     853 *
     854 * This is a hack mainly for RISC machines which restricts section size
    855855 * to 16MB among other things.
    856  * 
     856 *
    857857 * 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 
     858 * of the R_SCATTERED mask and the way bitfields are implemented by the
    859859 * C/C++ compilers.
    860860 */
     
    876876# error "Neither KLDR_LITTLE_ENDIAN nor KLDR_BIG_ENDIAN is defined!"
    877877#endif
    878     int32_t     r_value;            /**< The value the fixup is refering to (Without offset added). */
     878    int32_t     r_value;            /**< The value the fixup is refering to (without offset added). */
    879879} scattered_relocation_info_t;
    880880
     
    884884typedef enum reloc_type_generic
    885885{
    886     GENERIC_RELOC_VANILLA = 0,      /**< Standard relocation. */ 
     886    GENERIC_RELOC_VANILLA = 0,      /**< Standard relocation. */
    887887    GENERIC_RELOC_PAIR,             /**< Follows GENERIC_RELOC_SECTDIFF. */
    888888    GENERIC_RELOC_SECTDIFF,         /**< ??? */
Note: See TracChangeset for help on using the changeset viewer.