Index: libsdl1.2-1.2.10/src/hermes/common.inc =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ libsdl1.2-1.2.10/src/hermes/common.inc 2006-05-31 15:22:16.000000000 +0200 @@ -0,0 +1,84 @@ +; +; PIC support for HERMES +; Copyright (c) 2006 Sam Hocevar +; This source code is licensed under the GNU LGPL +; +; Please refer to the file COPYING.LIB contained in the distribution for +; licensing conditions + + +; These macros are totally harmless when PIC is not defined but can ruin +; everything if misused in PIC mode. On x86, shared objects cannot directly +; access global variables by address, they need to go through the GOT (global +; offset table). Most OSes do not care about it and let you load non-shared +; .so objects (Linux, Win32...). However, OS X requires PIC code in its +; .dylib objects. +; +; - GOT_* should be used as a suffix for global addressing, eg. +; mov eax, [foo GOT_ebx] +; instead of +; mov eax, [foo] +; +; - picgetgot computes the GOT address into the given register in PIC +; mode, otherwise does nothing. You need to do this before using GLOBAL. +; +; - picpush and picpop respectively push and pop the given register +; in PIC mode, otherwise do nothing. You should always use them around +; picgetgot except when sure that the register is no longer used and is +; being restored later by other means. +; +; - picesp is defined to compensate the changing of esp when pushing +; a register into the stack, eg. +; mov eax, [esp + 8] +; pushpic ebx +; mov eax, [picesp + 12] +; instead of +; mov eax, [esp + 8] +; pushpic ebx +; mov eax, [esp + 12] +; +; - picjmp jumps to a global address: +; picgetgot ebx +; picjmp ebx, far_address +; instead of +; jmp far_address +; +%ifdef PIC + EXTERN _GLOBAL_OFFSET_TABLE_ + %define GOT_eax + eax wrt ..gotoff + %define GOT_ebx + ebx wrt ..gotoff + %define GOT_ecx + ecx wrt ..gotoff + %define GOT_edx + edx wrt ..gotoff + %macro picgetgot 1 + call %%getgot + %%getgot: + pop %1 + add %1, _GLOBAL_OFFSET_TABLE_ + $$ - %%getgot wrt ..gotpc + %endmacro + %macro picpush 1 + push %1 + %endmacro + %macro picpop 1 + pop %1 + %endmacro + %define picesp esp+4 + %macro picjmp 2 + jmp [%2 + %1 wrt ..got] + %endmacro +%else + %define GOT_eax + %define GOT_ebx + %define GOT_ecx + %define GOT_edx + %macro picgetgot 1 + %endmacro + %macro picpush 1 + %endmacro + %macro picpop 1 + %endmacro + %define picesp esp + %macro picjmp 2 + jmp %2 + %endmacro +%endif + Index: libsdl1.2-1.2.10/src/hermes/mmxp2_32.asm =================================================================== --- libsdl1.2-1.2.10.orig/src/hermes/mmxp2_32.asm 2006-05-01 10:02:38.000000000 +0200 +++ libsdl1.2-1.2.10/src/hermes/mmxp2_32.asm 2006-05-31 15:32:58.000000000 +0200 @@ -18,6 +18,8 @@ ; are, they're terrible on p5 MMXs, but less so on pIIs. Someone needs to ; optimise them for p5 MMXs.. +%include "common.inc" + BITS 32 @@ -259,7 +263,8 @@ jnz .L3 .L4: - jmp _mmxreturn + picgetgot ecx + picjmp ecx, _mmxreturn _ConvertMMXpII32_16BGR555: @@ -399,7 +404,8 @@ jnz .L3 .L4: - jmp _mmxreturn + picgetgot ecx + picjmp ecx, _mmxreturn %ifidn __OUTPUT_FORMAT__,elf section .note.GNU-stack noalloc noexec nowrite progbits Index: libsdl1.2-1.2.10/src/hermes/x86_main.asm =================================================================== --- libsdl1.2-1.2.10.orig/src/hermes/x86_main.asm 2006-05-01 10:02:38.000000000 +0200 +++ libsdl1.2-1.2.10/src/hermes/x86_main.asm 2006-05-31 15:22:16.000000000 +0200 @@ -9,6 +9,8 @@ ; Most routines are (c) Glenn Fiedler (ptc@gaffer.org), used with permission ; +%include "common.inc" + BITS 32 GLOBAL _ConvertX86 Index: libsdl1.2-1.2.10/src/hermes/x86p_16.asm =================================================================== --- libsdl1.2-1.2.10.orig/src/hermes/x86p_16.asm 2006-05-01 10:02:38.000000000 +0200 +++ libsdl1.2-1.2.10/src/hermes/x86p_16.asm 2006-05-31 15:22:16.000000000 +0200 @@ -10,7 +10,8 @@ ; Used with permission. ; - +%include "common.inc" + BITS 32 GLOBAL _ConvertX86p16_32RGB888 @@ -54,7 +55,8 @@ dec ecx jnz .L1 .L2 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return .L3 ; head mov eax,edi @@ -132,7 +134,8 @@ add edi,BYTE 2 .L7 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return @@ -161,7 +164,8 @@ dec ecx jnz .L1 .L2 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return .L3 ; head mov eax,edi @@ -240,7 +244,8 @@ jmp SHORT .L6 .L7 pop ebp - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return @@ -274,7 +279,8 @@ dec ecx jnz .L1 .L2 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return .L3 ; head mov eax,edi @@ -358,7 +364,8 @@ add edi,BYTE 2 .L7 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return @@ -391,7 +398,8 @@ dec ecx jnz .L1 .L2 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return .L3 mov eax,edi and eax,BYTE 11b @@ -489,7 +497,8 @@ jnz .L6 .L7 pop ebp - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return %ifidn __OUTPUT_FORMAT__,elf section .note.GNU-stack noalloc noexec nowrite progbits Index: libsdl1.2-1.2.10/src/hermes/x86p_32.asm =================================================================== --- libsdl1.2-1.2.10.orig/src/hermes/x86p_32.asm 2006-05-01 10:02:38.000000000 +0200 +++ libsdl1.2-1.2.10/src/hermes/x86p_32.asm 2006-05-31 15:22:16.000000000 +0200 @@ -9,6 +9,7 @@ ; Most routines are (c) Glenn Fiedler (ptc@gaffer.org), used with permission ; +%include "common.inc" BITS 32 @@ -52,7 +53,8 @@ dec ecx jnz .L1 .L2 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return .L3 ; save ebp push ebp @@ -112,7 +114,8 @@ jnz .L5 .L6 pop ebp - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return @@ -132,7 +135,8 @@ dec ecx jnz .L1 .L2 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return .L3 ; save ebp push ebp @@ -183,7 +187,8 @@ jnz .L5 .L6 pop ebp - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return @@ -203,7 +208,8 @@ dec ecx jnz .L1 .L2 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return .L3 ; save ebp push ebp @@ -256,7 +262,8 @@ jnz .L5 .L6 pop ebp - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return @@ -281,7 +288,8 @@ dec ecx jnz .L1 .L2 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return .L3 ; head mov edx,edi @@ -353,7 +361,8 @@ jnz .L6 .L7 pop ebp - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return @@ -379,7 +388,8 @@ dec ecx jnz .L1 .L2 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return .L3 ; head mov edx,edi @@ -454,7 +464,8 @@ .L7 pop ebp - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return @@ -483,7 +494,8 @@ jnz .L1 .L2: ; End of short loop - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return .L3 ; head @@ -569,7 +581,8 @@ add edi,BYTE 2 .L7: - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return @@ -598,7 +611,8 @@ dec ecx jnz .L1 .L2 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return .L3 ; head mov ebx,edi @@ -683,7 +697,8 @@ add edi,BYTE 2 .L7 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return @@ -712,7 +727,8 @@ dec ecx jnz .L1 .L2 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return .L3 ; head mov ebx,edi @@ -794,7 +810,8 @@ add edi,BYTE 2 .L7 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return @@ -824,7 +841,8 @@ dec ecx jnz .L1 .L2 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return .L3 ; head mov ebx,edi @@ -909,7 +927,8 @@ add edi,BYTE 2 .L7 - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return @@ -1039,7 +1058,8 @@ jnz .L3 .L4: - jmp _x86return + picgetgot ebx + picjmp ebx, _x86return %ifidn __OUTPUT_FORMAT__,elf section .note.GNU-stack noalloc noexec nowrite progbits