Fix aarch64 ucontext layout on Android

BUG=354405,335641
R=mark@chromium.org

Review URL: https://breakpad.appspot.com/1444002

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1306 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
rmcilroy@chromium.org 2014-04-09 09:08:19 +00:00
parent fff818514d
commit 543cf832e6
4 changed files with 23 additions and 9 deletions

View file

@ -90,6 +90,9 @@ breakpad_getcontext:
#elif defined(__aarch64__) #elif defined(__aarch64__)
#define _NSIG 64
#define __NR_rt_sigprocmask 135
.text .text
.global breakpad_getcontext .global breakpad_getcontext
.hidden breakpad_getcontext .hidden breakpad_getcontext

View file

@ -33,11 +33,24 @@
#include "common/android/ucontext_constants.h" #include "common/android/ucontext_constants.h"
TEST(AndroidUContext, GRegsOffset) { TEST(AndroidUContext, GRegsOffset) {
#ifdef __arm__ #if defined(__arm__)
// There is no gregs[] array on ARM, so compare to the offset of // There is no gregs[] array on ARM, so compare to the offset of
// first register fields, since they're stored in order. // first register fields, since they're stored in order.
ASSERT_EQ(static_cast<size_t>(MCONTEXT_GREGS_OFFSET), ASSERT_EQ(static_cast<size_t>(MCONTEXT_GREGS_OFFSET),
offsetof(ucontext_t,uc_mcontext.arm_r0)); offsetof(ucontext_t,uc_mcontext.arm_r0));
#elif defined(__aarch64__)
// There is no gregs[] array on ARM, so compare to the offset of
// first register fields, since they're stored in order.
ASSERT_EQ(static_cast<size_t>(MCONTEXT_GREGS_OFFSET),
offsetof(ucontext_t,uc_mcontext.regs[0]));
ASSERT_EQ(static_cast<size_t>(MCONTEXT_SP_OFFSET),
offsetof(ucontext_t,uc_mcontext.sp));
ASSERT_EQ(static_cast<size_t>(MCONTEXT_PC_OFFSET),
offsetof(ucontext_t,uc_mcontext.pc));
ASSERT_EQ(static_cast<size_t>(MCONTEXT_PSTATE_OFFSET),
offsetof(ucontext_t,uc_mcontext.pstate));
ASSERT_EQ(static_cast<size_t>(MCONTEXT_EXTENSION_OFFSET),
offsetof(ucontext_t,uc_mcontext.__reserved));
#elif defined(__i386__) #elif defined(__i386__)
ASSERT_EQ(static_cast<size_t>(MCONTEXT_GREGS_OFFSET), ASSERT_EQ(static_cast<size_t>(MCONTEXT_GREGS_OFFSET),
offsetof(ucontext_t,uc_mcontext.gregs)); offsetof(ucontext_t,uc_mcontext.gregs));

View file

@ -72,6 +72,7 @@ typedef struct ucontext {
struct ucontext *uc_link; struct ucontext *uc_link;
stack_t uc_stack; stack_t uc_stack;
sigset_t uc_sigmask; sigset_t uc_sigmask;
char __padding[128 - sizeof(sigset_t)];
mcontext_t uc_mcontext; mcontext_t uc_mcontext;
} ucontext_t; } ucontext_t;

View file

@ -49,11 +49,11 @@
#define UCONTEXT_SIGMASK_OFFSET 40 #define UCONTEXT_SIGMASK_OFFSET 40
#define MCONTEXT_GREGS_OFFSET 56 #define MCONTEXT_GREGS_OFFSET 184
#define MCONTEXT_SP_OFFSET 304 #define MCONTEXT_SP_OFFSET 432
#define MCONTEXT_PC_OFFSET 312 #define MCONTEXT_PC_OFFSET 440
#define MCONTEXT_PSTATE_OFFSET 320 #define MCONTEXT_PSTATE_OFFSET 448
#define MCONTEXT_EXTENSION_OFFSET 336 #define MCONTEXT_EXTENSION_OFFSET 464
#define FPSIMD_MAGIC 0x46508001 #define FPSIMD_MAGIC 0x46508001
@ -67,9 +67,6 @@
#define REGISTER_SIZE 8 #define REGISTER_SIZE 8
#define SIMD_REGISTER_SIZE 16 #define SIMD_REGISTER_SIZE 16
#define _NSIG 64
#define __NR_rt_sigprocmask 135
#elif defined(__i386__) #elif defined(__i386__)
#define MCONTEXT_GREGS_OFFSET 20 #define MCONTEXT_GREGS_OFFSET 20