2004-10-18 02:48:08 -04:00
|
|
|
$OpenBSD: patch-loader_wrapper_S,v 1.3 2004/10/18 06:48:20 biorn Exp $
|
2003-02-16 02:25:18 -05:00
|
|
|
--- loader/wrapper.S.orig Mon Nov 25 21:37:12 2002
|
2004-10-18 02:48:08 -04:00
|
|
|
+++ loader/wrapper.S Thu Jul 15 09:29:23 2004
|
2003-02-16 02:25:18 -05:00
|
|
|
@@ -1,27 +1,36 @@
|
2002-12-22 09:19:47 -05:00
|
|
|
+#include "../mangle.h"
|
2003-02-16 02:25:18 -05:00
|
|
|
+#if defined(__OpenBSD__) && !defined(__ELF__)
|
|
|
|
+.data
|
|
|
|
+#else
|
2002-12-22 09:19:47 -05:00
|
|
|
.section .data
|
|
|
|
-.globl caller_return
|
|
|
|
-caller_return:
|
|
|
|
+#endif
|
|
|
|
+.globl MANGLEA(caller_return)
|
|
|
|
+MANGLEA(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
|
|
|
|
+.globl MANGLEA(report_entry)
|
|
|
|
+MANGLEA(report_entry):
|
|
|
|
+ .long MANGLEA(null_call)
|
|
|
|
+.globl MANGLEA(report_ret)
|
|
|
|
+MANGLEA(report_ret):
|
|
|
|
+ .long MANGLEA(null_call)
|
|
|
|
+.global MANGLEA(wrapper_target)
|
|
|
|
+MANGLEA(wrapper_target):
|
|
|
|
+ .long MANGLEA(null_call)
|
2004-10-18 02:48:08 -04:00
|
|
|
|
2003-02-16 02:25:18 -05:00
|
|
|
+#if defined(__OpenBSD__) && !defined(__ELF__)
|
|
|
|
+.text
|
|
|
|
+#else
|
2002-12-22 09:19:47 -05:00
|
|
|
.section .text
|
|
|
|
-.globl null_call
|
|
|
|
- .type null_call, @function
|
|
|
|
+#endif
|
|
|
|
+.globl MANGLEA(null_call)
|
|
|
|
+ .type MANGLEA(null_call), @function
|
|
|
|
.balign 16,0x90
|
|
|
|
-null_call:
|
|
|
|
+MANGLEA(null_call):
|
|
|
|
ret
|
|
|
|
-.globl wrapper
|
|
|
|
- .type wrapper, @function
|
|
|
|
+.globl MANGLEA(wrapper)
|
|
|
|
+ .type MANGLEA(wrapper), @function
|
|
|
|
.balign 16,0x90
|
|
|
|
-wrapper:
|
|
|
|
+MANGLEA(wrapper):
|
|
|
|
pusha # store registers (EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI)
|
|
|
|
pushf # store flags
|
|
|
|
|
2003-02-16 02:25:18 -05:00
|
|
|
@@ -39,7 +48,7 @@ wrapper:
|
2002-12-22 09:19:47 -05:00
|
|
|
push %eax
|
|
|
|
push %edx
|
|
|
|
|
|
|
|
- call *report_entry # report entry
|
|
|
|
+ call *MANGLEA(report_entry) # report entry
|
|
|
|
|
|
|
|
test %eax, %eax
|
|
|
|
jnz .Ldone
|
2003-02-16 02:25:18 -05:00
|
|
|
@@ -48,14 +57,14 @@ wrapper:
|
2002-12-22 09:19:47 -05:00
|
|
|
popf # restore flags
|
|
|
|
popa # restore registers
|
|
|
|
|
|
|
|
- popl caller_return # switch return addresses
|
|
|
|
+ popl MANGLEA(caller_return) # switch return addresses
|
|
|
|
pushl $.Lwrapper_return
|
|
|
|
|
|
|
|
- jmp *wrapper_target # wrapper_target should return at .Lwrapper_return
|
|
|
|
+ jmp *MANGLEA(wrapper_target) # wrapper_target should return at .Lwrapper_return
|
|
|
|
|
|
|
|
.balign 16, 0x90
|
|
|
|
.Lwrapper_return:
|
|
|
|
- pushl caller_return # restore the original return address
|
|
|
|
+ pushl MANGLEA(caller_return) # restore the original return address
|
|
|
|
pusha # more for reference sake here
|
|
|
|
pushf
|
|
|
|
|
2003-02-16 02:25:18 -05:00
|
|
|
@@ -73,7 +82,7 @@ wrapper:
|
2002-12-22 09:19:47 -05:00
|
|
|
push %eax
|
|
|
|
push %edx
|
|
|
|
|
|
|
|
- call *report_ret # report the return information (same args)
|
|
|
|
+ call *MANGLEA(report_ret) # report the return information (same args)
|
|
|
|
.Ldone:
|
|
|
|
|
|
|
|
leave
|