From: <dg...@us...> - 2006-12-21 09:54:52
|
Update of /cvsroot/xine/xine-lib/src/libw32dll/wine In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv26481/src/libw32dll/wine Modified Files: module.c stubs.s wrapper.S wrapper.h Log Message: Apply the textrel patch from Gentoo, thanks to PaX team for providing it. The patch was applied and tested for a while in Gentoo and Pardus, and solves also Debian's problems with non-PIC code. If problems will arise, they'll be debugged. Index: module.c =================================================================== RCS file: /cvsroot/xine/xine-lib/src/libw32dll/wine/module.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- module.c 8 Dec 2006 16:26:10 -0000 1.19 +++ module.c 21 Dec 2006 09:54:44 -0000 1.20 @@ -39,8 +39,8 @@ #ifdef EMU_QTX_API #include "wrapper.h" -static int report_func(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags); -static int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags); +int report_func(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags); +int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags); #endif //#undef TRACE @@ -519,8 +519,6 @@ printf ("wine/module: QuickTime.qts patched!!! old entry=%p\n",ptr[0]); #ifdef EMU_QTX_API - report_entry = report_func; - report_ret = report_func_ret; wrapper_target=ptr[0]; ptr[0]=wrapper; #endif @@ -683,7 +681,7 @@ static u_int32_t ret_array[4096]; static int ret_i=0; -static int report_func(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags) +int report_func(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags) { #ifdef DEBUG_QTX_API int i; @@ -882,7 +880,7 @@ return 0; } -static int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags) +int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags) { #ifdef DEBUG_QTX_API int i; @@ -997,8 +995,6 @@ // || !strcmp(function,"_CallComponent") ){ fprintf(stderr,"theQuickTimeDispatcher caught -> %p\n",retproc); - report_entry = report_func; - report_ret = report_func_ret; wrapper_target=(void *)retproc; retproc=(void *)wrapper; } Index: stubs.s =================================================================== RCS file: /cvsroot/xine/xine-lib/src/libw32dll/wine/stubs.s,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- stubs.s 21 Jun 2002 01:44:17 -0000 1.3 +++ stubs.s 21 Dec 2006 09:54:44 -0000 1.4 @@ -33,3 +33,6 @@ leal 12(%esp), %ebp pushl %eax ret + +.section .note.GNU-stack,"",@progbits + Index: wrapper.S =================================================================== RCS file: /cvsroot/xine/xine-lib/src/libw32dll/wine/wrapper.S,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- wrapper.S 18 Dec 2002 04:00:56 -0000 1.1 +++ wrapper.S 21 Dec 2006 09:54:44 -0000 1.2 @@ -1,17 +1,19 @@ .section .data -.globl caller_return caller_return: .long 0 -.globl report_entry -report_entry: - .long null_call -.globl report_ret -report_ret: - .long null_call .global wrapper_target wrapper_target: .long null_call +#undef __i686 /* gcc define gets in our way */ + .section .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits +.globl __i686.get_pc_thunk.bx + .hidden __i686.get_pc_thunk.bx + .type __i686.get_pc_thunk.bx,@function +__i686.get_pc_thunk.bx: + movl (%esp), %ebx + ret + .section .text .globl null_call .type null_call, @function @@ -22,46 +24,60 @@ .type wrapper, @function .balign 16,0x90 wrapper: + pushl $0 pusha # store registers (EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI) pushf # store flags push %ebp # set up a stack frame movl %esp, %ebp + call __i686.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + leal 4(%ebp), %eax # push flags addr push %eax leal 8(%ebp), %eax # push registers addr push %eax - leal 40(%ebp), %edx + leal 44(%ebp), %edx movl (%ebp), %eax subl %edx, %eax push %eax push %edx - call *report_entry # report entry + call report_func@PLT # report entry test %eax, %eax jnz .Ldone + movl 44(%ebp), %eax # switch return addresses + movl %eax, caller_return@GOTOFF(%ebx) + leal .Lwrapper_return@GOTOFF(%ebx), %eax + movl %eax, 40(%ebp) + + movl wrapper_target@GOTOFF(%ebx), %eax + mov %eax, 40(%ebp) # wrapper_target should return at .Lwrapper_return + leave # restore %esp, %ebp popf # restore flags popa # restore registers - - popl caller_return # switch return addresses - pushl $.Lwrapper_return - - jmp *wrapper_target # wrapper_target should return at .Lwrapper_return + + ret # fake 'return' to wrapper_target actually .balign 16, 0x90 .Lwrapper_return: - pushl caller_return # restore the original return address + pushl $0 pusha # more for reference sake here pushf push %ebp # set up a stack frame movl %esp, %ebp + call __i686.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + movl caller_return@GOTOFF(%ebx), %eax + movl %eax, 40(%ebp) # restore the original return address + leal 4(%ebp), %eax # push flags addr push %eax leal 8(%ebp), %eax # push registers addr @@ -73,11 +89,13 @@ push %eax push %edx - call *report_ret # report the return information (same args) + call report_func_ret@PLT# report the return information (same args) .Ldone: leave popf popa ret - + +.section .note.GNU-stack,"",@progbits + Index: wrapper.h =================================================================== RCS file: /cvsroot/xine/xine-lib/src/libw32dll/wine/wrapper.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- wrapper.h 18 Dec 2002 20:14:55 -0000 1.2 +++ wrapper.h 21 Dec 2006 09:54:44 -0000 1.3 @@ -11,10 +11,6 @@ u_int32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; } reg386_t; -typedef int (*wrapper_func_t)(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags); - -extern wrapper_func_t report_entry, report_ret; - extern void (*wrapper_target)(void); extern int wrapper(void); |