Author: dgorbachev
Date: Wed Aug 6 23:10:08 2014
New Revision: 63823
URL:
http://svn.reactos.org/svn/reactos?rev=63823&view=rev
Log:
[NTOSKRNL][PSEH3]
- Add inline asm dependencies to fix undefined reference errors when
building with link-time optimization.
- Improve formatting.
- No functional changes.
Modified:
trunk/reactos/include/reactos/libs/pseh/pseh3.h
trunk/reactos/lib/pseh/i386/pseh3.c
trunk/reactos/ntoskrnl/CMakeLists.txt
trunk/reactos/ntoskrnl/include/internal/i386/ke.h
trunk/reactos/ntoskrnl/ntkrnlmp/CMakeLists.txt
Modified: trunk/reactos/include/reactos/libs/pseh/pseh3.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/pseh/…
==============================================================================
--- trunk/reactos/include/reactos/libs/pseh/pseh3.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/libs/pseh/pseh3.h [iso-8859-1] Wed Aug 6 23:10:08 2014
@@ -113,15 +113,6 @@
/* This attribute allows automatic cleanup of the registered frames */
#define _SEH3$_AUTO_CLEANUP __attribute__((cleanup(_SEH3$_AutoCleanup)))
-/* CLANG specific definitions! */
-#ifdef __clang__
-
-/* CLANG thinks it is smart and optimizes the alloca away if it is 0 and with it the use
of a frame register */
-#define _SEH3$_EnforceFramePointer() asm volatile ("#\n" : :
"m"(*(char*)__builtin_alloca(4)) : "%esp", "memory")
-
-/* CLANG doesn't have asm goto! */
-#define _SEH3$_ASM_GOTO(...)
-
int
__attribute__((regparm(3)))
__attribute__((returns_twice))
@@ -129,6 +120,23 @@
volatile SEH3$_REGISTRATION_FRAME* RegistrationFrame,
const SEH3$_SCOPE_TABLE* ScopeTable,
void* AllocaFrame);
+
+int
+__attribute__((regparm(3)))
+__attribute__((returns_twice))
+_SEH3$_RegisterTryLevelWithNonVolatiles(
+ volatile SEH3$_REGISTRATION_FRAME* RegistrationFrame,
+ const SEH3$_SCOPE_TABLE* ScopeTable,
+ void* AllocaFrame);
+
+/* CLANG specific definitions! */
+#ifdef __clang__
+
+/* CLANG thinks it is smart and optimizes the alloca away if it is 0 and with it the use
of a frame register */
+#define _SEH3$_EnforceFramePointer() asm volatile ("#\n" : :
"m"(*(char*)__builtin_alloca(4)) : "%esp", "memory")
+
+/* CLANG doesn't have asm goto! */
+#define _SEH3$_ASM_GOTO(...)
#define _SEH3$_RegisterFrame_(_TrylevelFrame, _DataTable) \
do { \
@@ -141,14 +149,6 @@
} \
} while(0)
-int
-__attribute__((regparm(3)))
-__attribute__((returns_twice))
-_SEH3$_RegisterTryLevelWithNonVolatiles(
- volatile SEH3$_REGISTRATION_FRAME* RegistrationFrame,
- const SEH3$_SCOPE_TABLE* ScopeTable,
- void* AllocaFrame);
-
#define _SEH3$_RegisterTryLevel_(_TrylevelFrame, _DataTable) \
do { \
int result = _SEH3$_RegisterTryLevelWithNonVolatiles(_TrylevelFrame, _DataTable,
__builtin_alloca(0)); \
@@ -171,21 +171,21 @@
#ifdef __cplusplus
#define _SEH3$_CALL_WRAPPER(_Function, _TrylevelFrame, _DataTable) \
- asm goto ("leal %0, %%eax\n" \
- "leal %1, %%edx\n" \
- "call " #_Function "WithStackLayout\n" \
+ asm goto ("leal %0, %%eax\n\t" \
+ "leal %1, %%edx\n\t" \
+ "call " #_Function "WithStackLayout" \
: \
- : "m" (*(_TrylevelFrame)), "m" (*(_DataTable)),
"c"(__builtin_alloca(0)) \
+ : "m" (*(_TrylevelFrame)), "m" (*(_DataTable)),
"c" (__builtin_alloca(0)), "p" (_SEH3$_RegisterFrameWithNonVolatiles)
\
: "eax", "edx", "memory" \
: _SEH3$_l_BeforeTry, _SEH3$_l_HandlerTarget, _SEH3$_l_OnException,
_SEH3$_l_BeforeFilterOrFinally, _SEH3$_l_FilterOrFinally)
#else
#define _SEH3$_CALL_WRAPPER(_Function, _TrylevelFrame, _DataTable) \
- asm goto ("leal %0, %%eax\n" \
- "leal %1, %%edx\n" \
- "call " #_Function "\n" \
+ asm goto ("leal %0, %%eax\n\t" \
+ "leal %1, %%edx\n\t" \
+ "call " #_Function \
: \
- : "m" (*(_TrylevelFrame)), "m" (*(_DataTable)) \
+ : "m" (*(_TrylevelFrame)), "m" (*(_DataTable)),
"p" (_SEH3$_RegisterFrameWithNonVolatiles) \
: "eax", "edx", "ecx", "memory" \
: _SEH3$_l_BeforeTry, _SEH3$_l_HandlerTarget, _SEH3$_l_OnException,
_SEH3$_l_BeforeFilterOrFinally, _SEH3$_l_FilterOrFinally)
#endif
@@ -227,8 +227,8 @@
/* On invocation, the AllocaFrame field is loaded with the return esp value */
#define _SEH3$_NESTED_FUNC_RETURN(_Result) \
/* Restore esp and return to the caller */ \
- asm volatile ("movl %[FixedEsp], %%esp\nret\n" \
- : : "a"(_Result),
[FixedEsp]"m"(_SEH3$_TrylevelFrame.AllocaFrame) : "ebx",
"ecx", "edx", "esi", "edi", "flags",
"memory")
+ asm volatile ("movl %[FixedEsp], %%esp\n\tret" \
+ : : "a" (_Result), [FixedEsp] "m"
(_SEH3$_TrylevelFrame.AllocaFrame) : "ebx", "ecx", "edx",
"esi", "edi", "flags", "memory")
/* The filter "function" */
#define _SEH3$_DEFINE_FILTER_FUNC(_Name, expression) \
Modified: trunk/reactos/lib/pseh/i386/pseh3.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/pseh/i386/pseh3.c?rev=…
==============================================================================
--- trunk/reactos/lib/pseh/i386/pseh3.c [iso-8859-1] (original)
+++ trunk/reactos/lib/pseh/i386/pseh3.c [iso-8859-1] Wed Aug 6 23:10:08 2014
@@ -82,8 +82,8 @@
/* Second call to get the filter result */
"mov $1, %%ecx\n\t"
- "call *%[Filter]\n\t"
- : "=a"(FilterResult)
+ "call *%[Filter]"
+ : "=a" (FilterResult)
: [RegistrationFrame] "m" (RegistrationFrame), [Filter] "m"
(Filter)
: "ecx", "edx");
@@ -197,14 +197,14 @@
{
asm volatile (
/* Load the registers */
- "movl 20(%%ecx), %%esp\n"
- "movl 24(%%ecx), %%ebp\n"
+ "movl 20(%%ecx), %%esp\n\t"
+ "movl 24(%%ecx), %%ebp\n\t"
/* Stack pointer is 4 off from the call to __SEH3$_RegisterFrame */
- "addl $4, %%esp\n"
+ "addl $4, %%esp\n\t"
/* Jump into the exception handler */
- "jmp *%[Target]\n"
+ "jmp *%[Target]"
: :
"c" (RegistrationFrame),
"a" (RegistrationFrame->ScopeTable),
@@ -215,14 +215,14 @@
{
asm volatile (
/* Load the registers */
- "movl 20(%%ecx), %%esp\n"
- "movl 24(%%ecx), %%ebp\n"
+ "movl 20(%%ecx), %%esp\n\t"
+ "movl 24(%%ecx), %%ebp\n\t"
/* Stack pointer is 4 off from the call to __SEH3$_RegisterFrame */
- "addl $4, %%esp\n"
+ "addl $4, %%esp\n\t"
/* Jump into the exception handler */
- "jmp *%[Target]\n"
+ "jmp *%[Target]"
: :
"c" (RegistrationFrame),
"a" (RegistrationFrame->ScopeTable),
@@ -253,7 +253,7 @@
LONG FilterResult;
/* Clear the direction flag. */
- asm volatile ("cld\n" : : : "memory");
+ asm volatile ("cld" : : : "memory");
/* Save the exception pointers on the stack */
ExceptionPointers.ExceptionRecord = ExceptionRecord;
Modified: trunk/reactos/ntoskrnl/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/CMakeLists.txt?re…
==============================================================================
--- trunk/reactos/ntoskrnl/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/CMakeLists.txt [iso-8859-1] Wed Aug 6 23:10:08 2014
@@ -33,11 +33,6 @@
set_image_base(ntoskrnl 0x80800000)
endif()
-# Linker bug
-if(NOT MSVC AND LTCG)
- add_target_link_flags(ntoskrnl "-shared")
-endif()
-
target_link_libraries(ntoskrnl
cportlib
csq
Modified: trunk/reactos/ntoskrnl/include/internal/i386/ke.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/i386/ke.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/i386/ke.h [iso-8859-1] Wed Aug 6 23:10:08
2014
@@ -687,13 +687,13 @@
__asm__ __volatile__
(
- "subl %1, %%esp\n"
- "movl %%esp, %%edi\n"
- "movl %2, %%esi\n"
- "shrl $2, %1\n"
- "rep movsd\n"
- "call *%3\n"
- "movl %%eax, %0\n"
+ "subl %1, %%esp\n\t"
+ "movl %%esp, %%edi\n\t"
+ "movl %2, %%esi\n\t"
+ "shrl $2, %1\n\t"
+ "rep movsd\n\t"
+ "call *%3\n\t"
+ "movl %%eax, %0"
: "=r"(Result)
: "c"(StackBytes),
"d"(Arguments),
@@ -772,6 +772,7 @@
NTSTATUS
KiConvertToGuiThread(VOID)
{
+ NTSTATUS NTAPI PsConvertToGuiThread(VOID);
NTSTATUS Result;
PVOID StackFrame;
@@ -799,7 +800,7 @@
"addl %%esp, %1\n\t"
"movl %1, %%ebp"
: "=a"(Result), "=r"(StackFrame)
- :
+ : "p"(PsConvertToGuiThread)
: "%esp", "%ecx", "%edx", "memory"
);
return Result;
@@ -819,22 +820,24 @@
VOID
KiSwitchToBootStack(IN ULONG_PTR InitialStack)
{
+ VOID NTAPI KiSystemStartupBootStack(VOID);
+
/* We have to switch to a new stack before continuing kernel initialization */
#ifdef __GNUC__
__asm__
(
- "movl %0, %%esp\n"
- "subl %1, %%esp\n"
- "pushl %2\n"
- "jmp _KiSystemStartupBootStack@0\n"
+ "movl %0, %%esp\n\t"
+ "subl %1, %%esp\n\t"
+ "pushl %2\n\t"
+ "jmp _KiSystemStartupBootStack@0"
:
: "c"(InitialStack),
"i"(NPX_FRAME_LENGTH + KTRAP_FRAME_ALIGN + KTRAP_FRAME_LENGTH),
- "i"(CR0_EM | CR0_TS | CR0_MP)
+ "i"(CR0_EM | CR0_TS | CR0_MP),
+ "p"(KiSystemStartupBootStack)
: "%esp"
);
#elif defined(_MSC_VER)
- VOID NTAPI KiSystemStartupBootStack(VOID);
__asm
{
mov esp, InitialStack
@@ -858,7 +861,7 @@
#if defined(__GNUC__)
__asm__ __volatile__
(
- "iret\n"
+ "iret"
);
#elif defined(_MSC_VER)
__asm
Modified: trunk/reactos/ntoskrnl/ntkrnlmp/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntkrnlmp/CMakeLis…
==============================================================================
--- trunk/reactos/ntoskrnl/ntkrnlmp/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ntkrnlmp/CMakeLists.txt [iso-8859-1] Wed Aug 6 23:10:08 2014
@@ -30,11 +30,6 @@
set_image_base(ntkrnlmp 0x80800000)
endif()
-# Linker bug
-if(NOT MSVC AND LTCG)
- add_target_link_flags(ntkrnlmp "-shared")
-endif()
-
target_link_libraries(ntkrnlmp
cportlib
csq