From c5b25f41e455cdaa9d8e98d6f95bfb2d2238ee47 Mon Sep 17 00:00:00 2001 From: Casper Hornstrup Date: Sat, 15 Jan 2005 19:00:35 +0000 Subject: [PATCH] * Use objects rather than archive when linking ntoskrnl * Remove unused file except.s * Remove duplicate strtok() in ntoskrnl svn path=/branches/xmlbuildsystem/; revision=13062 --- reactos/ntoskrnl/kd/gdbstub.c | 50 --- reactos/ntoskrnl/ntoskrnl.xml | 1 - reactos/ntoskrnl/rtl/i386/except.s | 291 ------------------ .../rbuild/backend/mingw/modulehandler.cpp | 20 +- .../rbuild/backend/mingw/modulehandler.h | 1 + 5 files changed, 14 insertions(+), 349 deletions(-) delete mode 100755 reactos/ntoskrnl/rtl/i386/except.s diff --git a/reactos/ntoskrnl/kd/gdbstub.c b/reactos/ntoskrnl/kd/gdbstub.c index 26b2064a782..2d8c63ed56a 100644 --- a/reactos/ntoskrnl/kd/gdbstub.c +++ b/reactos/ntoskrnl/kd/gdbstub.c @@ -163,56 +163,6 @@ static PCHAR GspThreadStates[THREAD_STATE_MAX] = "Blocked" /* THREAD_STATE_BLOCKED */ }; -char * -strtok(char *s, const char *delim) -{ - const char *spanp; - int c, sc; - char *tok; - static char *last; - - - if (s == NULL && (s = last) == NULL) - return (NULL); - - /* - * Skip (span) leading delimiters (s += strspn(s, delim), sort of). - */ - cont: - c = *s++; - for (spanp = delim; (sc = *spanp++) != 0;) { - if (c == sc) - goto cont; - } - - if (c == 0) { /* no non-delimiter characters */ - last = NULL; - return (NULL); - } - tok = s - 1; - - /* - * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). - * Note that delim must have one NUL; we stop if we see that, too. - */ - for (;;) { - c = *s++; - spanp = delim; - do { - if ((sc = *spanp++) == c) { - if (c == 0) - s = NULL; - else - s[-1] = 0; - last = s; - return (tok); - } - } while (sc != 0); - } - /* NOTREACHED */ -} - - LONG HexValue (CHAR ch) { diff --git a/reactos/ntoskrnl/ntoskrnl.xml b/reactos/ntoskrnl/ntoskrnl.xml index 5d5dee07e0f..8c415a3241a 100644 --- a/reactos/ntoskrnl/ntoskrnl.xml +++ b/reactos/ntoskrnl/ntoskrnl.xml @@ -345,7 +345,6 @@ aulldiv.s aullrem.s aullshr.s - except.s exception.c seh.s diff --git a/reactos/ntoskrnl/rtl/i386/except.s b/reactos/ntoskrnl/rtl/i386/except.s deleted file mode 100755 index 8b32f1893f1..00000000000 --- a/reactos/ntoskrnl/rtl/i386/except.s +++ /dev/null @@ -1,291 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * PURPOSE: Kernel-mode exception support for IA-32 - * FILE: ntoskrnl/rtl/i386/except.s - * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net) - * NOTES: This file is shared with lib/ntdll/rtl/i386/except.s. - * Please keep them in sync. - */ - -#define EXCEPTION_UNWINDING 0x02 - -#define EREC_FLAGS 0x04 - -#define ExceptionContinueExecution 0 -#define ExceptionContinueSearch 1 -#define ExceptionNestedException 2 -#define ExceptionCollidedUnwind 3 - -.globl _RtlpExecuteHandlerForException -.globl _RtlpExecuteHandlerForUnwind - -#define CONTEXT_FLAGS 0x00 -#define CONTEXT_SEGGS 0x8C -#define CONTEXT_SEGFS 0x90 -#define CONTEXT_SEGES 0x94 -#define CONTEXT_SEGDS 0x98 -#define CONTEXT_EDI 0x9C -#define CONTEXT_ESI 0xA0 -#define CONTEXT_EBX 0xA4 -#define CONTEXT_EDX 0xA8 -#define CONTEXT_ECX 0xAC -#define CONTEXT_EAX 0xB0 -#define CONTEXT_EBP 0xB4 -#define CONTEXT_EIP 0xB8 -#define CONTEXT_SEGCS 0xBC -#define CONTEXT_EFLAGS 0xC0 -#define CONTEXT_ESP 0xC4 -#define CONTEXT_SEGSS 0xC8 - - -#define RCC_CONTEXT 0x08 - -// EAX = value to print -_do_debug: - pushal - pushl %eax - call _AsmDebug@4 - popal - ret - -#ifndef __NTOSKRNL__ - -// -// VOID -// RtlpCaptureContext(PCONTEXT pContext); -// -// Parameters: -// [ESP+08h] - PCONTEXT_X86 pContext -// Registers: -// None -// Returns: -// Nothing -// Notes: -// Grabs the current CPU context. -.globl _RtlpCaptureContext -_RtlpCaptureContext: - pushl %ebp - movl %esp, %ebp - movl RCC_CONTEXT(%ebp), %edx // EDX = Address of context structure - - cld - pushf - pop %eax - movl %eax, CONTEXT_EFLAGS(%edx) - xorl %eax, %eax - movl %eax, CONTEXT_EAX(%edx) - movl %eax, CONTEXT_EBX(%edx) - movl %eax, CONTEXT_ECX(%edx) - movl %eax, CONTEXT_EDX(%edx) - movl %eax, CONTEXT_ESI(%edx) - movl %eax, CONTEXT_EDI(%edx) - movl %cs, %eax - movl %eax, CONTEXT_SEGCS(%edx) - movl %ds, %eax - movl %eax, CONTEXT_SEGDS(%edx) - movl %es, %eax - movl %eax, CONTEXT_SEGES(%edx) - movl %fs, %eax - movl %eax, CONTEXT_SEGFS(%edx) - movl %gs, %eax - movl %eax, CONTEXT_SEGGS(%edx) - movl %ss, %eax - movl %eax, CONTEXT_SEGSS(%edx) - - // - // STACK LAYOUT: - (ESP to put in context structure) - // - RETURN ADDRESS OF CALLER OF CALLER - // - EBP OF CALLER OF CALLER - // ... - // - RETURN ADDRESS OF CALLER - // - EBP OF CALLER - // ... - // - - // Get return address of the caller of the caller of this function - movl %ebp, %ebx - //movl 4(%ebx), %eax // EAX = return address of caller - movl (%ebx), %ebx // EBX = EBP of caller - - movl 4(%ebx), %eax // EAX = return address of caller of caller - movl (%ebx), %ebx // EBX = EBP of caller of caller - - movl %eax, CONTEXT_EIP(%edx) // EIP = return address of caller of caller - movl %ebx, CONTEXT_EBP(%edx) // EBP = EBP of caller of caller - addl $8, %ebx - movl %ebx, CONTEXT_ESP(%edx) // ESP = EBP of caller of caller + 8 - - movl %ebp, %esp - popl %ebp - ret - -#endif /* !__NTOSKRNL__ */ - -#define REH_ERECORD 0x08 -#define REH_RFRAME 0x0C -#define REH_CONTEXT 0x10 -#define REH_DCONTEXT 0x14 -#define REH_EROUTINE 0x18 - -// Parameters: -// None -// Registers: -// [EBP+08h] - PEXCEPTION_RECORD ExceptionRecord -// [EBP+0Ch] - PEXCEPTION_REGISTRATION RegistrationFrame -// [EBP+10h] - PVOID Context -// [EBP+14h] - PVOID DispatcherContext -// [EBP+18h] - PEXCEPTION_HANDLER ExceptionRoutine -// EDX - Address of protecting exception handler -// Returns: -// EXCEPTION_DISPOSITION -// Notes: -// Setup the protecting exception handler and call the exception -// handler in the right context. -_RtlpExecuteHandler: - pushl %ebp - movl %esp, %ebp - pushl REH_RFRAME(%ebp) - - pushl %edx - pushl %fs:0x0 - movl %esp, %fs:0x0 - - // Prepare to call the exception handler - pushl REH_DCONTEXT(%ebp) - pushl REH_CONTEXT(%ebp) - pushl REH_RFRAME(%ebp) - pushl REH_ERECORD(%ebp) - - // Now call the exception handler - movl REH_EROUTINE(%ebp), %eax - call *%eax - - cmpl $-1, %fs:0x0 - jne .reh_stack_looks_ok - - // This should not happen - pushl 0 - pushl 0 - pushl 0 - pushl 0 - call _RtlAssert@16 - -.reh_loop: - jmp .reh_loop - -.reh_stack_looks_ok: - movl %fs:0x0, %esp - - // Return to the 'front-end' for this function - popl %fs:0x0 - movl %ebp, %esp - popl %ebp - ret - - -#define REP_ERECORD 0x04 -#define REP_RFRAME 0x08 -#define REP_CONTEXT 0x0C -#define REP_DCONTEXT 0x10 - -// Parameters: -// [ESP+04h] - PEXCEPTION_RECORD ExceptionRecord -// [ESP+08h] - PEXCEPTION_REGISTRATION RegistrationFrame -// [ESP+0Ch] - PCONTEXT Context -// [ESP+10h] - PVOID DispatcherContext -// Registers: -// None -// Returns: -// EXCEPTION_DISPOSITION -// Notes: -// This exception handler protects the exception handling -// mechanism by detecting nested exceptions. -_RtlpExceptionProtector: - movl $ExceptionContinueSearch, %eax - movl REP_ERECORD(%esp), %ecx - testl $EXCEPTION_UNWINDING, EREC_FLAGS(%ecx) - jnz .rep_end - - // Unwinding is not taking place, so return ExceptionNestedException - - // Set DispatcherContext field to the exception registration for the - // exception handler that executed when a nested exception occurred - movl REP_DCONTEXT(%esp), %ecx - movl REP_RFRAME(%esp), %eax - movl %eax, (%ecx) - movl $ExceptionNestedException, %eax - -.rep_end: - ret - - -// Parameters: -// [ESP+04h] - PEXCEPTION_RECORD ExceptionRecord -// [ESP+08h] - PEXCEPTION_REGISTRATION RegistrationFrame -// [ESP+0Ch] - PCONTEXT Context -// [ESP+10h] - PVOID DispatcherContext -// [ESP+14h] - PEXCEPTION_HANDLER ExceptionHandler -// Registers: -// None -// Returns: -// EXCEPTION_DISPOSITION -// Notes: -// Front-end -_RtlpExecuteHandlerForException: - movl $_RtlpExceptionProtector, %edx - jmp _RtlpExecuteHandler - - -#define RUP_ERECORD 0x04 -#define RUP_RFRAME 0x08 -#define RUP_CONTEXT 0x0C -#define RUP_DCONTEXT 0x10 - -// Parameters: -// [ESP+04h] - PEXCEPTION_RECORD ExceptionRecord -// [ESP+08h] - PEXCEPTION_REGISTRATION RegistrationFrame -// [ESP+0Ch] - PCONTEXT Context -// [ESP+10h] - PVOID DispatcherContext -// Registers: -// None -// Returns: -// EXCEPTION_DISPOSITION -// Notes: -// This exception handler protects the exception handling -// mechanism by detecting collided unwinds. -_RtlpUnwindProtector: - movl $ExceptionContinueSearch, %eax - movl %ecx, RUP_ERECORD(%esp) - testl $EXCEPTION_UNWINDING, EREC_FLAGS(%ecx) - jz .rup_end - - // Unwinding is taking place, so return ExceptionCollidedUnwind - - movl RUP_RFRAME(%esp), %ecx - movl RUP_DCONTEXT(%esp), %edx - - // Set DispatcherContext field to the exception registration for the - // exception handler that executed when a collision occurred - movl RUP_RFRAME(%ecx), %eax - movl %eax, (%edx) - movl $ExceptionCollidedUnwind, %eax - -.rup_end: - ret - - -// Parameters: -// [ESP+04h] - PEXCEPTION_RECORD ExceptionRecord -// [ESP+08h] - PEXCEPTION_REGISTRATION RegistrationFrame -// [ESP+0Ch] - PCONTEXT Context -// [ESP+10h] - PVOID DispatcherContext -// [ESP+14h] - PEXCEPTION_HANDLER ExceptionHandler -// Registers: -// None -// Returns: -// EXCEPTION_DISPOSITION -_RtlpExecuteHandlerForUnwind: - movl $_RtlpUnwindProtector, %edx - jmp _RtlpExecuteHandler diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index 970b85e272f..c0dc7f97ca5 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -587,6 +587,13 @@ MingwModuleHandler::GenerateArchiveTarget ( const Module& module, return archiveFilename; } +string +MingwModuleHandler::GetObjectsMacro ( const Module& module ) const +{ + return ssprintf ( "$(%s_OBJS)", + module.name.c_str () ); +} + string MingwModuleHandler::GetLinkerMacro ( const Module& module ) const { @@ -840,9 +847,9 @@ void MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module ) { static string ros_junk ( "$(ROS_TEMPORARY)" ); - string target ( FixupTargetFilename(module.GetPath()) ); - string workingDirectory = GetWorkingDirectory ( ); - string archiveFilename = GetModuleArchiveFilename ( module ); + string target ( FixupTargetFilename (module.GetPath ()) ); + string workingDirectory = GetWorkingDirectory (); + string objectsMacro = GetObjectsMacro ( module ); string importLibraryDependencies = GetImportLibraryDependencies ( module ); string base_tmp = ros_junk + module.name + ".base.tmp"; string junk_tmp = ros_junk + module.name + ".junk.tmp"; @@ -854,7 +861,7 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module ) fprintf ( fMakefile, "%s: %s %s\n", target.c_str (), - archiveFilename.c_str (), + objectsMacro.c_str (), importLibraryDependencies.c_str () ); fprintf ( fMakefile, "\t${gcc} %s %s -Wl,--base-file,%s -o %s %s %s\n", @@ -862,7 +869,7 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module ) gccOptions.c_str (), base_tmp.c_str (), junk_tmp.c_str (), - archiveFilename.c_str (), + objectsMacro.c_str (), importLibraryDependencies.c_str () ); fprintf ( fMakefile, "\t${rm} %s\n", @@ -871,7 +878,6 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module ) "\t${dlltool} --dllname %s --base-file %s --def ntoskrnl/ntoskrnl.def --output-exp %s --kill-at\n", target.c_str (), base_tmp.c_str (), - //FixupTargetFilename ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (), temp_exp.c_str () ); fprintf ( fMakefile, "\t${rm} %s\n", @@ -882,7 +888,7 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module ) gccOptions.c_str (), temp_exp.c_str (), target.c_str (), - archiveFilename.c_str (), + objectsMacro.c_str (), importLibraryDependencies.c_str () ); fprintf ( fMakefile, "\t${rm} %s\n\n", diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h index e3e420f87f4..6a91edc0b6e 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.h +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h @@ -36,6 +36,7 @@ protected: std::string GetInvocationParameters ( const Invoke& invoke ) const; void GenerateInvocations ( const Module& module ) const; void GeneratePreconditionDependencies ( const Module& module ) const; + std::string GetObjectsMacro ( const Module& module ) const; std::string GetLinkerMacro ( const Module& module ) const; std::string GenerateMacros ( const Module& module, const std::string& cflags_macro,