From 143732711e93dae0fb5d62d1fc8cd592c6d29c7f Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 13 Oct 2011 15:16:29 +0000 Subject: [PATCH] [ASM] Improve .proc / .endproc syntax, so that the full symbolic name is passed, which allows to create fastcall symbols. Remove the need to pass the function name to .endp svn path=/trunk/; revision=54112 --- reactos/dll/ntdll/dispatch/i386/dispatch.S | 16 ++++++------- .../dll/win32/kernel32/client/i386/fiber.S | 7 +++--- reactos/dll/win32/rpcrt4/msvc.S | 8 +++---- reactos/hal/halx86/apic/tsccal.S | 2 +- reactos/include/asm/asm.inc | 19 +++++++-------- reactos/include/asm/syscalls.inc | 12 +++------- reactos/include/reactos/asm.inc | 20 ++++++++++------ reactos/lib/rtl/i386/debug_asm.S | 24 +++++++++---------- reactos/lib/rtl/i386/rtlswap.S | 15 +++++------- reactos/lib/sdk/crt/string/i386/tcscpy.inc | 4 ++-- .../ntoskrnl/include/internal/i386/asmmacro.S | 4 ++-- reactos/ntoskrnl/ke/i386/trap.s | 8 +++---- 12 files changed, 67 insertions(+), 72 deletions(-) diff --git a/reactos/dll/ntdll/dispatch/i386/dispatch.S b/reactos/dll/ntdll/dispatch/i386/dispatch.S index 10706e21827..0ef4d37cc37 100644 --- a/reactos/dll/ntdll/dispatch/i386/dispatch.S +++ b/reactos/dll/ntdll/dispatch/i386/dispatch.S @@ -184,7 +184,7 @@ _KiRaiseUserExceptionDispatcher@0: PUBLIC _KiUserExceptionDispatcher@8 -.PROC KiUserExceptionDispatcher@8 +.PROC _KiUserExceptionDispatcher@8 FPO 0, 0, 0, 0, 0, FRAME_FPO /* Clear direction flag */ @@ -241,10 +241,10 @@ Exit: call _RtlRaiseException@4 ret 8 -.ENDP KiUserExceptionDispatcher@8 +.ENDP PUBLIC _KiIntSystemCall@0 -.PROC KiIntSystemCall@0 +.PROC _KiIntSystemCall@0 FPO 0, 0, 0, 0, 0, FRAME_FPO /* Set stack in EDX and do the interrupt */ @@ -254,26 +254,26 @@ PUBLIC _KiIntSystemCall@0 /* Return to caller */ ret -.ENDP KiIntSystemCall@0 +.ENDP PUBLIC _KiFastSystemCall@0 -.PROC KiFastSystemCall@0 +.PROC _KiFastSystemCall@0 FPO 0, 0, 0, 0, 0, FRAME_FPO /* Put ESP in EDX and do the SYSENTER */ mov edx, esp sysenter -.ENDP KiFastSystemCall@0 +.ENDP PUBLIC _KiFastSystemCallRet@0 -.PROC KiFastSystemCallRet@0 +.PROC _KiFastSystemCallRet@0 FPO 0, 0, 0, 0, 0, FRAME_FPO /* Just return to caller */ ret -.ENDP KiFastSystemCallRet@0 +.ENDP PUBLIC _RtlpGetStackLimits@8 _RtlpGetStackLimits@8: diff --git a/reactos/dll/win32/kernel32/client/i386/fiber.S b/reactos/dll/win32/kernel32/client/i386/fiber.S index d8bc8f28a3b..6e2444a6854 100644 --- a/reactos/dll/win32/kernel32/client/i386/fiber.S +++ b/reactos/dll/win32/kernel32/client/i386/fiber.S @@ -15,7 +15,7 @@ EXTERN _BaseThreadStartup@8:PROC .code PUBLIC _BaseFiberStartup@0 -.PROC BaseFiberStartup@0 +.PROC _BaseFiberStartup@0 /* Frame pointer is zeroed */ FPO 0, 0, 0, 0, 0, FRAME_FPO @@ -25,7 +25,7 @@ PUBLIC _BaseFiberStartup@0 push dword ptr [eax+FIBER_CONTEXT_EBX] /* Parameter */ push dword ptr [eax+FIBER_CONTEXT_EAX] /* Start Address */ call _BaseThreadStartup@8 -.ENDP BaseFiberStartup@0 +.ENDP PUBLIC _SwitchToFiber@4 @@ -135,6 +135,7 @@ NoFpuStateRestore: /* Jump to new fiber */ mov esp, [ecx+FIBER_CONTEXT_ESP] ret 4 -END + +END /* EOF */ diff --git a/reactos/dll/win32/rpcrt4/msvc.S b/reactos/dll/win32/rpcrt4/msvc.S index f3fe869b980..c45ccc68853 100644 --- a/reactos/dll/win32/rpcrt4/msvc.S +++ b/reactos/dll/win32/rpcrt4/msvc.S @@ -63,7 +63,7 @@ FUNC call_stubless_func call ndr_client_call add rsp, 38h ret -ENDFUNC call_stubless_func +ENDFUNC PUBLIC call_server_func FUNC call_server_func @@ -102,7 +102,7 @@ FUNC call_server_func pop rsi pop rbp ret -ENDFUNC call_server_func +ENDFUNC PUBLIC NdrClientCall2 @@ -121,7 +121,7 @@ FUNC NdrClientCall2 add rsp, 28h ret -ENDFUNC NdrClientCall2 +ENDFUNC EXTERN ndr_async_client_call:PROC PUBLIC NdrAsyncClientCall @@ -139,7 +139,7 @@ FUNC NdrAsyncClientCall add rsp, 28h ret -ENDFUNC NdrAsyncClientCall +ENDFUNC #endif diff --git a/reactos/hal/halx86/apic/tsccal.S b/reactos/hal/halx86/apic/tsccal.S index 63b731ec7f7..66bde94896b 100644 --- a/reactos/hal/halx86/apic/tsccal.S +++ b/reactos/hal/halx86/apic/tsccal.S @@ -100,7 +100,7 @@ CalibrationISR_Exit: pop rbx pop rax iretq -ENDFUNC TscCalibrationISR +ENDFUNC #endif END diff --git a/reactos/include/asm/asm.inc b/reactos/include/asm/asm.inc index 710d8e38ab8..97c4f8996bc 100644 --- a/reactos/include/asm/asm.inc +++ b/reactos/include/asm/asm.inc @@ -32,21 +32,18 @@ rip = 0 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */ .PROC MACRO name +__current_function_name EQU %name #ifdef _M_IX86 - _&name PROC + %name PROC #else - &name PROC FRAME + %name PROC FRAME #endif ENDM #define FUNC .PROC /* ... and .ENDP, replacing ENDP */ -.ENDP MACRO name -#ifdef _M_IX86 - _&name ENDP -#else - &name ENDP -#endif +.ENDP MACRO + %__current_function_name ENDP ENDM #define ENDFUNC .ENDP @@ -203,17 +200,17 @@ ENDM .macro .PROC name .func \name #ifdef _X86_ + /* x86 gas expects a label with _ prefix */ _\name: -#else - \name: #endif + \name: .cfi_startproc .equ cfa_current_offset, -8 .endm #define FUNC .PROC /* ... and .ENDP, replacing ENDP */ -.macro .ENDP name +.macro .ENDP .cfi_endproc .endfunc .endm diff --git a/reactos/include/asm/syscalls.inc b/reactos/include/asm/syscalls.inc index aad93da82e9..44b1badebe7 100644 --- a/reactos/include/asm/syscalls.inc +++ b/reactos/include/asm/syscalls.inc @@ -77,10 +77,7 @@ MACRO(MAKE_LABEL, Name, Stackbytes) ENDM MACRO(START_PROC, Name, Stackbytes) PUBLIC _&Name&@&Stackbytes - .PROC &Name&@&Stackbytes -ENDM -MACRO(END_PROC, Name, Stackbytes) - .ENDP &Name&@&Stackbytes + .PROC _&Name&@&Stackbytes ENDM #else MACRO(MAKE_LABEL, Name, Stackbytes) @@ -91,9 +88,6 @@ MACRO(START_PROC, Name, Stackbytes) PUBLIC &Name .PROC &Name ENDM -MACRO(END_PROC, Name, Stackbytes) - .ENDP &Name -ENDM #endif MACRO(STUB_U, Name, ArgCount) @@ -101,7 +95,7 @@ MACRO(STUB_U, Name, ArgCount) MAKE_LABEL Zw&Name, %Stackbytes START_PROC Nt&Name, %Stackbytes STUBCODE_U SyscallId, %Stackbytes - END_PROC Nt&Name, %Stackbytes + .ENDP SyscallId = SyscallId + 1 ENDM @@ -109,6 +103,6 @@ MACRO(STUB_K, Name, ArgCount) Stackbytes = 4 * &ArgCount START_PROC Zw&Name, %Stackbytes STUBCODE_K SyscallId, %Stackbytes - END_PROC Zw&Name, %Stackbytes + .ENDP SyscallId = SyscallId + 1 ENDM diff --git a/reactos/include/reactos/asm.inc b/reactos/include/reactos/asm.inc index 5267889cad5..89e0058d83c 100644 --- a/reactos/include/reactos/asm.inc +++ b/reactos/include/reactos/asm.inc @@ -32,14 +32,20 @@ rip = 0 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */ .PROC MACRO name - name PROC FRAME - _name: +__current_function_name EQU %name +#ifdef _M_IX86 + %name PROC +#else + %name PROC FRAME +#endif ENDM +#define FUNC .PROC /* ... and .ENDP, replacing ENDP */ -.ENDP MACRO name - name ENDP +.ENDP MACRO + %__current_function_name ENDP ENDM +#define ENDFUNC .ENDP /* check http://msdn.microsoft.com/en-us/library/9c9k076y%28VS.80%29.aspx and http://msdn.microsoft.com/en-us/library/ms679352%28VS.85%29.aspx */ @@ -150,17 +156,17 @@ ENDM .macro .PROC name .func \name #ifdef _X86_ + /* x86 gas expects a label with _ prefix */ _\name: -#else - \name: #endif + \name: .cfi_startproc .equ cfa_current_offset, -8 .endm #define FUNC .PROC /* ... and .ENDP, replacing ENDP */ -.macro .ENDP name +.macro .ENDP .cfi_endproc .endfunc .endm diff --git a/reactos/lib/rtl/i386/debug_asm.S b/reactos/lib/rtl/i386/debug_asm.S index 7849ec7f0c9..1b6be2f5ab4 100644 --- a/reactos/lib/rtl/i386/debug_asm.S +++ b/reactos/lib/rtl/i386/debug_asm.S @@ -22,31 +22,31 @@ PUBLIC _RtlpBreakWithStatusInstruction@0 .code -FUNC DbgBreakPointNoBugCheck@0 +FUNC _DbgBreakPointNoBugCheck@0 FPO 0, 0, 0, 0, 0, FRAME_FPO int 3 ret -ENDFUNC DbgBreakPointNoBugCheck@0 +ENDFUNC _DbgUserBreakPoint@0: -FUNC DbgBreakPoint@0 +FUNC _DbgBreakPoint@0 FPO 0, 0, 0, 0, 0, FRAME_FPO int 3 ret -ENDFUNC DbgBreakPoint@0 +ENDFUNC -FUNC DbgBreakPointWithStatus@4 +FUNC _DbgBreakPointWithStatus@4 FPO 0, 1, 0, 0, 0, FRAME_FPO mov eax, [esp+4] -ENDFUNC DbgBreakPointWithStatus@4 +ENDFUNC -FUNC RtlpBreakWithStatusInstruction@0 +FUNC _RtlpBreakWithStatusInstruction@0 FPO 0, 0, 0, 0, 0, FRAME_FPO int 3 ret 4 -ENDFUNC RtlpBreakWithStatusInstruction@0 +ENDFUNC -FUNC DebugService2@12 +FUNC _DebugService2@12 FPO 0, 3, 3, 0, 1, FRAME_NONFPO /* Setup the stack */ @@ -63,9 +63,9 @@ FUNC DebugService2@12 /* Restore stack */ pop ebp ret 12 -ENDFUNC DebugService2@12 +ENDFUNC -FUNC DebugService@20 +FUNC _DebugService@20 FPO 0, 5, 3, 0, 1, FRAME_NONFPO /* Setup the stack */ @@ -92,6 +92,6 @@ FUNC DebugService@20 /* Return */ pop ebp ret 20 -ENDFUNC DebugService@20 +ENDFUNC END diff --git a/reactos/lib/rtl/i386/rtlswap.S b/reactos/lib/rtl/i386/rtlswap.S index cd37de3a249..407b19e8ca0 100644 --- a/reactos/lib/rtl/i386/rtlswap.S +++ b/reactos/lib/rtl/i386/rtlswap.S @@ -16,28 +16,25 @@ PUBLIC @RtlUlonglongByteSwap@8 /* FUNCTIONS ***************************************************************/ .code -@RtlUshortByteSwap@4: -FUNC RtlUshortByteSwap +FUNC @RtlUshortByteSwap@4 FPO 0, 0, 0, 0, 0, FRAME_FPO /* Swap high and low bits */ mov ah, cl mov al, ch ret -ENDFUNC RtlUshortByteSwap +ENDFUNC -@RtlUlongByteSwap@4: -FUNC RtlUlongByteSwap +FUNC @RtlUlongByteSwap@4 FPO 0, 0, 0, 0, 0, FRAME_FPO /* Swap high and low bits */ mov eax, ecx bswap eax ret -ENDFUNC RtlUlongByteSwap +ENDFUNC -@RtlUlonglongByteSwap@8: -FUNC RtlUlonglongByteSwap +FUNC @RtlUlonglongByteSwap@8 FPO 0, 2, 0, 0, 0, FRAME_FPO /* Get 64-bit integer */ @@ -53,6 +50,6 @@ FUNC RtlUlonglongByteSwap and therefore put on tthe stack instead of in ecx and edx, but thats exactly how the function behaves on Windows! */ ret -ENDFUNC RtlUlonglongByteSwap +ENDFUNC END diff --git a/reactos/lib/sdk/crt/string/i386/tcscpy.inc b/reactos/lib/sdk/crt/string/i386/tcscpy.inc index e5ebd5ff4d8..6b5086f40f8 100644 --- a/reactos/lib/sdk/crt/string/i386/tcscpy.inc +++ b/reactos/lib/sdk/crt/string/i386/tcscpy.inc @@ -7,7 +7,7 @@ PUBLIC _tcscpy .code -FUNC tcscpy +FUNC _tcscpy FPO 0, 2, 2, 2, 0, FRAME_FPO push esi push edi @@ -27,7 +27,7 @@ FUNC tcscpy pop edi pop esi ret -ENDFUNC tcscpy +ENDFUNC END /* EOF */ diff --git a/reactos/ntoskrnl/include/internal/i386/asmmacro.S b/reactos/ntoskrnl/include/internal/i386/asmmacro.S index 77d989e9011..cf338d32338 100644 --- a/reactos/ntoskrnl/include/internal/i386/asmmacro.S +++ b/reactos/ntoskrnl/include/internal/i386/asmmacro.S @@ -219,7 +219,7 @@ ENDM MACRO(TRAP_ENTRY, Trap, Flags) EXTERN @&Trap&Handler@4 :PROC PUBLIC _&Trap - .PROC &Trap + .PROC _&Trap /* Generate proper debugging symbols */ FPO 0, 0, 0, 0, 1, FRAME_TRAP @@ -228,7 +228,7 @@ MACRO(TRAP_ENTRY, Trap, Flags) /* Call the C handler */ KiCallHandler @&Trap&Handler@4 - .ENDP &Trap + .ENDP ENDM #define KI_RESTORE_EAX HEX(001) diff --git a/reactos/ntoskrnl/ke/i386/trap.s b/reactos/ntoskrnl/ke/i386/trap.s index 84de56686dd..6817995ca35 100644 --- a/reactos/ntoskrnl/ke/i386/trap.s +++ b/reactos/ntoskrnl/ke/i386/trap.s @@ -136,19 +136,19 @@ _KiInterruptTemplateDispatch: EXTERN @KiSystemServiceHandler@8:PROC PUBLIC _KiSystemService -.PROC KiSystemService +.PROC _KiSystemService FPO 0, 0, 0, 0, 1, FRAME_TRAP KiEnterTrap (KI_PUSH_FAKE_ERROR_CODE OR KI_NONVOLATILES_ONLY OR KI_DONT_SAVE_SEGS) KiCallHandler @KiSystemServiceHandler@8 -.ENDP KiSystemService +.ENDP EXTERN @KiFastCallEntryHandler@8:PROC PUBLIC _KiFastCallEntry -.PROC KiFastCallEntry +.PROC _KiFastCallEntry FPO 0, 0, 0, 0, 1, FRAME_TRAP KiEnterTrap (KI_FAST_SYSTEM_CALL OR KI_NONVOLATILES_ONLY OR KI_DONT_SAVE_SEGS) KiCallHandler @KiFastCallEntryHandler@8 -.ENDP KiFastCallEntry +.ENDP PUBLIC _KiEndUnexpectedRange@0