Remove assembly language files, and make building Boost optional.
https://lists.launchpad.net/kicad-developers/msg11965.html
This commit is contained in:
parent
1c0f034bca
commit
c1e68436f1
|
@ -23,11 +23,6 @@ option( USE_WX_GRAPHICS_CONTEXT
|
|||
option( USE_WX_OVERLAY
|
||||
"Use wxOverlay: Always ON for MAC ( default OFF). Warning, this is experimental" )
|
||||
|
||||
#One of these 2 option *must* be set to ON:
|
||||
option( KICAD_STABLE_VERSION
|
||||
"set this option to ON to build the stable version of KICAD. mainly used to set version ID (default OFF)"
|
||||
)
|
||||
|
||||
option( KICAD_SCRIPTING
|
||||
"set this option ON to build the scripting support inside kicad binaries"
|
||||
)
|
||||
|
@ -44,22 +39,21 @@ option( KICAD_BUILD_STATIC
|
|||
"Builds Kicad and all libraries static (except wx-widgets)"
|
||||
)
|
||||
|
||||
option( KICAD_SKIP_BOOST
|
||||
"Skips building the required boost library components.
|
||||
WARNING: KiCad developers strongly advise you to build the bundled boost library, as it is
|
||||
known to work with KiCad. Other versions may contain bugs that may result in KiCad errors."
|
||||
)
|
||||
|
||||
|
||||
# when option KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES is enabled:
|
||||
# PYTHON_EXECUTABLE can be defined when invoking cmake
|
||||
# ( use -DPYTHON_EXECUTABLE=<python path>/python.exe or python2 )
|
||||
# when not defined by user, the default is python.exe under Windows and python2 for others
|
||||
# python binary file should be is exec path.
|
||||
|
||||
|
||||
option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." OFF )
|
||||
|
||||
|
||||
# Set version option (stable or testing)
|
||||
if( KICAD_STABLE_VERSION)
|
||||
add_definitions( -DKICAD_STABLE_VERSION )
|
||||
message( STATUS "Building stable version of KiCad" )
|
||||
endif()
|
||||
|
||||
# All CMake downloads go here. Suggested is up in the source tree, not in the build dir where they
|
||||
# would have to be downloaded over and over again. The default is to choose a directory that is
|
||||
# hidden on linux (starts with a '.') because there is a way to exclude this directory when grepping
|
||||
|
@ -317,7 +311,21 @@ check_find_package_result(CAIRO_FOUND "Cairo")
|
|||
|
||||
# Download boost and possibly build parts of it
|
||||
#################################################
|
||||
include( download_boost )
|
||||
if( KICAD_SKIP_BOOST )
|
||||
find_package( Boost 1.54.0 REQUIRED COMPONENTS context date_time filesystem iostreams locale
|
||||
program_options regex system thread )
|
||||
|
||||
if( NOT Boost_FOUND )
|
||||
message( FATAL_ERROR "Boost 1.54+ libraries are required." )
|
||||
endif()
|
||||
|
||||
message( WARNING "
|
||||
WARNING: You decided to skip building boost library.
|
||||
KiCad developers strongly advise you to build the bundled boost library, as it is known to work with KiCad.
|
||||
Other versions may contain bugs that may result in KiCad errors." )
|
||||
else()
|
||||
include( download_boost )
|
||||
endif()
|
||||
|
||||
##########################
|
||||
# Find wxWidgets library #
|
||||
|
|
|
@ -134,7 +134,7 @@ On either cmake command line shown below, you can optionally include
|
|||
-DCMAKE_INSTALL_PREFIX=<finallInstallDir>
|
||||
|
||||
If windows, run the following command:
|
||||
cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DKICAD_TESTING_VERSION=ON -DwxWidgets_ROOT_DIR=<wxInstallDir> ../../
|
||||
cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DwxWidgets_ROOT_DIR=<wxInstallDir> ../../
|
||||
|
||||
If linux, run instead the following command:
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ../../
|
||||
|
@ -167,7 +167,7 @@ Although normally you do not install the Debug binaries, you can debug them
|
|||
where they were built.
|
||||
|
||||
If windows, run the following command:
|
||||
cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Debug -DKICAD_TESTING_VERSION=ON -DwxWidgets_ROOT_DIR=<wxInstallDir> ../../
|
||||
cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Debug -DwxWidgets_ROOT_DIR=<wxInstallDir> ../../
|
||||
where <wxInstallDir> is <wxWidgets path>/Release
|
||||
|
||||
If linux, run instead the following command:
|
||||
|
|
|
@ -88,15 +88,11 @@ All of the configuration settings below are specific to the KiCad project.
|
|||
If for any reason you add or remove a build option to the KiCad CMake files,
|
||||
please update the list below.
|
||||
|
||||
KICAD_STABLE_VERSION (ON/OFF)
|
||||
-----------------------------
|
||||
This option enables or disables the stable version string to be created and
|
||||
used when building KiCad. It is mutually exclusive with KICAD_TESTING_VERSION.
|
||||
|
||||
KICAD_TESTING_VERSION (ON/OFF)
|
||||
------------------------------
|
||||
This option enables or disables the testing version string to be created and
|
||||
used when building KiCad. It is mutually exclusive with KICAD_STABLE_VERSION.
|
||||
KICAD_SKIP_BOOST (ON/OFF)
|
||||
--------------------------
|
||||
Skips building the required boost library components.
|
||||
WARNING: KiCad developers strongly advise you to build the bundled boost library, as it is
|
||||
known to work with KiCad. Other versions may contain bugs that may result in KiCad errors.
|
||||
|
||||
USE_WX_GRAPHICS_CONTEXT (ON/OFF)
|
||||
--------------------------------
|
||||
|
|
|
@ -149,8 +149,7 @@ command line enter the following commands:
|
|||
To create a release build of KiCad, run the following command:
|
||||
#cd build
|
||||
#cmake -G "MSYS Makefiles" \ # Back slashes are not required
|
||||
-DCMAKE_BUILD_TYPE=Release \ # and are for formatting only.
|
||||
-DKICAD_TESTING_VERSION=ON ../../
|
||||
-DCMAKE_BUILD_TYPE=Release ../../ \ # and are for formatting only.
|
||||
|
||||
If the configuration fails, you have failed to install the required software
|
||||
on you system. The error message should give you a good indication of what is
|
||||
|
@ -187,8 +186,7 @@ To create a debug version of KiCad, enter the following commands:
|
|||
|
||||
#cd <kicadSource>/build/debug
|
||||
#cmake -G "MSYS Makefiles" \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DKICAD_TESTING_VERSION=ON ../../
|
||||
-DCMAKE_BUILD_TYPE=Debug ../../
|
||||
#make
|
||||
|
||||
Generally speaking you do not install debug binaries. They can be debugged in
|
||||
|
@ -209,8 +207,7 @@ compile the source as described above.
|
|||
#cmake -G "MSYS Makefiles" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DKICAD_PYTHON_SCRIPTING=ON \
|
||||
-DKICAD_PYTHON_MODULES=ON \
|
||||
-DKICAD_TESTING_VERSION=ON ../../
|
||||
-DKICAD_PYTHON_MODULES=ON ../../
|
||||
|
||||
You only need to include the KICAD_PYTHON_MODULES option if you want to
|
||||
install the python modules that ship with KiCad. Also note that the wxPython
|
||||
|
|
|
@ -115,7 +115,7 @@ user@mac-osx$ make
|
|||
|
||||
It is also possible to give all the options on the commandline and not to edit the CMakeCache.txt. This is a oneliner for Leopard and up:
|
||||
|
||||
cmake ~/Repositories/testing -DKICAD_TESTING_VERSION=ON -DCMAKE_OSX_ARCHITECTURES="i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6" -DCMAKE_CXX_FLAGS="-D__ASSERTMACROS__" -DCMAKE_OSX_SYSROOT="/Developer/SDKs/MacOSX10.6.sdk"
|
||||
cmake ~/Repositories/testing -DCMAKE_OSX_ARCHITECTURES="i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6" -DCMAKE_CXX_FLAGS="-D__ASSERTMACROS__" -DCMAKE_OSX_SYSROOT="/Developer/SDKs/MacOSX10.6.sdk"
|
||||
|
||||
Optional compiler cache
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -9,13 +9,6 @@
|
|||
# define KICAD_BUILD_VERSION "(2013-jul-14)"
|
||||
#endif
|
||||
|
||||
|
||||
#if defined KICAD_STABLE_VERSION
|
||||
# define VERSION_STABILITY "stable"
|
||||
#else
|
||||
# define VERSION_STABILITY "product"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Function GetBuildVersion
|
||||
* Return the build date and version
|
||||
|
@ -24,8 +17,7 @@ wxString GetBuildVersion()
|
|||
{
|
||||
wxString msg = wxString::Format(
|
||||
wxT( "%s-%s" ),
|
||||
wxT( KICAD_BUILD_VERSION ),
|
||||
wxT( VERSION_STABILITY )
|
||||
wxT( KICAD_BUILD_VERSION )
|
||||
);
|
||||
|
||||
return msg;
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
Boost::Context assembly wrapper - done to avoid compiling the whole boost binary library
|
||||
which may be unpleasant, in particular under Windows (we don't support VC++, while boost::context
|
||||
does not support mingw */
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
#if __i386__
|
||||
#include "jump_i386_sysv_macho_gas.S"
|
||||
#include "make_i386_sysv_macho_gas.S"
|
||||
|
||||
#elif __x86_64__
|
||||
#include "jump_x86_64_sysv_macho_gas.S"
|
||||
#include "make_x86_64_sysv_macho_gas.S"
|
||||
|
||||
#else
|
||||
#error "Missing make_fcontext & jump_fcontext routines for this architecture"
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#if __i386__
|
||||
|
||||
#ifdef __WIN32__
|
||||
#include "jump_i386_pe_gas.S"
|
||||
#include "make_i386_pe_gas.S"
|
||||
#else
|
||||
#include "jump_i386_sysv_elf_gas.S"
|
||||
#include "make_i386_sysv_elf_gas.S"
|
||||
#endif
|
||||
|
||||
#elif __x86_64__
|
||||
#include "jump_x86_64_sysv_elf_gas.S"
|
||||
#include "make_x86_64_sysv_elf_gas.S"
|
||||
|
||||
#elif __arm__
|
||||
#include "jump_arm_aapcs_elf_gas.S"
|
||||
#include "make_arm_aapcs_elf_gas.S"
|
||||
|
||||
#else
|
||||
#error "Missing make_fcontext & jump_fcontext routines for this architecture"
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
Copyright Oliver Kowalke 2009.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/*******************************************************************
|
||||
* *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| 0x20| 0x24| *
|
||||
* ------------------------------------------------------------- *
|
||||
* | v1 | v2 | v3 | v4 | v5 | v6 | v7 | v8 | sp | lr | *
|
||||
* ------------------------------------------------------------- *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 10 | | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 0x28| | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | pc | | *
|
||||
* ------------------------------------------------------------- *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 11 | 12 | | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 0x2c| 0x30| | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | sp | size| | *
|
||||
* ------------------------------------------------------------- *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 0x34| 0x38|0x3c| 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58 | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | s24 | s25 | *
|
||||
* ------------------------------------------------------------- *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 23 | 24 | 25 | 26 | 27 | 28 | | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 0x5c| 0x60| 0x64| 0x68| 0x6c| 0x70| | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | s26 | s27 | s28 | s29 | s30 | s31 | | *
|
||||
* ------------------------------------------------------------- *
|
||||
* *
|
||||
* *****************************************************************/
|
||||
|
||||
.text
|
||||
.globl jump_fcontext
|
||||
.align 2
|
||||
.type jump_fcontext,%function
|
||||
jump_fcontext:
|
||||
stmia a1, {v1-v8,sp-lr} @ save V1-V8,SP-LR
|
||||
str lr, [a1,#40] @ save LR as PC
|
||||
|
||||
#if (defined(__VFP_FP__) && !defined(__SOFTFP__))
|
||||
cmp a4, #0 @ test if fpu env should be preserved
|
||||
beq 1f
|
||||
|
||||
mov a4, a1
|
||||
add a4, #52
|
||||
vstmia a4, {d8-d15} @ save S16-S31
|
||||
|
||||
mov a4, a2
|
||||
add a4, #52
|
||||
vldmia a4, {d8-d15} @ restore S16-S31
|
||||
1:
|
||||
#endif
|
||||
|
||||
mov a1, a3 @ use third arg as return value after jump
|
||||
@ and as first arg in context function
|
||||
ldmia a2, {v1-v8,sp-pc} @ restore v1-V8,SP-PC
|
||||
.size jump_fcontext,.-jump_fcontext
|
||||
|
||||
/* Mark that we don't need executable stack. */
|
||||
.section .note.GNU-stack,"",%progbits
|
|
@ -1,56 +0,0 @@
|
|||
/* Copyright Oliver Kowalke 2009.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
.global _jump_fcontext
|
||||
.text
|
||||
.align 2
|
||||
|
||||
_jump_fcontext:
|
||||
mov 0x4(%esp),%ecx
|
||||
mov %edi,(%ecx)
|
||||
mov %esi,0x4(%ecx)
|
||||
mov %ebx,0x8(%ecx)
|
||||
mov %ebp,0xc(%ecx)
|
||||
mov %fs:0x18,%edx
|
||||
mov (%edx),%eax
|
||||
mov %eax,0x24(%ecx)
|
||||
mov 0x4(%edx),%eax
|
||||
mov %eax,0x18(%ecx)
|
||||
mov 0x8(%edx),%eax
|
||||
mov %eax,0x20(%ecx)
|
||||
mov 0x10(%edx),%eax
|
||||
mov %eax,0x28(%ecx)
|
||||
lea 0x4(%esp),%eax
|
||||
mov %eax,0x10(%ecx)
|
||||
mov (%esp),%eax
|
||||
mov %eax,0x14(%ecx)
|
||||
mov 0x8(%esp),%edx
|
||||
mov (%edx),%edi
|
||||
mov 0x4(%edx),%esi
|
||||
mov 0x8(%edx),%ebx
|
||||
mov 0xc(%edx),%ebp
|
||||
mov 0x10(%esp),%eax
|
||||
test %eax,%eax
|
||||
je _jump_fcontext+0x5f
|
||||
stmxcsr 0x2c(%ecx)
|
||||
fnstcw 0x30(%ecx)
|
||||
ldmxcsr 0x2c(%edx)
|
||||
fldcw 0x30(%edx)
|
||||
mov %edx,%ecx
|
||||
mov %fs:0x18,%edx
|
||||
mov 0x24(%ecx),%eax
|
||||
mov %eax,(%edx)
|
||||
mov 0x18(%ecx),%eax
|
||||
mov %eax,0x4(%edx)
|
||||
mov 0x20(%ecx),%eax
|
||||
mov %eax,0x8(%edx)
|
||||
mov 0x28(%ecx),%eax
|
||||
mov %eax,0x10(%edx)
|
||||
mov 0xc(%esp),%eax
|
||||
mov 0x10(%ecx),%esp
|
||||
mov %eax,0x4(%esp)
|
||||
mov 0x14(%ecx),%ecx
|
||||
jmp *%ecx
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
Copyright Oliver Kowalke 2009.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/********************************************************************
|
||||
* *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 0 | 1 | 2 | 3 | 4 | 5 | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | EDI | ESI | EBX | EBP | ESP | EIP | *
|
||||
* -------------------------------------------------------------- *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 6 | 7 | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 0x18 | 0x1c | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | sp | size | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 8 | 9 | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 0x20 | 0x24 | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | fc_mxcsr|fc_x87_cw| | *
|
||||
* -------------------------------------------------------------- *
|
||||
* *
|
||||
* *****************************************************************/
|
||||
|
||||
.text
|
||||
.globl jump_fcontext
|
||||
.align 2
|
||||
.type jump_fcontext,@function
|
||||
jump_fcontext:
|
||||
movl 0x4(%esp), %ecx /* load address of the first fcontext_t arg */
|
||||
movl %edi, (%ecx) /* save EDI */
|
||||
movl %esi, 0x4(%ecx) /* save ESI */
|
||||
movl %ebx, 0x8(%ecx) /* save EBX */
|
||||
movl %ebp, 0xc(%ecx) /* save EBP */
|
||||
|
||||
leal 0x4(%esp), %eax /* exclude the return address */
|
||||
movl %eax, 0x10(%ecx) /* save as stack pointer */
|
||||
movl (%esp), %eax /* load return address */
|
||||
movl %eax, 0x14(%ecx) /* save return address */
|
||||
|
||||
movl 0x8(%esp), %edx /* load address of the second fcontext_t arg */
|
||||
movl (%edx), %edi /* restore EDI */
|
||||
movl 0x4(%edx), %esi /* restore ESI */
|
||||
movl 0x8(%edx), %ebx /* restore EBX */
|
||||
movl 0xc(%edx), %ebp /* restore EBP */
|
||||
|
||||
movl 0x10(%esp), %eax /* check if fpu enve preserving was requested */
|
||||
test %eax, %eax
|
||||
je 1f
|
||||
|
||||
stmxcsr 0x20(%ecx) /* save MMX control and status word */
|
||||
fnstcw 0x24(%ecx) /* save x87 control word */
|
||||
ldmxcsr 0x20(%edx) /* restore MMX control and status word */
|
||||
fldcw 0x24(%edx) /* restore x87 control word */
|
||||
1:
|
||||
movl 0xc(%esp), %eax /* use third arg as return value after jump */
|
||||
|
||||
movl 0x10(%edx), %esp /* restore ESP */
|
||||
movl %eax, 0x4(%esp) /* use third arg as first arg in context function */
|
||||
movl 0x14(%edx), %edx /* fetch the address to return to */
|
||||
|
||||
jmp *%edx /* indirect jump to context */
|
||||
.size jump_fcontext,.-jump_fcontext
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
Copyright Oliver Kowalke 2009.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/********************************************************************
|
||||
* *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 0 | 1 | 2 | 3 | 4 | 5 | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | EDI | ESI | EBX | EBP | ESP | EIP | *
|
||||
* -------------------------------------------------------------- *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 6 | 7 | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 0x18 | 0x1c | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | sp | size | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 8 | 9 | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 0x20 | 0x24 | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | fc_mxcsr|fc_x87_cw| | *
|
||||
* -------------------------------------------------------------- *
|
||||
* *
|
||||
* *****************************************************************/
|
||||
|
||||
.text
|
||||
.globl _jump_fcontext
|
||||
.align 2
|
||||
_jump_fcontext:
|
||||
movl 0x4(%esp), %ecx /* load address of the first fcontext_t arg */
|
||||
movl %edi, (%ecx) /* save EDI */
|
||||
movl %esi, 0x4(%ecx) /* save ESI */
|
||||
movl %ebx, 0x8(%ecx) /* save EBX */
|
||||
movl %ebp, 0xc(%ecx) /* save EBP */
|
||||
|
||||
leal 0x4(%esp), %eax /* exclude the return address */
|
||||
movl %eax, 0x10(%ecx) /* save as stack pointer */
|
||||
movl (%esp), %eax /* load return address */
|
||||
movl %eax, 0x14(%ecx) /* save return address */
|
||||
|
||||
movl 0x8(%esp), %edx /* load address of the second fcontext_t arg */
|
||||
movl (%edx), %edi /* restore EDI */
|
||||
movl 0x4(%edx), %esi /* restore ESI */
|
||||
movl 0x8(%edx), %ebx /* restore EBX */
|
||||
movl 0xc(%edx), %ebp /* restore EBP */
|
||||
|
||||
movl 0x10(%esp), %eax /* check if fpu enve preserving was requested */
|
||||
test %eax, %eax
|
||||
je 1f
|
||||
|
||||
stmxcsr 0x20(%ecx) /* save MMX control and status word */
|
||||
fnstcw 0x24(%ecx) /* save x87 control word */
|
||||
ldmxcsr 0x20(%edx) /* restore MMX control and status word */
|
||||
fldcw 0x24(%edx) /* restore x87 control word */
|
||||
1:
|
||||
movl 0xc(%esp), %eax /* use third arg as return value after jump */
|
||||
|
||||
movl 0x10(%edx), %esp /* restore ESP */
|
||||
movl %eax, 0x4(%esp) /* use third arg as first arg in context function */
|
||||
movl 0x14(%edx), %edx /* fetch the address to return to */
|
||||
|
||||
jmp *%edx /* indirect jump to context */
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
Copyright Oliver Kowalke 2009.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/****************************************************************************************
|
||||
* *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | RBX | R12 | R13 | R14 | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | R15 | RBP | RSP | RIP | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 16 | 17 | 18 | 19 | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0x40 | 0x44 | 0x48 | 0x4c | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | sp | size | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 20 | 21 | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0x50 | 0x54 | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | fc_mxcsr|fc_x87_cw| | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* *
|
||||
* **************************************************************************************/
|
||||
|
||||
.text
|
||||
.globl jump_fcontext
|
||||
.type jump_fcontext,@function
|
||||
.align 8
|
||||
jump_fcontext:
|
||||
movq %rbx, (%rdi) /* save RBX */
|
||||
movq %r12, 0x8(%rdi) /* save R12 */
|
||||
movq %r13, 0x10(%rdi) /* save R13 */
|
||||
movq %r14, 0x18(%rdi) /* save R14 */
|
||||
movq %r15, 0x20(%rdi) /* save R15 */
|
||||
movq %rbp, 0x28(%rdi) /* save RBP */
|
||||
|
||||
cmp $0, %rcx
|
||||
je 1f
|
||||
|
||||
stmxcsr 0x50(%rdi) /* save MMX control and status word */
|
||||
fnstcw 0x54(%rdi) /* save x87 control word */
|
||||
|
||||
ldmxcsr 0x50(%rsi) /* restore MMX control and status word */
|
||||
fldcw 0x54(%rsi) /* restore x87 control word */
|
||||
1:
|
||||
|
||||
leaq 0x8(%rsp), %rax /* exclude the return address and save as stack pointer */
|
||||
movq %rax, 0x30(%rdi) /* save as stack pointer */
|
||||
movq (%rsp), %rax /* save return address */
|
||||
movq %rax, 0x38(%rdi) /* save return address as RIP */
|
||||
|
||||
movq (%rsi), %rbx /* restore RBX */
|
||||
movq 0x8(%rsi), %r12 /* restore R12 */
|
||||
movq 0x10(%rsi), %r13 /* restore R13 */
|
||||
movq 0x18(%rsi), %r14 /* restore R14 */
|
||||
movq 0x20(%rsi), %r15 /* restore R15 */
|
||||
movq 0x28(%rsi), %rbp /* restore RBP */
|
||||
|
||||
movq 0x30(%rsi), %rsp /* restore RSP */
|
||||
movq 0x38(%rsi), %rcx /* fetch the address to return to */
|
||||
|
||||
movq %rdx, %rax /* use third arg as return value after jump */
|
||||
movq %rdx, %rdi /* use third arg as first arg in context function */
|
||||
|
||||
jmp *%rcx /* indirect jump to context */
|
||||
.size jump_fcontext,.-jump_fcontext
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
Copyright Oliver Kowalke 2009.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/****************************************************************************************
|
||||
* *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | RBX | R12 | R13 | R14 | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | R15 | RBP | RSP | RIP | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 16 | 17 | 18 | 19 | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0x40 | 0x44 | 0x48 | 0x4c | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | sp | size | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 20 | 21 | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0x50 | 0x54 | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | fc_mxcsr|fc_x87_cw| | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* *
|
||||
* **************************************************************************************/
|
||||
|
||||
.text
|
||||
.globl _jump_fcontext
|
||||
.align 8
|
||||
_jump_fcontext:
|
||||
movq %rbx, (%rdi) /* save RBX */
|
||||
movq %r12, 0x8(%rdi) /* save R12 */
|
||||
movq %r13, 0x10(%rdi) /* save R13 */
|
||||
movq %r14, 0x18(%rdi) /* save R14 */
|
||||
movq %r15, 0x20(%rdi) /* save R15 */
|
||||
movq %rbp, 0x28(%rdi) /* save RBP */
|
||||
|
||||
cmp $0, %rcx
|
||||
je 1f
|
||||
|
||||
stmxcsr 0x50(%rdi) /* save MMX control and status word */
|
||||
fnstcw 0x54(%rdi) /* save x87 control word */
|
||||
|
||||
ldmxcsr 0x50(%rsi) /* restore MMX control and status word */
|
||||
fldcw 0x54(%rsi) /* restore x87 control word */
|
||||
1:
|
||||
|
||||
leaq 0x8(%rsp), %rax /* exclude the return address and save as stack pointer */
|
||||
movq %rax, 0x30(%rdi) /* save as stack pointer */
|
||||
movq (%rsp), %rax /* save return address */
|
||||
movq %rax, 0x38(%rdi) /* save return address as RIP */
|
||||
|
||||
movq (%rsi), %rbx /* restore RBX */
|
||||
movq 0x8(%rsi), %r12 /* restore R12 */
|
||||
movq 0x10(%rsi), %r13 /* restore R13 */
|
||||
movq 0x18(%rsi), %r14 /* restore R14 */
|
||||
movq 0x20(%rsi), %r15 /* restore R15 */
|
||||
movq 0x28(%rsi), %rbp /* restore RBP */
|
||||
|
||||
movq 0x30(%rsi), %rsp /* restore RSP */
|
||||
movq 0x38(%rsi), %rcx /* fetch the address to return to */
|
||||
|
||||
movq %rdx, %rax /* use third arg as return value after jump */
|
||||
movq %rdx, %rdi /* use third arg as first arg in context function */
|
||||
|
||||
jmp *%rcx /* indirect jump to context */
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
Copyright Oliver Kowalke 2009.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/*******************************************************************
|
||||
* *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| 0x20| 0x24| *
|
||||
* ------------------------------------------------------------- *
|
||||
* | v1 | v2 | v3 | v4 | v5 | v6 | v7 | v8 | sp | lr | *
|
||||
* ------------------------------------------------------------- *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 10 | | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 0x28| | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | pc | | *
|
||||
* ------------------------------------------------------------- *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 11 | 12 | | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 0x2c| 0x30| | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | sp | size| | *
|
||||
* ------------------------------------------------------------- *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 0x34| 0x38|0x3c| 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58 | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | s24 | s25 | *
|
||||
* ------------------------------------------------------------- *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 23 | 24 | 25 | 26 | 27 | 28 | | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | 0x5c| 0x60| 0x64| 0x68| 0x6c| 0x70| | *
|
||||
* ------------------------------------------------------------- *
|
||||
* | s26 | s27 | s28 | s29 | s30 | s31 | | *
|
||||
* ------------------------------------------------------------- *
|
||||
* *
|
||||
* *****************************************************************/
|
||||
|
||||
.text
|
||||
.globl make_fcontext
|
||||
.align 2
|
||||
.type make_fcontext,%function
|
||||
make_fcontext:
|
||||
mov a4, a1 @ save address of context stack (base) A4
|
||||
sub a1, a1, #116 @ reserve space for fcontext_t at top of context stack
|
||||
|
||||
@ shift address in A1 to lower 16 byte boundary
|
||||
@ == pointer to fcontext_t and address of context stack
|
||||
bic a1, a1, #15
|
||||
|
||||
str a4, [a1,#44] @ save address of context stack (base) in fcontext_t
|
||||
str a2, [a1,#48] @ save context stack size in fcontext_t
|
||||
str a3, [a1,#40] @ save address of context function in fcontext_t
|
||||
|
||||
str a1, [a1,#32] @ save address in A4 as stack pointer for context function
|
||||
|
||||
adr a2, finish @ compute abs address of label finish
|
||||
str a2, [a1,#36] @ save address of finish as return address for context function
|
||||
@ entered after context function returns
|
||||
|
||||
bx lr
|
||||
|
||||
finish:
|
||||
@ SP points to same addras SP on entry of context function
|
||||
mov a1, #0 @ exit code is zero
|
||||
bl _exit@PLT @ exit application
|
||||
.size make_fcontext,.-make_fcontext
|
||||
|
||||
/* Mark that we don't need executable stack. */
|
||||
.section .note.GNU-stack,"",%progbits
|
|
@ -1,50 +0,0 @@
|
|||
/* Copyright Oliver Kowalke 2009.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
.global _make_fcontext
|
||||
.text
|
||||
.align 2
|
||||
|
||||
_make_fcontext:
|
||||
mov 0x4(%esp),%eax
|
||||
lea -0x34(%eax),%eax
|
||||
and $0xfffffff0,%eax
|
||||
mov 0x4(%esp),%ecx
|
||||
mov %ecx,0x18(%eax)
|
||||
mov 0x8(%esp),%edx
|
||||
mov %edx,0x1c(%eax)
|
||||
neg %edx
|
||||
lea (%edx,%ecx,1),%ecx
|
||||
mov %ecx,0x20(%eax)
|
||||
mov 0xc(%esp),%ecx
|
||||
mov %ecx,0x14(%eax)
|
||||
stmxcsr 0x2c(%eax)
|
||||
fnstcw 0x30(%eax)
|
||||
lea -0x1c(%eax),%edx
|
||||
mov %edx,0x10(%eax)
|
||||
mov $0x0,%ecx
|
||||
mov %ecx,(%edx)
|
||||
mov %fs:0x18,%ecx
|
||||
mov (%ecx),%edx
|
||||
inc %edx
|
||||
je _make_fcontext+0x4c // <_make_fcontext+0x4c>
|
||||
dec %edx
|
||||
xchg %edx,%ecx
|
||||
jmp _make_fcontext+0x42 // <_make_fcontext+0x42>
|
||||
mov 0x4(%ecx),%ecx
|
||||
mov 0x10(%eax),%edx
|
||||
mov %ecx,0x18(%edx)
|
||||
mov $0xffffffff,%ecx
|
||||
mov %ecx,0x14(%edx)
|
||||
lea 0x14(%edx),%ecx
|
||||
mov %ecx,0x24(%eax)
|
||||
ret
|
||||
|
||||
finish:
|
||||
xor %eax,%eax
|
||||
mov %eax,(%esp)
|
||||
call finish+0xa
|
||||
hlt
|
|
@ -1,77 +0,0 @@
|
|||
/*
|
||||
Copyright Oliver Kowalke 2009.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/********************************************************************
|
||||
* *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 0 | 1 | 2 | 3 | 4 | 5 | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | EDI | ESI | EBX | EBP | ESP | EIP | *
|
||||
* -------------------------------------------------------------- *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 6 | 7 | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 0x18 | 0x1c | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | sp | size | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 8 | 9 | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 0x20 | 0x24 | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | fc_mxcsr|fc_x87_cw| | *
|
||||
* -------------------------------------------------------------- *
|
||||
* *
|
||||
* *****************************************************************/
|
||||
|
||||
.text
|
||||
.globl make_fcontext
|
||||
.align 2
|
||||
.type make_fcontext,@function
|
||||
make_fcontext:
|
||||
movl 0x4(%esp), %eax /* load 1. arg of make_fcontext, pointer to context stack (base) */
|
||||
leal -0x28(%eax), %eax /* reserve space for fcontext_t at top of context stack */
|
||||
|
||||
/* shift address in EAX to lower 16 byte boundary */
|
||||
/* == pointer to fcontext_t and address of context stack */
|
||||
andl $-16, %eax
|
||||
|
||||
movl 0x4(%esp), %edx /* load 1. arg of make_fcontext, pointer to context stack (base) */
|
||||
movl %edx, 0x18(%eax) /* save address of context stack (base) in fcontext_t */
|
||||
movl 0x8(%esp), %edx /* load 2. arg of make_fcontext, context stack size */
|
||||
movl %edx, 0x1c(%eax) /* save stack size in fcontext_t */
|
||||
movl 0xc(%esp), %edx /* load 3. arg of make_fcontext, pointer to context function */
|
||||
movl %edx, 0x14(%eax) /* save address of context function in fcontext_t */
|
||||
|
||||
stmxcsr 0x20(%eax) /* save MMX control and status word */
|
||||
fnstcw 0x24(%eax) /* save x87 control word */
|
||||
|
||||
leal -0x8(%eax), %edx /* reserve space for the last frame on context stack; (ESP - 0x4) % 16 == 0 */
|
||||
movl %edx, 0x10(%eax) /* save address in EDX as stack pointer for context function */
|
||||
|
||||
call 1f
|
||||
1: popl %ecx /* address of label 2 */
|
||||
addl $finish-1b, %ecx /* compute abs address of label finish */
|
||||
movl %ecx, (%edx) /* save address of finish as return address for context functions */
|
||||
/* entered after context function returns */
|
||||
|
||||
ret
|
||||
|
||||
finish:
|
||||
/* ESP points to same address as ESP on entry of context function + 0x4 */
|
||||
call 2f
|
||||
2: popl %ebx /* address of label 3 */
|
||||
addl $_GLOBAL_OFFSET_TABLE_+[.-2b], %ebx /* compute address of GOT and store it in EBX */
|
||||
|
||||
xorl %eax, %eax
|
||||
movl %eax, (%esp) /* exit code is zero */
|
||||
call _exit@PLT /* exit application */
|
||||
hlt
|
||||
.size make_fcontext,.-make_fcontext
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
Copyright Oliver Kowalke 2009.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/********************************************************************
|
||||
* *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 0 | 1 | 2 | 3 | 4 | 5 | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | EDI | ESI | EBX | EBP | ESP | EIP | *
|
||||
* -------------------------------------------------------------- *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 6 | 7 | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 0x18 | 0x1c | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | sp | size | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 8 | 9 | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | 0x20 | 0x24 | | *
|
||||
* -------------------------------------------------------------- *
|
||||
* | fc_mxcsr|fc_x87_cw| | *
|
||||
* -------------------------------------------------------------- *
|
||||
* *
|
||||
* *****************************************************************/
|
||||
|
||||
.text
|
||||
.globl _make_fcontext
|
||||
.align 2
|
||||
_make_fcontext:
|
||||
movl 0x4(%esp), %eax /* load 1. arg of make_fcontext, pointer to context stack (base) */
|
||||
leal -0x28(%eax), %eax /* reserve space for fcontext_t at top of context stack */
|
||||
|
||||
/* shift address in EAX to lower 16 byte boundary */
|
||||
/* == pointer to fcontext_t and address of context stack */
|
||||
andl $-16, %eax
|
||||
|
||||
movl 0x4(%esp), %edx /* load 1. arg of make_fcontext, pointer to context stack (base) */
|
||||
movl %edx, 0x18(%eax) /* save address of stack pointer (base) in fcontext_t */
|
||||
movl 0x8(%esp), %edx /* load 2. arg of make_fcontext, context stack size */
|
||||
movl %edx, 0x1c(%eax) /* save stack size in fcontext_t */
|
||||
movl 0xc(%esp), %edx /* load 3. arg of make_fcontext, pointer to context function */
|
||||
movl %edx, 0x14(%eax) /* save address of context fcuntion in fcontext_t */
|
||||
|
||||
stmxcsr 0x20(%eax) /* save MMX control and status word */
|
||||
fnstcw 0x24(%eax) /* save x87 control word */
|
||||
|
||||
leal -0x14(%eax), %edx /* reserve space for the last frame on context stack */
|
||||
movl %edx, 0x10(%eax) /* save address in EDX as stack pointer for context function */
|
||||
|
||||
call 1f
|
||||
1: popl %ecx /* address of label 1 */
|
||||
addl $finish-1b, %ecx /* compute abs address of label finish */
|
||||
movl %ecx, (%edx) /* save address of finish as return address for context function */
|
||||
/* entered after context function returns */
|
||||
|
||||
ret
|
||||
|
||||
finish:
|
||||
/* ESP points to same address as ESP on entry of context function + 0x4 */
|
||||
xorl %eax, %eax
|
||||
movl %eax, (%esp) /* exit code is zero */
|
||||
call __exit /* exit application */
|
||||
hlt
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
Copyright Oliver Kowalke 2009.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/****************************************************************************************
|
||||
* *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | RBX | R12 | R13 | R14 | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | R15 | RBP | RSP | RIP | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 16 | 17 | 18 | 19 | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0x40 | 0x44 | 0x48 | 0x4c | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | sp | size | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 20 | 21 | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0x50 | 0x54 | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | fc_mxcsr|fc_x87_cw| | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* *
|
||||
* **************************************************************************************/
|
||||
|
||||
.text
|
||||
.globl make_fcontext
|
||||
|
||||
#ifndef __APPLE__
|
||||
.type make_fcontext,@function
|
||||
#endif
|
||||
|
||||
.align 8
|
||||
make_fcontext:
|
||||
leaq -0x58(%rdi), %rax /* reserve space for fcontext_t at top of context stack */
|
||||
|
||||
/* shift address in RAX to lower 16 byte boundary */
|
||||
/* == pointer to fcontext_t and address of context stack */
|
||||
andq $-16, %rax
|
||||
|
||||
movq %rdi, 0x40(%rax) /* save address of context stack pointer (base) in fcontext_t */
|
||||
movq %rsi, 0x48(%rax) /* save context stack size in fcontext_t */
|
||||
movq %rdx, 0x38(%rax) /* save address of context function in fcontext_t */
|
||||
|
||||
stmxcsr 0x50(%rax) /* save MMX control and status word */
|
||||
fnstcw 0x54(%rax) /* save x87 control word */
|
||||
|
||||
leaq -0x8(%rax), %rdx /* reserve space for the return address on context stack, (RSP - 0x8) % 16 == 0 */
|
||||
movq %rdx, 0x30(%rax) /* save address in RDX as stack pointer for context function */
|
||||
|
||||
leaq finish(%rip), %rcx /* compute abs address of label finish */
|
||||
movq %rcx, (%rdx) /* save address of finish as return address for context function */
|
||||
/* entered after context function returns */
|
||||
|
||||
ret /* return pointer to fcontext_t placed on context stack */
|
||||
|
||||
finish:
|
||||
/* RSP points to same address as RSP on entry of context function + 0x8 */
|
||||
xorq %rdi, %rdi /* exit code is zero */
|
||||
call _exit@PLT /* exit application */
|
||||
hlt
|
||||
|
||||
#ifndef __APPLE__
|
||||
.size make_fcontext,.-make_fcontext
|
||||
#endif
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
Copyright Oliver Kowalke 2009.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/****************************************************************************************
|
||||
* *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | RBX | R12 | R13 | R14 | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | R15 | RBP | RSP | RIP | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 16 | 17 | 18 | 19 | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0x40 | 0x44 | 0x48 | 0x4c | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | sp | size | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 20 | 21 | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | 0x50 | 0x54 | | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* | fc_mxcsr|fc_x87_cw| | *
|
||||
* ---------------------------------------------------------------------------------- *
|
||||
* *
|
||||
* **************************************************************************************/
|
||||
|
||||
.text
|
||||
.globl _make_fcontext
|
||||
.align 8
|
||||
_make_fcontext:
|
||||
leaq -0x58(%rdi), %rax /* reserve space for fcontext_t at top of context stack */
|
||||
|
||||
/* shift address in RAX to lower 16 byte boundary */
|
||||
/* == pointer to fcontext_t and address of context stack */
|
||||
movabs $-16, %r8
|
||||
andq %r8, %rax
|
||||
|
||||
movq %rdi, 0x40(%rax) /* save address of stack pointer (base) in fcontext_t */
|
||||
movq %rsi, 0x48(%rax) /* save stack size in fcontext_t */
|
||||
movq %rdx, 0x38(%rax) /* save address of context function in fcontext_t */
|
||||
|
||||
stmxcsr 0x50(%rax) /* save MMX control and status word */
|
||||
fnstcw 0x54(%rax) /* save x87 control word */
|
||||
|
||||
leaq -0x8(%rax), %rdx /* reserve space for the return address on context stack, (RSP - 0x8) % 16 == 0 */
|
||||
movq %rdx, 0x30(%rax) /* save address in RDX as stack pointer for context function */
|
||||
|
||||
leaq finish(%rip), %rcx /* compute abs address of label finish */
|
||||
movq %rcx, (%rdx) /* save address of finish as return address for context function */
|
||||
/* entered after context function returns */
|
||||
|
||||
ret /* return pointer to fcontext_t placed on context stack */
|
||||
|
||||
finish:
|
||||
/* RSP points to same address as RSP on entry of context function + 0x8 */
|
||||
xorq %rdi, %rdi /* exit code is zero */
|
||||
call __exit /* exit application */
|
Loading…
Reference in New Issue