From: Christopher Ferris Date: Fri, 11 Jul 2014 05:43:02 +0000 (+0000) Subject: Revert "Fix mac build" X-Git-Tag: android-x86-7.1-r1~889^2~3609^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=bc8a28896af5b99f0a42028f98bf0c74eb8047c9;p=android-x86%2Fart.git Revert "Fix mac build" This reverts commit e9343344d9bd268a05d1eae1ce80a3278ec19c89. Change-Id: I43d1717af9c3b1237dcacec66f55a4e4b8e1f0fe --- diff --git a/runtime/arch/x86/fault_handler_x86.cc b/runtime/arch/x86/fault_handler_x86.cc index 435f280a6..f62200aab 100644 --- a/runtime/arch/x86/fault_handler_x86.cc +++ b/runtime/arch/x86/fault_handler_x86.cc @@ -26,16 +26,6 @@ #include "thread.h" #include "thread-inl.h" -#if defined(__APPLE__) -#define ucontext __darwin_ucontext -#define CTX_ESP uc_mcontext->__ss.__esp -#define CTX_EIP uc_mcontext->__ss.__eip -#define CTX_EAX uc_mcontext->__ss.__eax -#else -#define CTX_ESP uc_mcontext.gregs[REG_ESP] -#define CTX_EIP uc_mcontext.gregs[REG_EIP] -#define CTX_EAX uc_mcontext.gregs[REG_EAX] -#endif // // X86 specific fault handler functions. @@ -173,7 +163,7 @@ void FaultManager::GetMethodAndReturnPCAndSP(siginfo_t* siginfo, void* context, mirror::ArtMethod** out_method, uintptr_t* out_return_pc, uintptr_t* out_sp) { struct ucontext* uc = reinterpret_cast(context); - *out_sp = static_cast(uc->CTX_ESP); + *out_sp = static_cast(uc->uc_mcontext.gregs[REG_ESP]); VLOG(signals) << "sp: " << std::hex << *out_sp; if (*out_sp == 0) { return; @@ -185,13 +175,13 @@ void FaultManager::GetMethodAndReturnPCAndSP(siginfo_t* siginfo, void* context, uintptr_t* overflow_addr = reinterpret_cast( reinterpret_cast(*out_sp) - GetStackOverflowReservedBytes(kX86)); if (overflow_addr == fault_addr) { - *out_method = reinterpret_cast(uc->CTX_EAX); + *out_method = reinterpret_cast(uc->uc_mcontext.gregs[REG_EAX]); } else { // The method is at the top of the stack. *out_method = reinterpret_cast(reinterpret_cast(*out_sp)[0]); } - uint8_t* pc = reinterpret_cast(uc->CTX_EIP); + uint8_t* pc = reinterpret_cast(uc->uc_mcontext.gregs[REG_EIP]); VLOG(signals) << HexDump(pc, 32, true, "PC "); uint32_t instr_size = GetInstructionSize(pc); @@ -200,8 +190,8 @@ void FaultManager::GetMethodAndReturnPCAndSP(siginfo_t* siginfo, void* context, bool NullPointerHandler::Action(int sig, siginfo_t* info, void* context) { struct ucontext *uc = reinterpret_cast(context); - uint8_t* pc = reinterpret_cast(uc->CTX_EIP); - uint8_t* sp = reinterpret_cast(uc->CTX_ESP); + uint8_t* pc = reinterpret_cast(uc->uc_mcontext.gregs[REG_EIP]); + uint8_t* sp = reinterpret_cast(uc->uc_mcontext.gregs[REG_ESP]); uint32_t instr_size = GetInstructionSize(pc); // We need to arrange for the signal handler to return to the null pointer @@ -213,9 +203,10 @@ bool NullPointerHandler::Action(int sig, siginfo_t* info, void* context) { uint32_t retaddr = reinterpret_cast(pc + instr_size); uint32_t* next_sp = reinterpret_cast(sp - 4); *next_sp = retaddr; - uc->CTX_ESP = reinterpret_cast(next_sp); + uc->uc_mcontext.gregs[REG_ESP] = reinterpret_cast(next_sp); - uc->CTX_EIP = reinterpret_cast(art_quick_throw_null_pointer_exception); + uc->uc_mcontext.gregs[REG_EIP] = + reinterpret_cast(art_quick_throw_null_pointer_exception); VLOG(signals) << "Generating null pointer exception"; return true; } @@ -239,8 +230,8 @@ bool SuspensionHandler::Action(int sig, siginfo_t* info, void* context) { uint8_t checkinst2[] = {0x85, 0x00}; struct ucontext *uc = reinterpret_cast(context); - uint8_t* pc = reinterpret_cast(uc->CTX_EIP); - uint8_t* sp = reinterpret_cast(uc->CTX_ESP); + uint8_t* pc = reinterpret_cast(uc->uc_mcontext.gregs[REG_EIP]); + uint8_t* sp = reinterpret_cast(uc->uc_mcontext.gregs[REG_ESP]); if (pc[0] != checkinst2[0] || pc[1] != checkinst2[1]) { // Second instruction is not correct (test eax,[eax]). @@ -273,9 +264,9 @@ bool SuspensionHandler::Action(int sig, siginfo_t* info, void* context) { uint32_t retaddr = reinterpret_cast(pc + 2); uint32_t* next_sp = reinterpret_cast(sp - 4); *next_sp = retaddr; - uc->CTX_ESP = reinterpret_cast(next_sp); + uc->uc_mcontext.gregs[REG_ESP] = reinterpret_cast(next_sp); - uc->CTX_EIP = reinterpret_cast(art_quick_test_suspend); + uc->uc_mcontext.gregs[REG_EIP] = reinterpret_cast(art_quick_test_suspend); // Now remove the suspend trigger that caused this fault. Thread::Current()->RemoveSuspendTrigger(); @@ -295,7 +286,7 @@ bool SuspensionHandler::Action(int sig, siginfo_t* info, void* context) { bool StackOverflowHandler::Action(int sig, siginfo_t* info, void* context) { struct ucontext *uc = reinterpret_cast(context); - uintptr_t sp = static_cast(uc->CTX_ESP); + uintptr_t sp = static_cast(uc->uc_mcontext.gregs[REG_ESP]); uintptr_t fault_addr = reinterpret_cast(info->si_addr); VLOG(signals) << "fault_addr: " << std::hex << fault_addr; @@ -324,10 +315,11 @@ bool StackOverflowHandler::Action(int sig, siginfo_t* info, void* context) { // the previous frame. // Tell the stack overflow code where the new stack pointer should be. - uc->CTX_EAX = pregion; + uc->uc_mcontext.gregs[REG_EAX] = pregion; // Now arrange for the signal handler to return to art_quick_throw_stack_overflow_from_signal. - uc->CTX_EIP = reinterpret_cast(art_quick_throw_stack_overflow_from_signal); + uc->uc_mcontext.gregs[REG_EIP] = reinterpret_cast( + art_quick_throw_stack_overflow_from_signal); return true; } diff --git a/runtime/arch/x86_64/quick_entrypoints_x86_64.S b/runtime/arch/x86_64/quick_entrypoints_x86_64.S index 885fbfde5..7f7226c0a 100644 --- a/runtime/arch/x86_64/quick_entrypoints_x86_64.S +++ b/runtime/arch/x86_64/quick_entrypoints_x86_64.S @@ -18,7 +18,7 @@ MACRO0(SETUP_FP_CALLEE_SAVE_FRAME) // Create space for ART FP callee-saved registers - subq MACRO_LITERAL(4 * 8), %rsp + subq LITERAL(4 * 8), %rsp CFI_ADJUST_CFA_OFFSET(4 * 8) movq %xmm12, 0(%rsp) movq %xmm13, 8(%rsp) @@ -32,7 +32,7 @@ MACRO0(RESTORE_FP_CALLEE_SAVE_FRAME) movq 8(%rsp), %xmm13 movq 16(%rsp), %xmm14 movq 24(%rsp), %xmm15 - addq MACRO_LITERAL(4 * 8), %rsp + addq LITERAL(4 * 8), %rsp CFI_ADJUST_CFA_OFFSET(- 4 * 8) END_MACRO diff --git a/sigchainlib/Android.mk b/sigchainlib/Android.mk index d86735d12..20c8cacf3 100644 --- a/sigchainlib/Android.mk +++ b/sigchainlib/Android.mk @@ -23,7 +23,6 @@ LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION) LOCAL_MODULE_TAGS := optional LOCAL_CFLAGS += $(ART_TARGET_CFLAGS) LOCAL_SRC_FILES := sigchain.cc -LOCAL_CLANG = $(ART_TARGET_CLANG) LOCAL_MODULE:= libsigchain LOCAL_SHARED_LIBRARIES := liblog libdl LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk @@ -36,7 +35,6 @@ LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION) LOCAL_MODULE_TAGS := optional LOCAL_IS_HOST_MODULE := true LOCAL_CFLAGS += $(ART_HOST_CFLAGS) -LOCAL_CLANG = $(ART_HOST_CLANG) LOCAL_SRC_FILES := sigchain.cc LOCAL_MODULE:= libsigchain LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk diff --git a/sigchainlib/sigchain.cc b/sigchainlib/sigchain.cc index 6f9308383..458ad6958 100644 --- a/sigchainlib/sigchain.cc +++ b/sigchainlib/sigchain.cc @@ -26,10 +26,6 @@ #include #include -#if defined(__APPLE__) -#define _NSIG NSIG -#endif - namespace art { class SignalAction {