]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/gdb/i386/machdep.S: Make usable with Apple assembler.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 29 May 2012 11:52:26 +0000 (13:52 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 29 May 2012 11:52:26 +0000 (13:52 +0200)
Binary on other platforms stays identical.

ChangeLog
grub-core/gdb/i386/machdep.S

index d6c8f4a6bb853d82c45dcfe0aa10b3ba68e6159a..93a4da5d6053fe03da71fc1c8968ffa880b51fee 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-29  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/gdb/i386/machdep.S: Make usable with Apple assembler.
+       Binary on other platforms stays identical.
+
 2012-05-28  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * configure.ac: Remove APPLE_CC and add -Wl,-allow_stack_execute on
index 24edd0f2c7449aa8aeef1d32b213d2574cde10f3..1615b0c9fe98b824d0adf86e6f09d1af6bdc5a48 100644 (file)
 
 #define GRUB_GDB_STACKSIZE     40000
 
+#define SEP ,
+
+#ifdef __APPLE__
+       .zerofill __DATA, __bss, LOCAL(grub_gdb_stack_end), GRUB_GDB_STACKSIZE, 4
+       LOCAL(grub_gdb_stack) = LOCAL(grub_gdb_stack_end)
+#else
 /*
  * The .data index for the address vector.
  */
        .bss
        .space GRUB_GDB_STACKSIZE
 VARIABLE(grub_gdb_stack)
+#endif
 
 /*
  * Supplemental macros for register saving/restoration
  * on exception handler entry/leave.
  */
 
+#ifdef __APPLE__
+.macro save32
+#define REG $0
+#define NDX $1
+#else
 .macro save32 reg ndx
-       movl \reg, EXT_C(grub_gdb_regs)+(\ndx * 4)
+#define REG \reg
+#define NDX \ndx
+#endif
+       movl REG, EXT_C(grub_gdb_regs)+(NDX * 4)
 .endm
 
+#undef REG
+#undef NDX
+
+#ifdef __APPLE__
+.macro save16
+#define REG $0
+#define NDX $1
+#else
 .macro save16 reg ndx
-       mov $0, %eax
-       movw \reg, EXT_C(grub_gdb_regs)+(\ndx * 4)
-       movw %ax, EXT_C(grub_gdb_regs)+(\ndx * 4 + 2)
+#define REG \reg
+#define NDX \ndx
+#endif
+#ifdef __APPLE__
+       xorl %eax, %eax
+#else
+       movl $0, %eax
+#endif
+       movw REG, EXT_C(grub_gdb_regs)+(NDX * 4)
+       movw %ax, EXT_C(grub_gdb_regs)+(NDX * 4 + 2)
        movl EXT_C(grub_gdb_regs)+(EAX * 4), %eax
 .endm
 
+#undef REG
+#undef NDX
+
+#ifdef __APPLE__
+.macro load32
+#define NDX $0
+#define REG $1
+#else
 .macro load32 ndx reg
-       movl EXT_C(grub_gdb_regs)+(\ndx * 4), \reg
+#define REG \reg
+#define NDX \ndx
+#endif
+       movl EXT_C(grub_gdb_regs)+(NDX * 4), REG
 .endm
 
-.macro load16 ndx reg
-       movw EXT_C(grub_gdb_regs)+(\ndx * 4), \reg
+#undef REG
+#undef NDX
+
+#ifdef __APPLE__
+.macro load16
+#define NDX $0
+#define REG $1
+#else
+.macro load16 ndx reg 
+#define NDX \ndx
+#define REG \reg
+#endif
+       movw EXT_C(grub_gdb_regs)+(NDX * 4), REG
 .endm
 
+#undef REG
+#undef NDX
+
 .macro save_context
-       save32 %eax EAX
-       save32 %ecx ECX
-       save32 %edx EDX
-       save32 %ebx EBX
-       save32 %ebp EBP
-       save32 %esi ESI
-       save32 %edi EDI
+       save32 %eax, EAX
+
+       save32 %ecx, ECX
+       save32 %edx, EDX
+       save32 %ebx, EBX
+       save32 %ebp, EBP
+       save32 %esi, ESI
+       save32 %edi, EDI
 
        popl %ebx
-       save32 %ebx EIP
+       save32 %ebx, EIP
        popl %ebx
-       save32 %ebx CS
+       save32 %ebx, CS
        popl %ebx
-       save32 %ebx EFLAGS
+       save32 %ebx, EFLAGS
 
-       save32 %esp ESP
+       save32 %esp, ESP
 
-       save16 %ds DS
-       save16 %es ES
-       save16 %fs FS
-       save16 %gs GS
-       save16 %ss SS
+       save16 %ds, DS
+       save16 %es, ES
+       save16 %fs, FS
+       save16 %gs, GS
+       save16 %ss, SS
 .endm
 
 .macro load_context
-       load16 SS %ss
-       load32 ESP %esp
+       load16 SS, %ss
+       load32 ESP, %esp
 
-       load32 EBP %ebp
-       load32 ESI %esi
-       load32 EDI %edi
+       load32 EBP, %ebp
+       load32 ESI, %esi
+       load32 EDI, %edi
 
-       load16 DS %ds
-       load16 ES %es
-       load16 FS %fs
-       load16 GS %gs
+       load16 DS, %ds
+       load16 ES, %es
+       load16 FS, %fs
+       load16 GS, %gs
 
-       load32 EFLAGS %eax
+       load32 EFLAGS, %eax
        pushl %eax
-       load32 CS %eax
+       load32 CS, %eax
        pushl %eax
-       load32 EIP %eax
+       load32 EIP, %eax
        pushl %eax
 
-       load32 EBX %ebx
-       load32 EDX %edx
-       load32 ECX %ecx
-       load32 EAX %eax
+       load32 EBX, %ebx
+       load32 EDX, %edx
+       load32 ECX, %ecx
+       load32 EAX, %eax
 .endm
 
 /*
@@ -115,7 +171,17 @@ VARIABLE(grub_gdb_stack)
  * and adds their addresses to the grub_gdb_trapvec array.
  */
 
+#ifdef __APPLE__
+.macro ent
+#define EC $0
+#define BEG $1
+#define END $2
+#else
 .macro ent ec beg end=0
+#define EC \ec
+#define BEG \beg
+#define END \end
+#endif
 
        /*
         * Wrapper body itself.
@@ -123,13 +189,21 @@ VARIABLE(grub_gdb_stack)
 
        .text
 1:     
-       .if \ec
-               add $4,%esp
+       .if EC
+#ifdef __APPLE__
+               add $$4, %esp
+#else
+               add $4, %esp
+#endif
        .endif
 
        save_context
+#ifdef __APPLE__
+       mov     $LOCAL(grub_gdb_stack), %esp
+#else
        mov     $EXT_C(grub_gdb_stack), %esp
-       mov     $\beg, %eax     /* trap number */
+#endif
+       mov     $(BEG), %eax    /* trap number */
        call    EXT_C(grub_gdb_trap)
        load_context
        iret
@@ -138,15 +212,23 @@ VARIABLE(grub_gdb_stack)
         * Address entry in trapvec array.
         */
 
-       .data VECTOR
+#ifdef __APPLE__
+       .section __DATA, VECTOR
+#else
+       .data VECTOR
+#endif
        .long 1b
 
        /*
         * Next... (recursion).
         */
 
-       .if \end-\beg > 0
+       .if END-BEG > 0
+#ifdef __APPLE__
+               ent EC, (BEG+1), END
+#else
                ent \ec "(\beg+1)" \end
+#endif
        .endif
 .endm
 
@@ -154,16 +236,18 @@ VARIABLE(grub_gdb_stack)
  * Here does the actual construction of the address array and handlers
  * take place.
  */
-
-       .data VECTOR
-
+#ifdef __APPLE__
+       .section __DATA, VECTOR
+#else
+       .data VECTOR
+#endif
 VARIABLE(grub_gdb_trapvec)
-       ent EC_ABSENT   0 7
-       ent EC_PRESENT  8
-       ent EC_ABSENT   9
-       ent EC_PRESENT  10 14
+       ent EC_ABSENT,  0, 7
+       ent EC_PRESENT, 8
+       ent EC_ABSENT,  9
+       ent EC_PRESENT, 10, 14
        /*
         * You may have to split this further or as(1)
         * will complain about nesting being too deep.
         */
-       ent EC_ABSENT   15 GRUB_GDB_LAST_TRAP
+       ent EC_ABSENT,  15, GRUB_GDB_LAST_TRAP