[AD] [patch] preliminary PIC support in ASM files |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Here is the first part of my big PIC mode fixes for the
assembly functions. This patch is split in two: the first is for
src/i386/asmdefs.inc and defines convenience macros to handle global
symbols in PI code, and the second starts the big work of modifying code
that accesses global variables so that it uses the GOT and PLT in PIC
mode.
These patches change absolutely nothing to platforms not using PIC
code (like Win32 or DOS). I will apply them to the Debian packages
because policy requires shared libraries to be PIC.
Comments, fixes, and help appreciated!
Regards,
--
Sam.
Index: src/i386/asmdefs.inc
===================================================================
RCS file: /cvsroot/alleg/allegro/src/i386/asmdefs.inc,v
retrieving revision 1.9
diff -u -r1.9 asmdefs.inc
--- src/i386/asmdefs.inc 6 Nov 2001 17:16:40 -0000 1.9
+++ src/i386/asmdefs.inc 23 Sep 2004 15:09:25 -0000
@@ -97,6 +97,81 @@
#define IRQ_STACKS 8
+/* Special helper functions that retrieve the GOT address. They are declared
+ * in their own special section so that GCC knows they should only be linked
+ * once, so as to not bloat the binaries.
+ */
+#ifdef __PIC__
+#define DECLARE_LINKONCE(reg) \
+ .section .gnu.linkonce.t.__i686.get_pc_thunk.reg,"ax",@progbits ; \
+ .globl __i686.get_pc_thunk.reg ; \
+ .hidden __i686.get_pc_thunk.reg ; \
+ .type __i686.get_pc_thunk.reg, @function ; \
+ __i686.get_pc_thunk.reg: ; \
+ movl (%esp), %e##reg ; \
+ ret
+
+DECLARE_LINKONCE(ax)
+DECLARE_LINKONCE(bx)
+DECLARE_LINKONCE(cx)
+DECLARE_LINKONCE(dx)
+DECLARE_LINKONCE(si)
+DECLARE_LINKONCE(di)
+DECLARE_LINKONCE(bp)
+
+#define get_pc_thunk_eax __i686.get_pc_thunk.ax
+#define get_pc_thunk_ebx __i686.get_pc_thunk.bx
+#define get_pc_thunk_ecx __i686.get_pc_thunk.cx
+#define get_pc_thunk_edx __i686.get_pc_thunk.dx
+#define get_pc_thunk_esi __i686.get_pc_thunk.si
+#define get_pc_thunk_edi __i686.get_pc_thunk.di
+#define get_pc_thunk_ebp __i686.get_pc_thunk.bp
+#endif /* __PIC__ */
+
+/* Macro that retrieves the GOT address when compiling PIC.
+ */
+#ifdef __PIC__
+#define GET_GOT(reg) \
+ call get_pc_thunk_##reg ; \
+ addl $_GLOBAL_OFFSET_TABLE_, %reg
+#endif
+
+/* Macros to load a global into a given register, push a global onto the
+ * stack, or call a global function pointer. tmp should be the name of a
+ * spare register (eax, ebx, ecx, edx, esi or edi). This spare register is
+ * only used when compiling PIC.
+ * These operations are slow, so you should not use them within a critical
+ * loop.
+ */
+#ifdef __PIC__
+#define MOVL_GLOBL(glob, reg) \
+ GET_GOT(reg) ; \
+ movl GLOBL(glob)@GOT(%reg), %reg ; \
+ movl (%reg), %reg
+
+#define PUSHL_GLOBL(glob, tmp) \
+ GET_GOT(tmp) ; \
+ movl GLOBL(glob)@GOT(%tmp), %tmp ; \
+ pushl (%tmp)
+
+#define CALL_PTR_GLOBL(glob, tmp) \
+ GET_GOT(tmp) ; \
+ movl GLOBL(glob)@GOT(%tmp), %tmp ; \
+ movl (%tmp), %tmp ; \
+ call *%tmp
+
+#else
+#define MOVL_GLOBL(glob, reg) \
+ movl GLOBL(glob), %reg
+
+#define PUSHL_GLOBL(glob, tmp) \
+ pushl GLOBL(glob)
+
+#define CALL_PTR_GLOBL(glob, tmp) \
+ call *GLOBL(glob)
+
+#endif /* __PIC__ */
+
#endif /* ifndef ASMDEFS_INC */
Index: src/i386/iblit16.s
===================================================================
RCS file: /cvsroot/alleg/allegro/src/i386/iblit16.s,v
retrieving revision 1.13
diff -u -r1.13 iblit16.s
--- src/i386/iblit16.s 16 Jul 2003 19:43:28 -0000 1.13
+++ src/i386/iblit16.s 23 Sep 2004 15:09:26 -0000
@@ -50,7 +50,7 @@
#ifdef ALLEGRO_MMX /* only use MMX if compiler supports it */
- movl GLOBL(cpu_capabilities), %eax /* if MMX is enabled (or not disabled :) */
+ MOVL_GLOBL(cpu_capabilities, eax) /* if MMX is enabled (or not disabled :) */
andl $CPU_MMX, %eax
jz clear_no_mmx
@@ -315,7 +315,7 @@
#ifdef ALLEGRO_MMX /* only use MMX if the compiler supports it */
- movl GLOBL(cpu_capabilities), %eax /* if MMX is enabled (or not disabled :) */
+ MOVL_GLOBL(cpu_capabilities, eax) /* if MMX is enabled (or not disabled :) */
andl $CPU_MMX, %eax
jz blit_no_mmx
@@ -566,7 +566,7 @@
#ifdef ALLEGRO_SSE /* Use SSE if the compiler supports it */
/* Speed improvement on the Pentium 3 only, so we need to check for MMX+ and no 3DNow! */
- movl GLOBL(cpu_capabilities), %ecx /* if MMX+ is enabled (or not disabled :) */
+ MOVL_GLOBL(cpu_capabilities, ecx) /* if MMX+ is enabled (or not disabled :) */
andl $CPU_MMXPLUS | $CPU_3DNOW, %ecx
cmpl $CPU_MMXPLUS, %ecx
jne masked16_no_mmx
Index: src/i386/imisc.s
===================================================================
RCS file: /cvsroot/alleg/allegro/src/i386/imisc.s,v
retrieving revision 1.3
diff -u -r1.3 imisc.s
--- src/i386/imisc.s 5 Jul 2002 10:23:47 -0000 1.3
+++ src/i386/imisc.s 23 Sep 2004 15:09:26 -0000
@@ -488,7 +488,15 @@
shrl %cl, %eax /* shift x to fall into range 0..255 */
/* table lookup... */
+#ifdef __PIC__
+ pushl %ebx
+ GET_GOT(ebx)
+ movl GLOBL(_sqrt_table)@GOT(%ebx), %ebx
+ movzwl (%ebx,%eax,2), %eax
+ popl %ebx
+#else
movzwl GLOBL(_sqrt_table)(,%eax,2), %eax
+#endif
shrb $1, %cl /* %cl = n */
shll %cl, %eax /* multiply `sqrt(x/2^(2n))' by `2^n' */
@@ -499,7 +507,7 @@
sqrt_error_check: /* here we go if x<=0 */
jz sqrt_done /* if zero, return eax=0 */
- movl GLOBL(allegro_errno), %edx
+ MOVL_GLOBL(allegro_errno, edx)
movl $ERANGE, (%edx) /* on overflow, set errno */
xorl %eax, %eax /* return zero */
@@ -564,7 +572,15 @@
shrdl %cl, %edx, %eax /* make eax fall into range 0..255 */
shrl $24, %eax
/* eax = table lookup square root */
+#ifdef __PIC__
+ pushl %ebx
+ GET_GOT(ebx)
+ movl GLOBL(_sqrt_table)@GOT(%ebx), %ebx
+ movzwl (%ebx,%eax,2), %eax
+ popl %ebx
+#else
movzwl GLOBL(_sqrt_table)(,%eax,2), %eax
+#endif
shrb $1, %cl /* adjust result... */
shll %cl, %eax
jmp hypot_done
@@ -582,7 +598,15 @@
andb $0xFE, %cl /* make cl=2n even */
shrl %cl, %eax /* make eax fall into range 0..255 */
/* eax = table lookup square root */
+#ifdef __PIC__
+ pushl %ebx
+ GET_GOT(ebx)
+ movl GLOBL(_sqrt_table)@GOT(%ebx), %ebx
+ movzwl (%ebx,%eax,2), %eax
+ popl %ebx
+#else
movzwl GLOBL(_sqrt_table)(,%eax,2), %eax
+#endif
shrb $1, %cl /* cl = n */
shll %cl, %eax /* adjust result... */
shrl $4, %eax
@@ -590,7 +614,7 @@
_align_
hypot_overflow: /* overflow */
- movl GLOBL(allegro_errno), %eax
+ MOVL_GLOBL(allegro_errno, eax)
movl $ERANGE, (%eax) /* set errno */
movl $0x7FFFFFFF, %eax /* and return MAXINT */
Index: src/i386/ispr16.s
===================================================================
RCS file: /cvsroot/alleg/allegro/src/i386/ispr16.s,v
retrieving revision 1.3
diff -u -r1.3 ispr16.s
--- src/i386/ispr16.s 2 Oct 2002 18:29:57 -0000 1.3
+++ src/i386/ispr16.s 23 Sep 2004 15:09:26 -0000
@@ -177,7 +177,7 @@
pushl %edx /* get color expansion lookup table */
movl BMP_VTABLE(%edx), %edx
pushl VTABLE_COLOR_DEPTH(%edx)
- call *GLOBL(_palette_expansion_table)
+ CALL_PTR_GLOBL(_palette_expansion_table, edx)
addl $4, %esp
popl %edx
movl %eax, %edi
@@ -382,10 +382,10 @@
cmpw $MASK_COLOR_16, %ax
jz trans_sprite_skip
movw %es:(%ebx, %edi), %dx /* read memory pixel */
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, ecx)
pushl %edx
pushl %eax
- call *GLOBL(_blender_func16) /* blend */
+ CALL_PTR_GLOBL(_blender_func16, ecx) /* blend */
addl $12, %esp
movw %ax, %es:(%ebx) /* write the result */
trans_sprite_skip:
@@ -433,10 +433,10 @@
cmpl $MASK_COLOR_32, %eax
jz trans_rgba_sprite_skip
movw %es:(%ebx, %edi), %dx /* read memory pixel */
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, ecx)
pushl %edx
pushl %eax
- call *GLOBL(_blender_func16x) /* blend */
+ CALL_PTR_GLOBL(_blender_func16x, ecx) /* blend */
addl $12, %esp
movw %ax, %es:(%ebx) /* write the result */
trans_rgba_sprite_skip:
@@ -489,8 +489,8 @@
jz lit_sprite_skip
pushl %edi
pushl %eax
- pushl GLOBL(_blender_col_16)
- call *GLOBL(_blender_func16) /* blend */
+ PUSHL_GLOBL(_blender_col_16, eax)
+ CALL_PTR_GLOBL(_blender_func16, eax) /* blend */
addl $12, %esp
movw %ax, %es:(%ebx) /* write pixel */
lit_sprite_skip:
@@ -672,10 +672,10 @@
; \
trans_rle_clipped_run_loop##n: ; \
movl R_TMP, %edx ; \
- pushl GLOBL(_blender_alpha) ; \
+ PUSHL_GLOBL(_blender_alpha, ebx) ; \
pushl %es:(%edi, %edx) /* read memory pixel */ ; \
pushl (%esi) /* read sprite pixel */ ; \
- call *GLOBL(_blender_func16) /* blend */ ; \
+ CALL_PTR_GLOBL(_blender_func16, ebx) /* blend */ ; \
addl $12, %esp ; \
movw %ax, %es:(%edi) /* write the pixel */ ; \
addl $2, %esi ; \
@@ -696,10 +696,10 @@
; \
trans_rle_run_loop: ; \
movl R_TMP, %edx ; \
- pushl GLOBL(_blender_alpha) ; \
+ PUSHL_GLOBL(_blender_alpha, ebx) ; \
pushl %es:(%edi, %edx) /* read memory pixel */ ; \
pushl (%esi) /* read sprite pixel */ ; \
- call *GLOBL(_blender_func16) /* blend */ ; \
+ CALL_PTR_GLOBL(_blender_func16, ebx) /* blend */ ; \
addl $12, %esp ; \
movw %ax, %es:(%edi) /* write the pixel */ ; \
addl $2, %esi ; \
@@ -744,8 +744,8 @@
lit_rle_clipped_run_loop##n: ; \
pushl %ebx ; \
pushl (%esi) /* read sprite pixel */ ; \
- pushl GLOBL(_blender_col_16) ; \
- call *GLOBL(_blender_func16) /* blend */ ; \
+ PUSHL_GLOBL(_blender_col_16, ebx) ; \
+ CALL_PTR_GLOBL(_blender_func16, ebx) /* blend */ ; \
addl $12, %esp ; \
movw %ax, %es:(%edi) /* write the pixel */ ; \
addl $2, %esi ; \
@@ -768,8 +768,8 @@
lit_rle_run_loop: ; \
pushl %ebx ; \
pushl (%esi) /* read sprite pixel */ ; \
- pushl GLOBL(_blender_col_16) ; \
- call *GLOBL(_blender_func16) /* blend */ ; \
+ PUSHL_GLOBL(_blender_col_16, ebx) ; \
+ CALL_PTR_GLOBL(_blender_func16, ebx) /* blend */ ; \
addl $12, %esp ; \
movw %ax, %es:(%edi) /* write the pixel */ ; \
addl $2, %esi ; \
@@ -821,10 +821,10 @@
; \
trans_rgba_rle_clipped_run_loop##n: ; \
movl R_TMP, %edx ; \
- pushl GLOBL(_blender_alpha) ; \
+ PUSHL_GLOBL(_blender_alpha, ebx) ; \
pushl %es:(%edi, %edx) /* read memory pixel */ ; \
pushl (%esi) /* read sprite pixel */ ; \
- call *GLOBL(_blender_func16x) /* blend */ ; \
+ CALL_PTR_GLOBL(_blender_func16x, ebx) /* blend */ ; \
addl $12, %esp ; \
movw %ax, %es:(%edi) /* write the pixel */ ; \
addl $4, %esi ; \
@@ -845,10 +845,10 @@
; \
trans_rgba_rle_run_loop: ; \
movl R_TMP, %edx ; \
- pushl GLOBL(_blender_alpha) ; \
+ PUSHL_GLOBL(_blender_alpha, ebx) ; \
pushl %es:(%edi, %edx) /* read memory pixel */ ; \
pushl (%esi) /* read sprite pixel */ ; \
- call *GLOBL(_blender_func16x) /* blend */ ; \
+ CALL_PTR_GLOBL(_blender_func16x, ebx) /* blend */ ; \
addl $12, %esp ; \
movw %ax, %es:(%edi) /* write the pixel */ ; \
addl $4, %esi ; \
Index: src/i386/izbuf.s
===================================================================
RCS file: /cvsroot/alleg/allegro/src/i386/izbuf.s,v
retrieving revision 1.8
diff -u -r1.8 izbuf.s
--- src/i386/izbuf.s 8 Apr 2004 19:26:20 -0000 1.8
+++ src/i386/izbuf.s 23 Sep 2004 15:09:29 -0000
@@ -253,7 +253,7 @@
shrl $19, %eax /* blue */
orl %eax, %esi /* blue */
- movl GLOBL(rgb_map), %eax /* table lookup */
+ MOVL_GLOBL(rgb_map, eax) /* table lookup */
movb (%eax, %esi), %al
movb %al, FSEG(%edi) /* write the pixel */
@@ -318,6 +318,37 @@
andb $0x41, %ah ; \
jnz 2f ; \
; \
+ DO_GRGB(depth, r_sft, g_sft, b_sft) ; \
+ movl ADDR, %esi
+
+#ifdef __PIC__
+#define DO_GRGB(depth, r_sft, g_sft, b_sft) \
+ movl %ebx, %eax /* red */ ; \
+ pushl %ebx ; \
+ pushl %edx ; \
+ call __i686.get_pc_thunk.bx ; \
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx ; \
+ movl GLOBL(_rgb_r_shift_##depth)@GOT(%ebx), %edx ; \
+ movb (%edx), %cl ; \
+ shrl $r_sft, %eax ; \
+ shll %cl, %eax ; \
+ movl %edi, %esi /* green */ ; \
+ movl GLOBL(_rgb_g_shift_##depth)@GOT(%ebx), %edx ; \
+ movb (%edx), %cl ; \
+ shrl $g_sft, %esi ; \
+ shll %cl, %esi ; \
+ orl %esi, %eax ; \
+ movl GLOBL(_rgb_b_shift_##depth)@GOT(%ebx), %edx ; \
+ movb (%edx), %cl ; \
+ popl %edx ; \
+ movl %edx, %esi /* blue */ ; \
+ shrl $b_sft, %esi ; \
+ shll %cl, %esi ; \
+ orl %esi, %eax ; \
+ popl %ebx
+
+#else
+#define DO_GRGB(depth, r_sft, g_sft, b_sft) \
movl %ebx, %eax /* red */ ; \
movb GLOBL(_rgb_r_shift_##depth), %cl ; \
shrl $r_sft, %eax ; \
@@ -331,8 +362,9 @@
movb GLOBL(_rgb_b_shift_##depth), %cl ; \
shrl $b_sft, %esi ; \
shll %cl, %esi ; \
- orl %esi, %eax ; \
- movl ADDR, %esi
+ orl %esi, %eax
+
+#endif /* __PIC__ */
/* end of grgb routine */
#define END_GRGB(bpp) \
@@ -659,7 +691,7 @@
#undef INIT_CODE
movzbl (%esi, %eax), %eax /* read texel */
movb ALPHA2, %ah
- movl GLOBL(color_map), %ecx
+ MOVL_GLOBL(color_map, ecx)
movb (%ecx, %eax), %al
movb %al, FSEG(%edi)
#define END_CODE \
@@ -685,7 +717,7 @@
orl %eax, %eax
jz 2f
movb ALPHA2, %ah
- movl GLOBL(color_map), %ecx
+ MOVL_GLOBL(color_map, ecx)
movb (%ecx, %eax), %al
movb %al, FSEG(%edi)
#define END_CODE \
@@ -715,10 +747,10 @@
movzbl 2+ALPHA, %edx
pushl %edx
movw (%esi, %eax, 2), %ax /* read texel */
- pushl GLOBL(_blender_col_15)
+ PUSHL_GLOBL(_blender_col_15, edx)
pushl %eax
- call *GLOBL(_blender_func15)
+ CALL_PTR_GLOBL(_blender_func15, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -748,10 +780,10 @@
pushl %edx
movzbl 2+ALPHA, %edx
pushl %edx
- pushl GLOBL(_blender_col_15)
+ PUSHL_GLOBL(_blender_col_15, edx)
pushl %eax
- call *GLOBL(_blender_func15)
+ CALL_PTR_GLOBL(_blender_func15, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -781,9 +813,9 @@
movzbl 2+ALPHA, %edx
pushl %edx
movw (%esi, %eax, 2), %ax /* read texel */
- pushl GLOBL(_blender_col_16)
+ PUSHL_GLOBL(_blender_col_16, edx)
pushl %eax
- call *GLOBL(_blender_func16)
+ CALL_PTR_GLOBL(_blender_func16, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -813,10 +845,10 @@
pushl %edx
movzbl 2+ALPHA, %edx
pushl %edx
- pushl GLOBL(_blender_col_16)
+ PUSHL_GLOBL(_blender_col_16, edx)
pushl %eax
- call *GLOBL(_blender_func16)
+ CALL_PTR_GLOBL(_blender_func16, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -849,10 +881,10 @@
movzbl 2+ALPHA, %edx
pushl %edx
movl (%esi, %eax, 4), %eax /* read texel */
- pushl GLOBL(_blender_col_32)
+ PUSHL_GLOBL(_blender_col_32, edx)
pushl %eax
- call *GLOBL(_blender_func32)
+ CALL_PTR_GLOBL(_blender_func32, eax)
addl $12, %esp
movl %eax, FSEG(%edi) /* write the pixel */
@@ -882,10 +914,10 @@
pushl %edx
movzbl 2+ALPHA, %edx
pushl %edx
- pushl GLOBL(_blender_col_32)
+ PUSHL_GLOBL(_blender_col_32, edx)
pushl %eax
- call *GLOBL(_blender_func32)
+ CALL_PTR_GLOBL(_blender_func32, eax)
addl $12, %esp
movl %eax, FSEG(%edi) /* write the pixel */
@@ -921,10 +953,10 @@
movb 2(%esi, %ecx), %al /* read texel */
shll $16, %eax
movw (%esi, %ecx), %ax
- pushl GLOBL(_blender_col_24)
+ PUSHL_GLOBL(_blender_col_24, edx)
pushl %eax
- call *GLOBL(_blender_func24)
+ CALL_PTR_GLOBL(_blender_func24, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -959,10 +991,10 @@
pushl %edx
movzbl 2+ALPHA, %edx
pushl %edx
- pushl GLOBL(_blender_col_24)
+ PUSHL_GLOBL(_blender_col_24, edx)
pushl %eax
- call *GLOBL(_blender_func24)
+ CALL_PTR_GLOBL(_blender_func24, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -998,7 +1030,7 @@
movl READ_ADDR, %edi
movb FSEG (%edi), %al
popl %edi
- movl GLOBL(color_map), %ecx
+ MOVL_GLOBL(color_map, ecx)
movb (%ecx, %eax), %al
movb %al, FSEG(%edi)
#define END_CODE \
@@ -1025,7 +1057,7 @@
movl READ_ADDR, %edi
movb FSEG (%edi), %al
popl %edi
- movl GLOBL(color_map), %ecx
+ MOVL_GLOBL(color_map, ecx)
movb (%ecx, %eax), %al
movb %al, FSEG(%edi)
#define END_CODE \
@@ -1049,7 +1081,7 @@
INIT_ATEX(INIT_CODE)
#undef INIT_CODE
pushl %edx
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, edx)
pushl %edi
movl READ_ADDR, %edi
movw FSEG (%edi), %cx
@@ -1058,7 +1090,7 @@
pushl %ecx
pushl %eax
- call *GLOBL(_blender_func15)
+ CALL_PTR_GLOBL(_blender_func15, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -1087,11 +1119,11 @@
movw FSEG (%edi), %cx
popl %edi
pushl %edx
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, edx)
pushl %ecx
pushl %eax
- call *GLOBL(_blender_func15)
+ CALL_PTR_GLOBL(_blender_func15, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -1115,7 +1147,7 @@
INIT_ATEX(INIT_CODE)
#undef INIT_CODE
pushl %edx
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, edx)
pushl %edi
movl READ_ADDR, %edi
movw FSEG (%edi), %cx
@@ -1124,7 +1156,7 @@
pushl %ecx
pushl %eax
- call *GLOBL(_blender_func16)
+ CALL_PTR_GLOBL(_blender_func16, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -1153,11 +1185,11 @@
movw FSEG (%edi), %cx
popl %edi
pushl %edx
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, edx)
pushl %ecx
pushl %eax
- call *GLOBL(_blender_func16)
+ CALL_PTR_GLOBL(_blender_func16, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -1184,14 +1216,14 @@
INIT_ATEX(INIT_CODE)
#undef INIT_CODE
pushl %edx
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, edx)
movl %edi, ALPHA
movl READ_ADDR, %edi
pushl FSEG (%edi)
movl ALPHA, %edi
pushl (%esi, %eax, 4)
- call *GLOBL(_blender_func32)
+ CALL_PTR_GLOBL(_blender_func32, edx)
addl $12, %esp
movl %eax, FSEG(%edi) /* write the pixel */
@@ -1216,14 +1248,14 @@
cmpl $MASK_COLOR_32, %eax
jz 2f
pushl %edx
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, edx)
movl %edi, ALPHA
movl READ_ADDR, %edi
pushl FSEG (%edi)
movl ALPHA, %edi
pushl %eax
- call *GLOBL(_blender_func32)
+ CALL_PTR_GLOBL(_blender_func32, eax)
addl $12, %esp
movl %eax, FSEG(%edi) /* write the pixel */
@@ -1250,7 +1282,7 @@
INIT_ATEX(INIT_CODE)
#undef INIT_CODE
pushl %edx
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, edx)
leal (%eax, %eax, 2), %ecx
pushl %edi
movl READ_ADDR, %edi
@@ -1264,7 +1296,7 @@
pushl %edx
pushl %eax
- call *GLOBL(_blender_func24)
+ CALL_PTR_GLOBL(_blender_func24, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -1298,13 +1330,13 @@
movb FSEG 2(%edi), %cl
pushl %edx
movl ALPHA, %edi
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, edx)
shll $16, %ecx
movw FSEG (%edi), %cx
pushl %ecx
pushl %eax
- call *GLOBL(_blender_func24)
+ CALL_PTR_GLOBL(_blender_func24, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -1669,7 +1701,7 @@
#undef INIT_CODE
movzbl (%esi, %eax), %eax /* read texel */
movb 2+ALPHA, %ah
- movl GLOBL(color_map), %ecx
+ MOVL_GLOBL(color_map, ecx)
movb (%ecx, %eax), %al
movb %al, FSEG(%edi)
#define END_CODE \
@@ -1695,7 +1727,7 @@
orl %eax, %eax
jz 2f
movb 2+ALPHA, %ah
- movl GLOBL(color_map), %ecx
+ MOVL_GLOBL(color_map, ecx)
movb (%ecx, %eax), %al
movb %al, FSEG(%edi)
#define END_CODE \
@@ -1725,10 +1757,10 @@
movzbl 2+ALPHA, %edx
pushl %edx
movw (%esi, %eax, 2), %ax /* read texel */
- pushl GLOBL(_blender_col_15)
+ PUSHL_GLOBL(_blender_col_15, edx)
pushl %eax
- call *GLOBL(_blender_func15)
+ CALL_PTR_GLOBL(_blender_func15, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -1758,10 +1790,10 @@
pushl %edx
movzbl 2+ALPHA, %edx
pushl %edx
- pushl GLOBL(_blender_col_15)
+ PUSHL_GLOBL(_blender_col_15, edx)
pushl %eax
- call *GLOBL(_blender_func15)
+ CALL_PTR_GLOBL(_blender_func15, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -1791,10 +1823,10 @@
movzbl 2+ALPHA, %edx
pushl %edx
movw (%esi, %eax, 2), %ax /* read texel */
- pushl GLOBL(_blender_col_16)
+ PUSHL_GLOBL(_blender_col_16, edx)
pushl %eax
- call *GLOBL(_blender_func16)
+ CALL_PTR_GLOBL(_blender_func16, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -1824,10 +1856,10 @@
pushl %edx
movzbl 2+ALPHA, %edx
pushl %edx
- pushl GLOBL(_blender_col_16)
+ PUSHL_GLOBL(_blender_col_16, edx)
pushl %eax
- call *GLOBL(_blender_func16)
+ CALL_PTR_GLOBL(_blender_func16, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -1860,10 +1892,10 @@
movzbl 2+ALPHA, %edx
pushl %edx
movl (%esi, %eax, 4), %eax /* read texel */
- pushl GLOBL(_blender_col_32)
+ PUSHL_GLOBL(_blender_col_32, edx)
pushl %eax
- call *GLOBL(_blender_func32)
+ CALL_PTR_GLOBL(_blender_func32, eax)
addl $12, %esp
movl %eax, FSEG(%edi) /* write the pixel */
@@ -1893,10 +1925,10 @@
pushl %edx
movzbl 2+ALPHA, %edx
pushl %edx
- pushl GLOBL(_blender_col_32)
+ PUSHL_GLOBL(_blender_col_32, edx)
pushl %eax
- call *GLOBL(_blender_func32)
+ CALL_PTR_GLOBL(_blender_func32, eax)
addl $12, %esp
movl %eax, FSEG(%edi) /* write the pixel */
@@ -1932,10 +1964,10 @@
movb 2(%esi, %ecx), %al /* read texel */
shll $16, %eax
movw (%esi, %ecx), %ax
- pushl GLOBL(_blender_col_24)
+ PUSHL_GLOBL(_blender_col_24, edx)
pushl %eax
- call *GLOBL(_blender_func32)
+ CALL_PTR_GLOBL(_blender_func32, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -1970,10 +2002,10 @@
pushl %edx
movzbl 2+ALPHA, %edx
pushl %edx
- pushl GLOBL(_blender_col_24)
+ PUSHL_GLOBL(_blender_col_24, edx)
pushl %eax
- call *GLOBL(_blender_func24)
+ CALL_PTR_GLOBL(_blender_func24, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -2008,7 +2040,7 @@
movl READ_ADDR, %edi
movb FSEG (%edi), %al
popl %edi
- movl GLOBL(color_map), %ecx
+ MOVL_GLOBL(color_map, ecx)
movb (%ecx, %eax), %al
movb %al, FSEG(%edi)
#define END_CODE \
@@ -2035,7 +2067,7 @@
movl READ_ADDR, %edi
movb FSEG (%edi), %al
popl %edi
- movl GLOBL(color_map), %ecx
+ MOVL_GLOBL(color_map, ecx)
movb (%ecx, %eax), %al
movb %al, FSEG(%edi)
#define END_CODE \
@@ -2058,7 +2090,7 @@
INIT_PTEX(INIT_CODE)
#undef INIT_CODE
pushl %edx
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, edx)
pushl %edi
movl READ_ADDR, %edi
movw FSEG (%edi), %cx
@@ -2067,7 +2099,7 @@
pushl %ecx
pushl %eax
- call *GLOBL(_blender_func15)
+ CALL_PTR_GLOBL(_blender_func15, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -2096,11 +2128,11 @@
movw FSEG (%edi), %cx
popl %edi
pushl %edx
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, edx)
pushl %ecx
pushl %eax
- call *GLOBL(_blender_func15)
+ CALL_PTR_GLOBL(_blender_func15, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -2124,7 +2156,7 @@
INIT_PTEX(INIT_CODE)
#undef INIT_CODE
pushl %edx
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, edx)
pushl %edi
movl READ_ADDR, %edi
movw FSEG (%edi), %cx
@@ -2133,7 +2165,7 @@
pushl %ecx
pushl %eax
- call *GLOBL(_blender_func16)
+ CALL_PTR_GLOBL(_blender_func16, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -2162,11 +2194,11 @@
movw FSEG (%edi), %cx
popl %edi
pushl %edx
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, edx)
pushl %ecx
pushl %eax
- call *GLOBL(_blender_func16)
+ CALL_PTR_GLOBL(_blender_func16, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -2193,14 +2225,14 @@
INIT_PTEX(INIT_CODE)
#undef INIT_CODE
pushl %edx
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, edx)
movl %edi, ALPHA
movl READ_ADDR, %edi
pushl FSEG (%edi)
movl ALPHA, %edi
pushl (%esi, %eax, 4)
- call *GLOBL(_blender_func32)
+ CALL_PTR_GLOBL(_blender_func32, edx)
addl $12, %esp
movl %eax, FSEG(%edi) /* write the pixel */
@@ -2225,14 +2257,14 @@
cmpl $MASK_COLOR_32, %eax
jz 2f
pushl %edx
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, edx)
movl %edi, ALPHA
movl READ_ADDR, %edi
pushl FSEG (%edi)
movl ALPHA, %edi
pushl %eax
- call *GLOBL(_blender_func32)
+ CALL_PTR_GLOBL(_blender_func32, eax)
addl $12, %esp
movl %eax, FSEG(%edi) /* write the pixel */
@@ -2259,7 +2291,7 @@
INIT_PTEX(INIT_CODE)
#undef INIT_CODE
pushl %edx
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, edx)
leal (%eax, %eax, 2), %ecx
pushl %edi
movl READ_ADDR, %edi
@@ -2273,7 +2305,7 @@
pushl %edx
pushl %eax
- call *GLOBL(_blender_func24)
+ CALL_PTR_GLOBL(_blender_func24, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
@@ -2306,14 +2338,14 @@
movl READ_ADDR, %edi
movb FSEG 2(%edi), %cl
pushl %edx
- pushl GLOBL(_blender_alpha)
+ PUSHL_GLOBL(_blender_alpha, edx)
shll $16, %ecx
movw FSEG (%edi), %cx
movl ALPHA, %edi
pushl %ecx
pushl %eax
- call *GLOBL(_blender_func24)
+ CALL_PTR_GLOBL(_blender_func24, eax)
addl $12, %esp
movw %ax, FSEG(%edi) /* write the pixel */
Index: src/misc/icolconv.s
===================================================================
RCS file: /cvsroot/alleg/allegro/src/misc/icolconv.s,v
retrieving revision 1.27
diff -u -r1.27 icolconv.s
--- src/misc/icolconv.s 27 Jul 2004 08:07:45 -0000 1.27
+++ src/misc/icolconv.s 23 Sep 2004 15:09:30 -0000
@@ -3220,14 +3220,25 @@
pushl %ebp
movl %esp, %ebp
+#ifdef __PIC__
+ pushl %ebx
+#endif
pushl $2
pushl ARG2
pushl ARG1
+#ifdef __PIC__
+ GET_GOT(ebx)
+ call GLOBL(_colorcopy)@PLT
+#else
call GLOBL(_colorcopy)
+#endif
addl $12, %esp
+#ifdef __PIC__
+ popl %ebx
+#endif
popl %ebp
ret
@@ -3244,14 +3255,25 @@
pushl %ebp
movl %esp, %ebp
+#ifdef __PIC__
+ pushl %ebx
+#endif
pushl $3
pushl ARG2
pushl ARG1
+#ifdef __PIC__
+ GET_GOT(ebx)
+ call GLOBL(_colorcopy)@PLT
+#else
call GLOBL(_colorcopy)
+#endif
addl $12, %esp
+#ifdef __PIC__
+ popl %ebx
+#endif
popl %ebp
ret
@@ -3268,14 +3290,25 @@
pushl %ebp
movl %esp, %ebp
+#ifdef __PIC__
+ pushl %ebx
+#endif
pushl $4
pushl ARG2
pushl ARG1
+#ifdef __PIC__
+ GET_GOT(ebx)
+ call GLOBL(_colorcopy)@PLT
+#else
call GLOBL(_colorcopy)
+#endif
addl $12, %esp
+#ifdef __PIC__
+ popl %ebx
+#endif
popl %ebp
ret
Index: src/x/xwins.s
===================================================================
RCS file: /cvsroot/alleg/allegro/src/x/xwins.s,v
retrieving revision 1.7
diff -u -r1.7 xwins.s
--- src/x/xwins.s 31 Aug 2004 07:29:29 -0000 1.7
+++ src/x/xwins.s 23 Sep 2004 15:09:31 -0000
@@ -29,24 +29,46 @@
/* Use only with ASM calling convention. */
FUNC(_xwin_write_line_asm)
+#ifdef __PIC__
+ pushl %ebx
+#endif
pushl %ecx
pushl %eax
pushl %edx
+#ifdef __PIC__
+ GET_GOT(ebx)
+ call GLOBL(_xwin_write_line)@PLT
+#else
call GLOBL(_xwin_write_line)
+#endif
popl %edx
popl %ecx /* preserve %eax */
popl %ecx
+#ifdef __PIC__
+ popl %ebx
+#endif
ret
FUNC(_xwin_unwrite_line_asm)
+#ifdef __PIC__
+ pushl %ebx
+#endif
pushl %ecx
pushl %eax
pushl %edx
+#ifdef __PIC__
+ GET_GOT(ebx)
+ call GLOBL(_xwin_unwrite_line)@PLT
+#else
call GLOBL(_xwin_unwrite_line)
+#endif
popl %edx
popl %eax
popl %ecx
+#ifdef __PIC__
+ popl %ebx
+#endif
ret
#endif