This file is part of MXE. See index.html for further information. From 7b1ff5c3a275e2903a7f35a3817d00f8a75b47d0 Mon Sep 17 00:00:00 2001 From: Tony Theodore Date: Sun, 29 Mar 2015 12:55:15 +0200 Subject: [PATCH 1/3] fixes This patch has been taken from: https://aur.archlinux.org/packages/mingw-w64-boost/ diff --git a/boost/detail/interlocked.hpp b/boost/detail/interlocked.hpp index 2c91ce2..abc7c6d 100644 --- a/boost/detail/interlocked.hpp +++ b/boost/detail/interlocked.hpp @@ -1,6 +1,10 @@ #ifndef BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED #define BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED +#ifndef BOOST_USE_WINDOWS_H +#define BOOST_USE_WINDOWS_H +#endif + // // boost/detail/interlocked.hpp // diff --git a/boost/detail/interlocked.hpp.orig b/boost/detail/interlocked.hpp.orig new file mode 100644 index 0000000..2c91ce2 --- /dev/null +++ b/boost/detail/interlocked.hpp.orig @@ -0,0 +1,218 @@ +#ifndef BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED +#define BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED + +// +// boost/detail/interlocked.hpp +// +// Copyright 2005 Peter Dimov +// +// 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) +// + +#include + +// MS compatible compilers support #pragma once +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if defined( BOOST_USE_WINDOWS_H ) + +# include + +# define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement +# define BOOST_INTERLOCKED_DECREMENT InterlockedDecrement +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange +# define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange +# define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER InterlockedCompareExchangePointer +# define BOOST_INTERLOCKED_EXCHANGE_POINTER InterlockedExchangePointer + +#elif defined( BOOST_USE_INTRIN_H ) + +#include + +# define BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement +# define BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange +# define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange +# define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd + +# if defined(_M_IA64) || defined(_M_AMD64) || defined(__x86_64__) || defined(__x86_64) + +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER _InterlockedCompareExchangePointer +# define BOOST_INTERLOCKED_EXCHANGE_POINTER _InterlockedExchangePointer + +# else + +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \ + ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare))) +# define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \ + ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange))) + +# endif + +#elif defined(_WIN32_WCE) + +#if _WIN32_WCE >= 0x600 + +extern "C" long __cdecl _InterlockedIncrement( long volatile * ); +extern "C" long __cdecl _InterlockedDecrement( long volatile * ); +extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long ); +extern "C" long __cdecl _InterlockedExchange( long volatile *, long ); +extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long ); + +# define BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement +# define BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange +# define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange +# define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd + +#else +// under Windows CE we still have old-style Interlocked* functions + +extern "C" long __cdecl InterlockedIncrement( long* ); +extern "C" long __cdecl InterlockedDecrement( long* ); +extern "C" long __cdecl InterlockedCompareExchange( long*, long, long ); +extern "C" long __cdecl InterlockedExchange( long*, long ); +extern "C" long __cdecl InterlockedExchangeAdd( long*, long ); + +# define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement +# define BOOST_INTERLOCKED_DECREMENT InterlockedDecrement +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange +# define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange +# define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd + +#endif + +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \ + ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long*)(dest),(long)(exchange),(long)(compare))) +# define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \ + ((void*)BOOST_INTERLOCKED_EXCHANGE((long*)(dest),(long)(exchange))) + +#elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN ) + +#if defined( BOOST_MSVC ) && BOOST_MSVC >= 1400 + +#include + +#else + +# if defined( __CLRCALL_PURE_OR_CDECL ) +# define BOOST_INTERLOCKED_CLRCALL_PURE_OR_CDECL __CLRCALL_PURE_OR_CDECL +# else +# define BOOST_INTERLOCKED_CLRCALL_PURE_OR_CDECL __cdecl +# endif + +extern "C" long BOOST_INTERLOCKED_CLRCALL_PURE_OR_CDECL _InterlockedIncrement( long volatile * ); +extern "C" long BOOST_INTERLOCKED_CLRCALL_PURE_OR_CDECL _InterlockedDecrement( long volatile * ); +extern "C" long BOOST_INTERLOCKED_CLRCALL_PURE_OR_CDECL _InterlockedCompareExchange( long volatile *, long, long ); +extern "C" long BOOST_INTERLOCKED_CLRCALL_PURE_OR_CDECL _InterlockedExchange( long volatile *, long ); +extern "C" long BOOST_INTERLOCKED_CLRCALL_PURE_OR_CDECL _InterlockedExchangeAdd( long volatile *, long ); + +# undef BOOST_INTERLOCKED_CLRCALL_PURE_OR_CDECL + +# if defined( BOOST_MSVC ) && BOOST_MSVC >= 1310 +# pragma intrinsic( _InterlockedIncrement ) +# pragma intrinsic( _InterlockedDecrement ) +# pragma intrinsic( _InterlockedCompareExchange ) +# pragma intrinsic( _InterlockedExchange ) +# pragma intrinsic( _InterlockedExchangeAdd ) +# endif + +#endif + +# if defined(_M_IA64) || defined(_M_AMD64) + +extern "C" void* __cdecl _InterlockedCompareExchangePointer( void* volatile *, void*, void* ); +extern "C" void* __cdecl _InterlockedExchangePointer( void* volatile *, void* ); + +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER _InterlockedCompareExchangePointer +# define BOOST_INTERLOCKED_EXCHANGE_POINTER _InterlockedExchangePointer + +# else + +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \ + ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare))) +# define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \ + ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange))) + +# endif + +# define BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement +# define BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange +# define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange +# define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd + +// Unlike __MINGW64__, __MINGW64_VERSION_MAJOR is defined by MinGW-w64 for both 32 and 64-bit targets. +#elif defined(__MINGW64_VERSION_MAJOR) + +// MinGW-w64 provides intrin.h for both 32 and 64-bit targets. +#include + +# define BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement +# define BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange +# define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange +# define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd +# if defined(__x86_64__) || defined(__x86_64) +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER _InterlockedCompareExchangePointer +# define BOOST_INTERLOCKED_EXCHANGE_POINTER _InterlockedExchangePointer +# else +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \ + ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare))) +# define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \ + ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange))) +# endif + +#elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ ) + +#define BOOST_INTERLOCKED_IMPORT __declspec(dllimport) + +namespace boost +{ + +namespace detail +{ + +extern "C" BOOST_INTERLOCKED_IMPORT long __stdcall InterlockedIncrement( long volatile * ); +extern "C" BOOST_INTERLOCKED_IMPORT long __stdcall InterlockedDecrement( long volatile * ); +extern "C" BOOST_INTERLOCKED_IMPORT long __stdcall InterlockedCompareExchange( long volatile *, long, long ); +extern "C" BOOST_INTERLOCKED_IMPORT long __stdcall InterlockedExchange( long volatile *, long ); +extern "C" BOOST_INTERLOCKED_IMPORT long __stdcall InterlockedExchangeAdd( long volatile *, long ); + +# if defined(_M_IA64) || defined(_M_AMD64) +extern "C" BOOST_INTERLOCKED_IMPORT void* __stdcall InterlockedCompareExchangePointer( void* volatile *, void*, void* ); +extern "C" BOOST_INTERLOCKED_IMPORT void* __stdcall InterlockedExchangePointer( void* volatile *, void* ); +# endif + +} // namespace detail + +} // namespace boost + +# define BOOST_INTERLOCKED_INCREMENT ::boost::detail::InterlockedIncrement +# define BOOST_INTERLOCKED_DECREMENT ::boost::detail::InterlockedDecrement +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE ::boost::detail::InterlockedCompareExchange +# define BOOST_INTERLOCKED_EXCHANGE ::boost::detail::InterlockedExchange +# define BOOST_INTERLOCKED_EXCHANGE_ADD ::boost::detail::InterlockedExchangeAdd + +# if defined(_M_IA64) || defined(_M_AMD64) +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER ::boost::detail::InterlockedCompareExchangePointer +# define BOOST_INTERLOCKED_EXCHANGE_POINTER ::boost::detail::InterlockedExchangePointer +# else +# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \ + ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare))) +# define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \ + ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange))) +# endif + +#else + +# error "Interlocked intrinsics not available" + +#endif + +#endif // #ifndef BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED diff --git a/libs/context/build/Jamfile.v2 b/libs/context/build/Jamfile.v2 index 7cc8a07..2143ed3 100644 --- a/libs/context/build/Jamfile.v2 +++ b/libs/context/build/Jamfile.v2 @@ -581,6 +581,17 @@ alias asm_context_sources ; alias asm_context_sources + : asm/make_i386_ms_pe_gas.S + asm/jump_i386_ms_pe_gas.S + dummy.cpp + : 32 + x86 + pe + windows + gcc + ; + +alias asm_context_sources : asm/make_i386_ms_pe_masm.asm asm/jump_i386_ms_pe_masm.asm dummy.cpp @@ -715,6 +726,17 @@ alias asm_context_sources ; alias asm_context_sources + : asm/make_x86_64_ms_pe_gas.S + asm/jump_x86_64_ms_pe_gas.S + dummy.cpp + : 64 + x86 + pe + windows + gcc + ; + +alias asm_context_sources : asm/make_x86_64_ms_pe_masm.asm asm/jump_x86_64_ms_pe_masm.asm dummy.cpp diff --git a/libs/context/build/Jamfile.v2.orig b/libs/context/build/Jamfile.v2.orig new file mode 100644 index 0000000..7cc8a07 --- /dev/null +++ b/libs/context/build/Jamfile.v2.orig @@ -0,0 +1,775 @@ + +# Boost.Context Library Build Jamfile + +# 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) + +import common ; +import feature ; +import indirect ; +import modules ; +import os ; +import toolset ; +import architecture ; + +project boost/context + : requirements + SOLARIS:_XOPEN_SOURCE=600 + shared:BOOST_CONTEXT_DYN_LINK=1 + BOOST_CONTEXT_SOURCE + : usage-requirements + shared:BOOST_CONTEXT_DYN_LINK=1 + : source-location ../src + ; + +local rule default_binary_format ( ) +{ + local tmp = elf ; + if [ os.name ] = "MACOSX" { tmp = mach-o ; } + if [ os.name ] = "NT" { tmp = pe ; } + if [ os.name ] = "AIX" { tmp = xcoff ; } + return $(tmp) ; +} + +feature.feature binary-format + : elf + mach-o + pe + xcoff + : propagated + ; +feature.set-default binary-format : [ default_binary_format ] ; + + +local rule default_abi ( ) +{ + local tmp = sysv ; + if [ os.name ] = "NT" { tmp = ms ; } + else if [ os.platform ] = "ARM" { tmp = aapcs ; } + else if [ os.platform ] = "MIPS" { tmp = o32 ; } + return $(tmp) ; +} + +feature.feature abi + : aapcs + eabi + ms + n32 + n64 + o32 + o64 + sysv + x32 + : propagated + ; +feature.set-default abi : [ default_abi ] ; + + +actions gas32 +{ + cpp -x assembler-with-cpp "$(>)" | as --32 -o "$(<)" +} + +actions gas64 +{ + cpp -x assembler-with-cpp "$(>)" | as --64 -o "$(<)" +} + +actions gasx32 +{ + cpp -x assembler-with-cpp "$(>)" | as --x32 -o "$(<)" +} + +actions gas +{ + cpp -x assembler-with-cpp "$(>)" | as -o "$(<)" +} + +actions armasm +{ + armasm "$(>)" "$(<)" +} + +actions masm +{ + ml /c /Fo"$(<)" "$(>)" +} + +actions masm64 +{ + ml64 /c /Fo"$(<)" "$(>)" +} + + +rule configure ( properties * ) +{ + local result ; + +# if ( ! ( gcc in $(properties) +# || intel in $(properties) +# || msvc in $(properties) ) ) +# { +# result = no ; +# ECHO "toolset not supported" ; +# } + + return $(result) ; +} + +# ARM +# ARM/AAPCS/ELF +alias asm_context_sources + : [ make asm/make_arm_aapcs_elf_gas.o : asm/make_arm_aapcs_elf_gas.S : @gas32 ] + [ make asm/jump_arm_aapcs_elf_gas.o : asm/jump_arm_aapcs_elf_gas.S : @gas32 ] + : aapcs + 32 + arm + elf + ; + +alias asm_context_sources + : asm/make_arm_aapcs_elf_gas.S + asm/jump_arm_aapcs_elf_gas.S + : aapcs + 32 + arm + elf + clang + ; + +alias asm_context_sources + : asm/make_arm_aapcs_elf_gas.S + asm/jump_arm_aapcs_elf_gas.S + : aapcs + 32 + arm + elf + gcc + ; + +alias asm_context_sources + : asm/make_arm_aapcs_elf_gas.S + asm/jump_arm_aapcs_elf_gas.S + : aapcs + 32 + arm + elf + qcc + ; +# ARM/AAPCS/MACH-O +alias asm_context_sources + : [ make asm/make_arm_aapcs_macho_gas.o : asm/make_arm_aapcs_macho_gas.S : @gas32 ] + [ make asm/jump_arm_aapcs_macho_gas.o : asm/jump_arm_aapcs_macho_gas.S : @gas32 ] + : aapcs + 32 + arm + mach-o + ; + +alias asm_context_sources + : asm/make_arm_aapcs_macho_gas.S + asm/jump_arm_aapcs_macho_gas.S + : aapcs + 32 + arm + mach-o + clang + ; + +alias asm_context_sources + : asm/make_arm_aapcs_macho_gas.S + asm/jump_arm_aapcs_macho_gas.S + : aapcs + 32 + arm + mach-o + darwin + ; +# ARM/AAPCS/PE +alias asm_context_sources + : [ make asm/make_arm_aapcs_pe_armasm.o : asm/make_arm_aapcs_pe_armasm.asm : @armasm ] + [ make asm/jump_arm_aapcs_pe_armasm.o : asm/jump_arm_aapcs_pe_armasm.asm : @armasm ] + untested.cpp + : aapcs + 32 + arm + pe + ; + +alias asm_context_sources + : asm/make_arm_aapcs_pe_armasm.asm + asm/jump_arm_aapcs_pe_armasm.asm + untested.cpp + : aapcs + 32 + arm + pe + msvc + ; + +# MIPS +# MIPS/O32/ELF +alias asm_context_sources + : [ make asm/make_mips32_o32_elf_gas.o : asm/make_mips32_o32_elf_gas.S : @gas32 ] + [ make asm/jump_mips32_o32_elf_gas.o : asm/jump_mips32_o32_elf_gas.S : @gas32 ] + : o32 + 32 + mips1 + elf + ; + +alias asm_context_sources + : asm/make_mips32_o32_elf_gas.S + asm/jump_mips32_o32_elf_gas.S + : o32 + 32 + mips1 + elf + clang + ; + +alias asm_context_sources + : asm/make_mips32_o32_elf_gas.S + asm/jump_mips32_o32_elf_gas.S + : o32 + 32 + mips1 + elf + gcc + ; + +# POWERPC_32 +# POWERPC_32/SYSV/ELF +alias asm_context_sources + : [ make asm/make_ppc32_sysv_elf_gas.o : asm/make_ppc32_sysv_elf_gas.S : @gas32 ] + [ make asm/jump_ppc32_sysv_elf_gas.o : asm/jump_ppc32_sysv_elf_gas.S : @gas32 ] + : sysv + 32 + power + elf + ; + +alias asm_context_sources + : asm/make_ppc32_sysv_elf_gas.S + asm/jump_ppc32_sysv_elf_gas.S + : sysv + 32 + power + elf + clang + ; + +alias asm_context_sources + : asm/make_ppc32_sysv_elf_gas.S + asm/jump_ppc32_sysv_elf_gas.S + : sysv + 32 + power + elf + gcc + ; +# POWERPC_32/SYSV/MACH-O +alias asm_context_sources + : [ make asm/make_ppc32_sysv_macho_gas.o : asm/make_ppc32_sysv_macho_gas.S : @gas32 ] + [ make asm/jump_ppc32_sysv_macho_gas.o : asm/jump_ppc32_sysv_macho_gas.S : @gas32 ] + : sysv + 32 + power + mach-o + ; + +alias asm_context_sources + : asm/make_ppc32_sysv_macho_gas.S + asm/jump_ppc32_sysv_macho_gas.S + : sysv + 32 + power + mach-o + clang + ; + +alias asm_context_sources + : asm/make_ppc32_sysv_macho_gas.S + asm/jump_ppc32_sysv_macho_gas.S + : sysv + 32 + power + mach-o + darwin + ; +#POWERPC_32/SYSV/XCOFF +alias asm_context_sources + : [ make asm/make_ppc32_sysv_xcoff_gas.o : asm/make_ppc32_sysv_xcoff_gas.S : @gas ] + [ make asm/jump_ppc32_sysv_xcoff_gas.o : asm/jump_ppc32_sysv_xcoff_gas.S : @gas ] + : sysv + 32 + power + xcoff + ; + +alias asm_context_sources + : asm/make_ppc32_sysv_xcoff_gas.S + asm/jump_ppc32_sysv_xcoff_gas.S + : sysv + 32 + power + xcoff + clang + ; + +alias asm_context_sources + : asm/make_ppc32_sysv_xcoff_gas.S + asm/jump_ppc32_sysv_xcoff_gas.S + : sysv + 32 + power + xcoff + gcc + ; + +# POWERPC_64 +# POWERPC_64/SYSV/ELF +alias asm_context_sources + : [ make asm/make_ppc64_sysv_elf_gas.o : asm/make_ppc64_sysv_elf_gas.S : @gas64 ] + [ make asm/jump_ppc64_sysv_elf_gas.o : asm/jump_ppc64_sysv_elf_gas.S : @gas64 ] + : sysv + 64 + power + elf + ; + +alias asm_context_sources + : asm/make_ppc64_sysv_elf_gas.S + asm/jump_ppc64_sysv_elf_gas.S + : sysv + 64 + power + elf + clang + ; + +alias asm_context_sources + : asm/make_ppc64_sysv_elf_gas.S + asm/jump_ppc64_sysv_elf_gas.S + : sysv + 64 + power + elf + gcc + ; +# POWERPC_64/SYSV/MACH-O +alias asm_context_sources + : [ make asm/make_ppc64_sysv_macho_gas.o : asm/make_ppc64_sysv_macho_gas.S : @gas ] + [ make asm/jump_ppc64_sysv_macho_gas.o : asm/jump_ppc64_sysv_macho_gas.S : @gas ] + untested.cpp + : sysv + 64 + power + mach-o + ; + +alias asm_context_sources + : asm/make_ppc64_sysv_macho_gas.S + asm/jump_ppc64_sysv_macho_gas.S + untested.cpp + : sysv + 64 + power + mach-o + clang + ; + +alias asm_context_sources + : asm/make_ppc64_sysv_macho_gas.S + asm/jump_ppc64_sysv_macho_gas.S + untested.cpp + : sysv + 64 + power + mach-o + darwin + ; +# POWERPC_64/SYSV/XCOFF +alias asm_context_sources + : [ make asm/make_ppc64_sysv_xcoff_gas.o : asm/make_ppc64_sysv_xcoff_gas.S : @gas ] + [ make asm/jump_ppc64_sysv_xcoff_gas.o : asm/jump_ppc64_sysv_xcoff_gas.S : @gas ] + : sysv + 64 + power + xcoff + ; + +alias asm_context_sources + : asm/make_ppc64_sysv_xcoff_gas.S + asm/jump_ppc64_sysv_xcoff_gas.S + : sysv + 64 + power + xcoff + clang + ; + +alias asm_context_sources + : asm/make_ppc64_sysv_xcoff_gas.S + asm/jump_ppc64_sysv_xcoff_gas.S + : sysv + 64 + power + xcoff + gcc + ; + +# POWERPC universal +# POWERPC_32_64/SYSV/MACH-O +alias asm_context_sources + : asm/make_ppc32_ppc64_sysv_macho_gas.S + asm/jump_ppc32_ppc64_sysv_macho_gas.S + : sysv + 32_64 + power + mach-o + ; + +# SPARC +# SPARC/SYSV/ELF +alias asm_context_sources + : [ make asm/make_sparc_sysv_elf_gas.o : asm/make_sparc_sysv_elf_gas.S : @gas32 ] + [ make asm/jump_sparc_sysv_elf_gas.o : asm/jump_sparc_sysv_elf_gas.S : @gas32 ] + unsupported.cpp + : sysv + 32 + sparc + elf + ; + +alias asm_context_sources + : asm/make_sparc_sysv_elf_gas.S + asm/jump_sparc_sysv_elf_gas.S + unsupported.cpp + : sysv + 32 + sparc + elf + clang + ; + +alias asm_context_sources + : asm/make_sparc_sysv_elf_gas.S + asm/jump_sparc_sysv_elf_gas.S + unsupported.cpp + : sysv + 32 + sparc + elf + gcc + ; + +# SPARC_64 +# SPARC_64/SYSV/ELF +alias asm_context_sources + : [ make asm/make_sparc64_sysv_elf_gas.o : asm/make_sparc64_sysv_elf_gas.S : @gas64 ] + [ make asm/jump_sparc64_sysv_elf_gas.o : asm/jump_sparc64_sysv_elf_gas.S : @gas64 ] + unsupported.cpp + : sysv + 64 + sparc + elf + ; + +alias asm_context_sources + : asm/make_sparc64_sysv_elf_gas.S + asm/jump_sparc64_sysv_elf_gas.S + unsupported.cpp + : sysv + 64 + sparc + elf + clang + ; + +alias asm_context_sources + : asm/make_sparc64_sysv_elf_gas.S + asm/jump_sparc64_sysv_elf_gas.S + unsupported.cpp + : sysv + 64 + sparc + elf + gcc + ; + +# X86 +# X86/SYSV/ELF +alias asm_context_sources + : [ make asm/make_i386_sysv_elf_gas.o : asm/make_i386_sysv_elf_gas.S : @gas32 ] + [ make asm/jump_i386_sysv_elf_gas.o : asm/jump_i386_sysv_elf_gas.S : @gas32 ] + : sysv + 32 + x86 + elf + ; + +alias asm_context_sources + : asm/make_i386_sysv_elf_gas.S + asm/jump_i386_sysv_elf_gas.S + : sysv + 32 + x86 + elf + clang + ; + +alias asm_context_sources + : asm/make_i386_sysv_elf_gas.S + asm/jump_i386_sysv_elf_gas.S + : sysv + 32 + x86 + elf + gcc + ; + +alias asm_context_sources + : asm/make_i386_sysv_elf_gas.S + asm/jump_i386_sysv_elf_gas.S + : sysv + 32 + x86 + elf + intel + ; +# X86/SYSV/MACH-O +alias asm_context_sources + : [ make asm/make_i386_sysv_macho_gas.o : asm/make_i386_sysv_macho_gas.S : @gas32 ] + [ make asm/jump_i386_sysv_macho_gas.o : asm/jump_i386_sysv_macho_gas.S : @gas32 ] + : sysv + 32 + x86 + mach-o + ; + +alias asm_context_sources + : asm/make_i386_sysv_macho_gas.S + asm/jump_i386_sysv_macho_gas.S + : sysv + 32 + x86 + mach-o + clang + ; + +alias asm_context_sources + : asm/make_i386_sysv_macho_gas.S + asm/jump_i386_sysv_macho_gas.S + : sysv + 32 + x86 + mach-o + darwin + ; +# X86/MS/PE +alias asm_context_sources + : [ make asm/make_i386_ms_pe_masm.o : asm/make_i386_ms_pe_masm.asm : @masm ] + [ make asm/jump_i386_ms_pe_masm.o : asm/jump_i386_ms_pe_masm.asm : @masm ] + dummy.cpp + : ms + 32 + x86 + pe + ; + +alias asm_context_sources + : asm/make_i386_ms_pe_masm.asm + asm/jump_i386_ms_pe_masm.asm + dummy.cpp + : ms + 32 + x86 + pe + intel + ; + +alias asm_context_sources + : asm/make_i386_ms_pe_masm.asm + asm/jump_i386_ms_pe_masm.asm + dummy.cpp + : ms + 32 + x86 + pe + msvc + ; + +# X86_64 +# X86_64/SYSV/ELF +alias asm_context_sources + : [ make asm/make_x86_64_sysv_elf_gas.o : asm/make_x86_64_sysv_elf_gas.S : @gas64 ] + [ make asm/jump_x86_64_sysv_elf_gas.o : asm/jump_x86_64_sysv_elf_gas.S : @gas64 ] + : sysv + 64 + x86 + elf + ; + +alias asm_context_sources + : asm/make_x86_64_sysv_elf_gas.S + asm/jump_x86_64_sysv_elf_gas.S + : sysv + 64 + x86 + elf + clang + ; + +alias asm_context_sources + : asm/make_x86_64_sysv_elf_gas.S + asm/jump_x86_64_sysv_elf_gas.S + : sysv + 64 + x86 + elf + gcc + ; + +alias asm_context_sources + : asm/make_x86_64_sysv_elf_gas.S + asm/jump_x86_64_sysv_elf_gas.S + : sysv + 64 + x86 + elf + intel + ; +# X86_64/X32/ELF +alias asm_context_sources + : [ make asm/make_x86_64_x32_elf_gas.o : asm/make_x86_64_x32_elf_gas.S : @gasx32 ] + [ make asm/jump_x86_64_x32_elf_gas.o : asm/jump_x86_64_x32_elf_gas.S : @gasx32 ] + untested.cpp + : x32 + 32 + x86 + elf + ; + +alias asm_context_sources + : asm/make_x86_64_x32_elf_gas.S + asm/jump_x86_64_x32_elf_gas.S + untested.cpp + : x32 + 32 + x86 + elf + clang + ; + +alias asm_context_sources + : asm/make_x86_64_x32_elf_gas.S + asm/jump_x86_64_x32_elf_gas.S + untested.cpp + : x32 + 32 + x86 + elf + gcc + ; +# X86_64/SYSV/MACH-O +alias asm_context_sources + : [ make asm/make_x86_64_sysv_macho_gas.o : asm/make_x86_64_sysv_macho_gas.S : @gas64 ] + [ make asm/jump_x86_64_sysv_macho_gas.o : asm/jump_x86_64_sysv_macho_gas.S : @gas64 ] + : sysv + 64 + x86 + mach-o + ; + +alias asm_context_sources + : asm/make_x86_64_sysv_macho_gas.S + asm/jump_x86_64_sysv_macho_gas.S + : sysv + 64 + x86 + mach-o + clang + ; + +alias asm_context_sources + : asm/make_x86_64_sysv_macho_gas.S + asm/jump_x86_64_sysv_macho_gas.S + : sysv + 64 + x86 + mach-o + darwin + ; +# X86_64/MS/PE +alias asm_context_sources + : [ make asm/make_x86_64_ms_pe_masm.o : asm/make_x86_64_ms_pe_masm.asm : @masm64 ] + [ make asm/jump_x86_64_ms_pe_masm.o : asm/jump_x86_64_ms_pe_masm.asm : @masm64 ] + dummy.cpp + : ms + 64 + x86 + pe + ; + +alias asm_context_sources + : asm/make_x86_64_ms_pe_masm.asm + asm/jump_x86_64_ms_pe_masm.asm + dummy.cpp + : ms + 64 + x86 + pe + intel + ; + +alias asm_context_sources + : asm/make_x86_64_ms_pe_masm.asm + asm/jump_x86_64_ms_pe_masm.asm + dummy.cpp + : ms + 64 + x86 + pe + msvc + ; + +#X86 universal +alias asm_context_sources + : asm/make_i386_x86_64_sysv_macho_gas.S + asm/jump_i386_x86_64_sysv_macho_gas.S + : sysv + 32_64 + x86 + mach-o + ; + +# COMBINED +alias asm_context_sources + : asm/make_combined_sysv_macho_gas.S + asm/jump_combined_sysv_macho_gas.S + : sysv + combined + mach-o + ; + + +alias asm_context_sources + : unsupported.cpp + ; + +explicit asm_context_sources ; + +alias select_asm_context_sources + : asm_context_sources + : [ architecture.architecture ] + [ architecture.address-model ] + ; + +lib boost_context + : select_asm_context_sources + ; + +boost-install boost_context ; diff --git a/libs/context/src/asm/jump_i386_ms_pe_gas.S b/libs/context/src/asm/jump_i386_ms_pe_gas.S new file mode 100644 index 0000000..84ab084 --- /dev/null +++ b/libs/context/src/asm/jump_i386_ms_pe_gas.S @@ -0,0 +1,108 @@ +/* + Copyright Oliver Kowalke 2009. + Copyright Thomas Sailer 2013. + 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 | * + * -------------------------------------------------------------- * + * | 0h | 04h | 08h | 0ch | 010h | 014h | * + * -------------------------------------------------------------- * + * | EDI | ESI | EBX | EBP | ESP | EIP | * + * -------------------------------------------------------------- * + * -------------------------------------------------------------- * + * | 6 | 7 | 8 | | * + * -------------------------------------------------------------- * + * | 018h | 01ch | 020h | | * + * -------------------------------------------------------------- * + * | sp | size | limit | | * + * -------------------------------------------------------------- * + * -------------------------------------------------------------- * + * | 9 | | * + * -------------------------------------------------------------- * + * | 024h | | * + * -------------------------------------------------------------- * + * |fc_execpt| | * + * -------------------------------------------------------------- * + * -------------------------------------------------------------- * + * | 10 | | * + * -------------------------------------------------------------- * + * | 028h | | * + * -------------------------------------------------------------- * + * |fc_strage| | * + * -------------------------------------------------------------- * + * -------------------------------------------------------------- * + * | 11 | 12 | | * + * -------------------------------------------------------------- * + * | 02ch | 030h | | * + * -------------------------------------------------------------- * + * | fc_mxcsr|fc_x87_cw| | * + * -------------------------------------------------------------- * + * * + * *****************************************************************/ + +.file "jump_i386_ms_pe_gas.S" +.text +.p2align 4,,15 +.globl _jump_fcontext +.def _jump_fcontext; .scl 2; .type 32; .endef +_jump_fcontext: + movl 0x04(%esp), %ecx /* load address of the first fcontext_t arg */ + movl %edi, (%ecx) /* save EDI */ + movl %esi, 0x04(%ecx) /* save ESI */ + movl %ebx, 0x08(%ecx) /* save EBX */ + movl %ebp, 0x0c(%ecx) /* save EBP */ + + movl %fs:(0x18), %edx /* load NT_TIB */ + movl (%edx), %eax /* load current SEH exception list */ + movl %eax, 0x24(%ecx) /* save current exception list */ + movl 0x04(%edx), %eax /* load current stack base */ + movl %eax, 0x18(%ecx) /* save current stack base */ + movl 0x08(%edx), %eax /* load current stack limit */ + movl %eax, 0x20(%ecx) /* save current stack limit */ + movl 0x10(%edx), %eax /* load fiber local storage */ + movl %eax, 0x28(%ecx) /* save fiber local storage */ + + leal 0x04(%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 0x08(%esp), %edx /* load address of the second fcontext_t arg */ + movl (%edx), %edi /* restore EDI */ + movl 0x04(%edx), %esi /* restore ESI */ + movl 0x08(%edx), %ebx /* restore EBX */ + movl 0x0c(%edx), %ebp /* restore EBP */ + + movl 0x10(%esp), %eax /* check if fpu enve preserving was requested */ + testl %eax, %eax + je 1f + + stmxcsr 0x2c(%ecx) /* save MMX control word */ + fnstcw 0x30(%ecx) /* save x87 control word */ + ldmxcsr 0x2c(%edx) /* restore MMX control word */ + fldcw 0x30(%edx) /* restore x87 control word */ +1: + movl %edx, %ecx + movl %fs:(0x18), %edx /* load NT_TIB */ + movl 0x24(%ecx), %eax /* load SEH exception list */ + movl %eax, (%edx) /* restore next SEH item */ + movl 0x18(%ecx), %eax /* load stack base */ + movl %eax, 0x04(%edx) /* restore stack base */ + movl 0x20(%ecx), %eax /* load stack limit */ + movl %eax, 0x08(%edx) /* restore stack limit */ + movl 0x28(%ecx), %eax /* load fiber local storage */ + movl %eax, 0x10(%edx) /* restore fiber local storage */ + + movl 0x0c(%esp), %eax /* use third arg as return value after jump */ + + movl 0x10(%ecx), %esp /* restore ESP */ + movl %eax, 0x04(%esp) /* use third arg as first arg in context function */ + movl 0x14(%ecx), %ecx /* fetch the address to return to */ + + jmp *%ecx /* indirect jump to context */ diff --git a/libs/context/src/asm/jump_x86_64_ms_pe_gas.S b/libs/context/src/asm/jump_x86_64_ms_pe_gas.S new file mode 100644 index 0000000..32aa2a5 --- /dev/null +++ b/libs/context/src/asm/jump_x86_64_ms_pe_gas.S @@ -0,0 +1,189 @@ +/* + Copyright Oliver Kowalke 2009. + Copyright Thomas Sailer 2013. + 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 | * + * ---------------------------------------------------------------------------------- * + * | R12 | R13 | R14 | R15 | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * + * ---------------------------------------------------------------------------------- * + * | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | * + * ---------------------------------------------------------------------------------- * + * | RDI | RSI | RBX | RBP | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 16 | 17 | 18 | 19 | | * + * ---------------------------------------------------------------------------------- * + * | 0x40 | 0x44 | 0x48 | 0x4c | | * + * ---------------------------------------------------------------------------------- * + * | RSP | RIP | | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 20 | 21 | 22 | 23 | 24 | 25 | | * + * ---------------------------------------------------------------------------------- * + * | 0x50 | 0x54 | 0x58 | 0x5c | 0x60 | 0x64 | | * + * ---------------------------------------------------------------------------------- * + * | sp | size | limit | | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 26 | 27 | | * + * ---------------------------------------------------------------------------------- * + * | 0x68 | 0x6c | | * + * ---------------------------------------------------------------------------------- * + * | fbr_strg | | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | * + * ---------------------------------------------------------------------------------- * + * | 0x70 | 0x74 | 0x78 | 0x7c | 0x80 | 0x84 | 0x88 | 0x8c | * + * ---------------------------------------------------------------------------------- * + * | fc_mxcsr|fc_x87_cw| fc_xmm | SEE registers (XMM6-XMM15) | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | * + * ---------------------------------------------------------------------------------- * + * | 0x90 | 0x94 | 0x98 | 0x9c | 0xa0 | 0xa4 | 0xa8 | 0xac | * + * ---------------------------------------------------------------------------------- * + * | SEE registers (XMM6-XMM15) | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | * + * ---------------------------------------------------------------------------------- * + * | 0xb0 | 0xb4 | 0xb8 | 0xbc | 0xc0 | 0xc4 | 0xc8 | 0xcc | * + * ---------------------------------------------------------------------------------- * + * | SEE registers (XMM6-XMM15) | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | * + * ---------------------------------------------------------------------------------- * + * | 0xd0 | 0xd4 | 0xd8 | 0xdc | 0xe0 | 0xe4 | 0xe8 | 0xec | * + * ---------------------------------------------------------------------------------- * + * | SEE registers (XMM6-XMM15) | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | * + * ---------------------------------------------------------------------------------- * + * | 0xf0 | 0xf4 | 0xf8 | 0xfc | 0x100 | 0x104 | 0x108 | 0x10c | * + * ---------------------------------------------------------------------------------- * + * | SEE registers (XMM6-XMM15) | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | * + * ---------------------------------------------------------------------------------- * + * | 0x110 | 0x114 | 0x118 | 0x11c | 0x120 | 0x124 | 0x128 | 0x12c | * + * ---------------------------------------------------------------------------------- * + * | SEE registers (XMM6-XMM15) | * + * ---------------------------------------------------------------------------------- * + * * + * *************************************************************************************/ + +.file "jump_x86_64_ms_pe_gas.S" +.text +.p2align 4,,15 +.globl jump_fcontext +.def jump_fcontext; .scl 2; .type 32; .endef +.seh_proc jump_fcontext +jump_fcontext: +.seh_endprologue + movq %r12, (%rcx) /* save R12 */ + movq %r13, 0x08(%rcx) /* save R13 */ + movq %r14, 0x10(%rcx) /* save R14 */ + movq %r15, 0x18(%rcx) /* save R15 */ + movq %rdi, 0x20(%rcx) /* save RDI */ + movq %rsi, 0x28(%rcx) /* save RSI */ + movq %rbx, 0x30(%rcx) /* save RBX */ + movq %rbp, 0x38(%rcx) /* save RBP */ + + movq %gs:(0x30), %r10 /* load NT_TIB */ + movq 0x08(%r10), %rax /* load current stack base */ + movq %rax, 0x50(%rcx) /* save current stack base */ + movq 0x10(%r10), %rax /* load current stack limit */ + movq %rax, 0x60(%rcx) /* save current stack limit */ + movq 0x18(%r10), %rax /* load fiber local storage */ + movq %rax, 0x68(%rcx) /* save fiber local storage */ + + testq %r9, %r9 + je 1f + + stmxcsr 0x70(%rcx) /* save MMX control and status word */ + fnstcw 0x74(%rcx) /* save x87 control word */ + /* save XMM storage */ + /* save start address of SSE register block in R10 */ + leaq 0x90(%rcx), %r10 + /* shift address in R10 to lower 16 byte boundary */ + /* == pointer to SEE register block */ + andq $-16, %r10 + + movaps %xmm6, (%r10) + movaps %xmm7, 0x10(%r10) + movaps %xmm8, 0x20(%r10) + movaps %xmm9, 0x30(%r10) + movaps %xmm10, 0x40(%r10) + movaps %xmm11, 0x50(%r10) + movaps %xmm12, 0x60(%r10) + movaps %xmm13, 0x70(%r10) + movaps %xmm14, 0x80(%r10) + movaps %xmm15, 0x90(%r10) + + ldmxcsr 0x70(%rdx) /* restore MMX control and status word */ + fldcw 0x74(%rdx) /* restore x87 control word */ + /* restore XMM storage */ + /* save start address of SSE register block in R10 */ + leaq 0x90(%rdx), %r10 + /* shift address in R10 to lower 16 byte boundary */ + /* == pointer to SEE register block */ + andq $-16, %r10 + + movaps (%r10), %xmm6 + movaps 0x10(%r10), %xmm7 + movaps 0x20(%r10), %xmm8 + movaps 0x30(%r10), %xmm9 + movaps 0x40(%r10), %xmm10 + movaps 0x50(%r10), %xmm11 + movaps 0x60(%r10), %xmm12 + movaps 0x70(%r10), %xmm13 + movaps 0x80(%r10), %xmm14 + movaps 0x90(%r10), %xmm15 + +1: + leaq 0x08(%rsp), %rax /* exclude the return address */ + movq %rax, 0x40(%rcx) /* save as stack pointer */ + movq (%rsp), %rax /* load return address */ + movq %rax, 0x48(%rcx) /* save return address */ + + movq (%rdx), %r12 /* restore R12 */ + movq 0x08(%rdx), %r13 /* restore R13 */ + movq 0x10(%rdx), %r14 /* restore R14 */ + movq 0x18(%rdx), %r15 /* restore R15 */ + movq 0x20(%rdx), %rdi /* restore RDI */ + movq 0x28(%rdx), %rsi /* restore RSI */ + movq 0x30(%rdx), %rbx /* restore RBX */ + movq 0x38(%rdx), %rbp /* restore RBP */ + + movq %gs:(0x30), %r10 /* load NT_TIB */ + movq 0x50(%rdx), %rax /* load stack base */ + movq %rax, 0x08(%r10) /* restore stack base */ + movq 0x60(%rdx), %rax /* load stack limit */ + movq %rax, 0x10(%r10) /* restore stack limit */ + movq 0x68(%rdx), %rax /* load fiber local storage */ + movq %rax, 0x18(%r10) /* restore fiber local storage */ + + movq 0x40(%rdx), %rsp /* restore RSP */ + movq 0x48(%rdx), %r10 /* fetch the address to returned to */ + + movq %r8, %rax /* use third arg as return value after jump */ + movq %r8, %rcx /* use third arg as first arg in context function */ + + jmp *%r10 /* indirect jump to caller */ +.seh_endproc diff --git a/libs/context/src/asm/make_i386_ms_pe_gas.S b/libs/context/src/asm/make_i386_ms_pe_gas.S new file mode 100644 index 0000000..1b57faa --- /dev/null +++ b/libs/context/src/asm/make_i386_ms_pe_gas.S @@ -0,0 +1,115 @@ +/* + Copyright Oliver Kowalke 2009. + Copyright Thomas Sailer 2013. + 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 | * + * -------------------------------------------------------------- * + * | 0h | 04h | 08h | 0ch | 010h | 014h | * + * -------------------------------------------------------------- * + * | EDI | ESI | EBX | EBP | ESP | EIP | * + * -------------------------------------------------------------- * + * -------------------------------------------------------------- * + * | 6 | 7 | 8 | | * + * -------------------------------------------------------------- * + * | 018h | 01ch | 020h | | * + * -------------------------------------------------------------- * + * | sp | size | limit | | * + * -------------------------------------------------------------- * + * -------------------------------------------------------------- * + * | 9 | | * + * -------------------------------------------------------------- * + * | 024h | | * + * -------------------------------------------------------------- * + * |fc_execpt| | * + * -------------------------------------------------------------- * + * -------------------------------------------------------------- * + * | 10 | | * + * -------------------------------------------------------------- * + * | 028h | | * + * -------------------------------------------------------------- * + * |fc_strage| | * + * -------------------------------------------------------------- * + * -------------------------------------------------------------- * + * | 11 | 12 | | * + * -------------------------------------------------------------- * + * | 02ch | 030h | | * + * -------------------------------------------------------------- * + * | fc_mxcsr|fc_x87_cw| | * + * -------------------------------------------------------------- * + * * + * *****************************************************************/ + +.file "make_i386_ms_pe_gas.S" +.text +.p2align 4,,15 +.globl _make_fcontext +.def _make_fcontext; .scl 2; .type 32; .endef +_make_fcontext: + movl 0x04(%esp), %eax /* load 1. arg of make_fcontext, pointer to context stack (base) */ + leal -0x34(%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 0x04(%esp), %ecx /* load 1. arg of make_fcontext, pointer to context stack (base) */ + movl %ecx, 0x18(%eax) /* save address of context stack (base) in fcontext_t */ + movl 0x08(%esp), %edx /* load 2. arg of make_fcontext, context stack size */ + movl %edx, 0x1c(%eax) /* save context stack size in fcontext_t */ + negl %edx /* negate stack size for LEA instruction (== substraction) */ + leal (%ecx,%edx),%ecx /* compute bottom address of context stack (limit) */ + movl %ecx, 0x20(%eax) /* save address of context stack (limit) in fcontext_t */ + movl 0x0c(%esp), %ecx /* load 3. arg of make_fcontext, pointer to context function */ + movl %ecx, 0x14(%eax) /* save address of context function in fcontext_t */ + + stmxcsr 0x02c(%eax) /* save MMX control word */ + fnstcw 0x030(%eax) /* save x87 control word */ + + leal -0x1c(%eax),%edx /* reserve space for last frame and seh on context stack, (ESP - 0x4) % 16 == 0 */ + movl %edx, 0x10(%eax) /* save address in EDX as stack pointer for context function */ + + movl $finish, %ecx /* abs address of finish */ + movl %ecx, (%edx) /* save address of finish as return address for context function */ + /* entered after context function returns */ + + /* traverse current seh chain to get the last exception handler installed by Windows */ + /* note that on Windows Server 2008 and 2008 R2, SEHOP is activated by default */ + /* the exception handler chain is tested for the presence of ntdll.dll!FinalExceptionHandler */ + /* at its end by RaiseException all seh andlers are disregarded if not present and the */ + /* program is aborted */ + movl %fs:(0x18), %ecx /* load NT_TIB into ECX */ + +walk: + movl (%ecx), %edx /* load 'next' member of current SEH into EDX */ + incl %edx /* test if 'next' of current SEH is last (== 0xffffffff) */ + jz found + decl %edx + xchgl %ecx, %edx /* exchange content; ECX contains address of next SEH */ + jmp walk /* inspect next SEH */ + +found: + movl 0x04(%ecx), %ecx /* load 'handler' member of SEH == address of last SEH handler installed by Windows */ + movl 0x10(%eax), %edx /* load address of stack pointer for context function */ + movl %ecx, 0x18(%edx) /* save address in ECX as SEH handler for context */ + movl $0xffffffff,%ecx /* set ECX to -1 */ + movl %ecx, 0x14(%edx) /* save ECX as next SEH item */ + leal 0x14(%edx), %ecx /* load address of next SEH item */ + movl %ecx, 0x24(%eax) /* save next SEH */ + + 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 + +.def __exit; .scl 2; .type 32; .endef /* standard C library function */ diff --git a/libs/context/src/asm/make_x86_64_ms_pe_gas.S b/libs/context/src/asm/make_x86_64_ms_pe_gas.S new file mode 100644 index 0000000..5bfeeb1 --- /dev/null +++ b/libs/context/src/asm/make_x86_64_ms_pe_gas.S @@ -0,0 +1,132 @@ +/* + Copyright Oliver Kowalke 2009. + Copyright Thomas Sailer 2013. + 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 | * + * ---------------------------------------------------------------------------------- * + * | R12 | R13 | R14 | R15 | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * + * ---------------------------------------------------------------------------------- * + * | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | * + * ---------------------------------------------------------------------------------- * + * | RDI | RSI | RBX | RBP | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 16 | 17 | 18 | 19 | | * + * ---------------------------------------------------------------------------------- * + * | 0x40 | 0x44 | 0x48 | 0x4c | | * + * ---------------------------------------------------------------------------------- * + * | RSP | RIP | | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 20 | 21 | 22 | 23 | 24 | 25 | | * + * ---------------------------------------------------------------------------------- * + * | 0x50 | 0x54 | 0x58 | 0x5c | 0x60 | 0x64 | | * + * ---------------------------------------------------------------------------------- * + * | sp | size | limit | | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 26 | 27 | | * + * ---------------------------------------------------------------------------------- * + * | 0x68 | 0x6c | | * + * ---------------------------------------------------------------------------------- * + * | fbr_strg | | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | * + * ---------------------------------------------------------------------------------- * + * | 0x70 | 0x74 | 0x78 | 0x7c | 0x80 | 0x84 | 0x88 | 0x8c | * + * ---------------------------------------------------------------------------------- * + * | fc_mxcsr|fc_x87_cw| fc_xmm | SEE registers (XMM6-XMM15) | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | * + * ---------------------------------------------------------------------------------- * + * | 0x90 | 0x94 | 0x98 | 0x9c | 0xa0 | 0xa4 | 0xa8 | 0xac | * + * ---------------------------------------------------------------------------------- * + * | SEE registers (XMM6-XMM15) | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | * + * ---------------------------------------------------------------------------------- * + * | 0xb0 | 0xb4 | 0xb8 | 0xbc | 0xc0 | 0xc4 | 0xc8 | 0xcc | * + * ---------------------------------------------------------------------------------- * + * | SEE registers (XMM6-XMM15) | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | * + * ---------------------------------------------------------------------------------- * + * | 0xd0 | 0xd4 | 0xd8 | 0xdc | 0xe0 | 0xe4 | 0xe8 | 0xec | * + * ---------------------------------------------------------------------------------- * + * | SEE registers (XMM6-XMM15) | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | * + * ---------------------------------------------------------------------------------- * + * | 0xf0 | 0xf4 | 0xf8 | 0xfc | 0x100 | 0x104 | 0x108 | 0x10c | * + * ---------------------------------------------------------------------------------- * + * | SEE registers (XMM6-XMM15) | * + * ---------------------------------------------------------------------------------- * + * ---------------------------------------------------------------------------------- * + * | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | * + * ---------------------------------------------------------------------------------- * + * | 0x110 | 0x114 | 0x118 | 0x11c | 0x120 | 0x124 | 0x128 | 0x12c | * + * ---------------------------------------------------------------------------------- * + * | SEE registers (XMM6-XMM15) | * + * ---------------------------------------------------------------------------------- * + * * + * *************************************************************************************/ + +.file "make_x86_64_ms_pe_gas.S" +.text +.p2align 4,,15 +.globl make_fcontext +.def make_fcontext; .scl 2; .type 32; .endef +.seh_proc make_fcontext +make_fcontext: +.seh_endprologue + leaq -0x130(%rcx),%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 %r8, 0x48(%rax) /* save address of context function in fcontext_t */ + movq %rdx, 0x58(%rax) /* save context stack size in fcontext_t */ + movq %rcx, 0x50(%rax) /* save address of context stack pointer (base) in fcontext_t */ + + negq %rdx /* negate stack size for LEA instruction (== substraction) */ + leaq (%rcx,%rdx),%rcx /* compute bottom address of context stack (limit) */ + movq %rcx, 0x60(%rax) /* save bottom address of context stack (limit) in fcontext_t */ + + stmxcsr 0x70(%rax) /* save MMX control and status word */ + fnstcw 0x74(%rax) /* save x87 control word */ + + leaq -0x28(%rax),%rdx /* reserve 32byte shadow space + return address on stack, (RSP - 0x8) % 16 == 0 */ + movq %rdx, 0x40(%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 + +finish: + /* RSP points to same address as RSP on entry of context function + 0x8 */ + xorq %rcx, %rcx /* exit code is zero */ + call _exit /* exit application */ + hlt +.seh_endproc + +.def _exit; .scl 2; .type 32; .endef /* standard C library function */ -- 2.1.0 From eddef4ea6e60df241c9afa9a6adc909c57f8095c Mon Sep 17 00:00:00 2001 From: Pavel Vatagin Date: Sun, 29 Mar 2015 12:57:11 +0200 Subject: [PATCH 2/3] more fixes taken from https://github.com/boostorg/interprocess/pull/15 diff --git a/boost/interprocess/detail/win32_api.hpp b/boost/interprocess/detail/win32_api.hpp index d9d3e70..7fcc907 100644 --- a/boost/interprocess/detail/win32_api.hpp +++ b/boost/interprocess/detail/win32_api.hpp @@ -28,11 +28,18 @@ #include #include +#if defined (BOOST_INTERPROCESS_WINDOWS) +# include +# include +#else +# error "This file can only be included in Windows OS" +#endif + #ifdef BOOST_USE_WINDOWS_H #include -#include -#include -#include +#include +#include +#include #endif #if defined(_MSC_VER) @@ -44,13 +51,6 @@ # pragma comment( lib, "Shell32.lib" ) //SHGetSpecialFolderPathA #endif -#if defined (BOOST_INTERPROCESS_WINDOWS) -# include -# include -#else -# error "This file can only be included in Windows OS" -#endif - ////////////////////////////////////////////////////////////////////////////// // // Declaration of Windows structures or typedefs if BOOST_USE_WINDOWS_H is used @@ -2252,7 +2252,7 @@ inline bool get_last_bootup_time(std::string &stamp) // Print the contents of each record in the buffer. if(find_record_in_buffer(heap_deleter.get(), dwBytesRead, provider_name, event_id, pTypedRecord)){ char stamp_str[sizeof(unsigned long)*3+1]; - std::sprintf(&stamp_str[0], "%u", ((unsigned int)pTypedRecord->TimeGenerated)); + sprintf(&stamp_str[0], "%u", ((unsigned int)pTypedRecord->TimeGenerated)); stamp = stamp_str; break; } -- 2.1.0 From 9081374d788ead34e417f0fe1aa34310156eb14f Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Sun, 29 Mar 2015 13:00:45 +0200 Subject: [PATCH 3/3] add missing winsock2.h Otherwise windows.h might default to winsock.h. diff --git a/boost/detail/interlocked.hpp b/boost/detail/interlocked.hpp index abc7c6d..2cd60c1 100644 --- a/boost/detail/interlocked.hpp +++ b/boost/detail/interlocked.hpp @@ -24,6 +24,7 @@ #if defined( BOOST_USE_WINDOWS_H ) +# include # include # define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement -- 2.1.0