Changeset 63


Ignore:
Timestamp:
Oct 30, 2013, 3:00:14 AM (12 years ago)
Author:
bird
Message:

kLdrModMachO.c: Workaround for misaligned TEXT.unwind_info found once in VirtualBox.dylib (Xcode 3.2.6, I think). DYLIB debug info loading adjustments.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/k/kLdrFmts/mach-o.h

    r56 r63  
    500500 */
    501501/** Section type mask. */
    502 #define SECTION_TYPE                KU32_C(0x000000ff)
     502#define SECTION_TYPE                    KU32_C(0x000000ff)
    503503/** Regular section. */
    504 #define S_REGULAR                   0x0
     504#define S_REGULAR                       0x00
    505505/** Zero filled section. */
    506 #define S_ZEROFILL                  0x1
     506#define S_ZEROFILL                      0x01
    507507/** C literals. */
    508 #define S_CSTRING_LITERALS          0x2
     508#define S_CSTRING_LITERALS              0x02
    509509/** 4 byte literals. */
    510 #define S_4BYTE_LITERALS            0x3
     510#define S_4BYTE_LITERALS                0x03
    511511/** 8 byte literals. */
    512 #define S_8BYTE_LITERALS            0x4
     512#define S_8BYTE_LITERALS                0x04
    513513/** Pointer to literals. */
    514 #define S_LITERAL_POINTERS          0x5
     514#define S_LITERAL_POINTERS              0x05
    515515/** Section containing non-lazy symbol pointers.
    516516 * Reserved1 == start index in the indirect symbol table. */
    517 #define S_NON_LAZY_SYMBOL_POINTERS  0x6
     517#define S_NON_LAZY_SYMBOL_POINTERS      0x06
    518518/** Section containing lazy symbol pointers.
    519519 * Reserved1 == start index in the indirect symbol table. */
    520 #define S_LAZY_SYMBOL_POINTERS      0x7
     520#define S_LAZY_SYMBOL_POINTERS          0x07
    521521/** Section containing symbol stubs.
    522522 * Reserved2 == stub size. */
    523 #define S_SYMBOL_STUBS              0x8
     523#define S_SYMBOL_STUBS                  0x08
    524524/** Section containing function pointers for module initialization. . */
    525 #define S_MOD_INIT_FUNC_POINTERS    0x9
     525#define S_MOD_INIT_FUNC_POINTERS        0x09
    526526/** Section containing function pointers for module termination. . */
    527 #define S_MOD_TERM_FUNC_POINTERS    0xa
     527#define S_MOD_TERM_FUNC_POINTERS        0x0a
    528528/** Section containing symbols that are to be coalesced. */
    529 #define S_COALESCED                 0xb
     529#define S_COALESCED                     0x0b
    530530/** Zero filled section that be larger than 4GB. */
    531 #define S_GB_ZEROFILL               0xc
     531#define S_GB_ZEROFILL                   0x0c
    532532/** Section containing pairs of function pointers for interposing. */
    533 #define S_INTERPOSING               0xd
     533#define S_INTERPOSING                   0x0d
    534534/** 16 byte literals. */
    535 #define S_16BYTE_LITERALS           0xe
     535#define S_16BYTE_LITERALS               0x0e
     536/** DTrace byte code / definitions (DOF = DTrace object format). */
     537#define S_DTRACE_DOF                    0x0f
     538/** Section containing pointers to symbols in lazily loaded dylibs. */
     539#define S_LAZY_DYLIB_SYMBOL_POINTERS    0x10
    536540
    537541/** Section attribute mask. */
  • trunk/kLdr/kLdrModMachO.c

    r62 r63  
    739739                            case S_NON_LAZY_SYMBOL_POINTERS: \
    740740                            case S_LAZY_SYMBOL_POINTERS: \
     741                            case S_LAZY_DYLIB_SYMBOL_POINTERS: \
    741742                                /* (reserved 1 = is indirect symbol table index) */ \
    742743                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved2, KLDR_ERR_MACHO_BAD_SECTION); \
     
    759760                            \
    760761                            case S_LITERAL_POINTERS: \
     762                            case S_DTRACE_DOF: \
     763                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved1, KLDR_ERR_MACHO_BAD_SECTION); \
     764                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved2, KLDR_ERR_MACHO_BAD_SECTION); \
     765                                fFileBits = 1; \
     766                                break; \
     767                            \
    761768                            case S_INTERPOSING: \
    762769                            case S_GB_ZEROFILL: \
     
    780787                        KLDRMODMACHO_CHECK_RETURN(pSect->align < 31, \
    781788                                                  KLDR_ERR_MACHO_BAD_SECTION); \
     789                        /* Workaround for buggy ld64 (or as, llvm, ++) that produces a misaligned __TEXT.__unwind_info. */ \
     790                        /* Seen: pSect->align = 4, pSect->addr = 0x5ebe14.  Just adjust the alignment down. */ \
     791                        if (   ((K_BIT32(pSect->align) - KU32_C(1)) & pSect->addr) \
     792                            && pSect->align == 4 \
     793                            && kHlpStrComp(pSect->sectname, "__unwind_info") == 0) \
     794                            pSect->align = 2; \
    782795                        KLDRMODMACHO_CHECK_RETURN(!((K_BIT32(pSect->align) - KU32_C(1)) & pSect->addr), \
    783796                                                  KLDR_ERR_MACHO_BAD_SECTION); \
     
    10251038                if (!(fOpenFlags & KLDRMOD_OPEN_FLAGS_FOR_INFO))
    10261039                    KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_UNSUPPORTED_LOAD_COMMAND);
     1040                *pfCanLoad = K_FALSE;
    10271041                break;
    10281042
Note: See TracChangeset for help on using the changeset viewer.