Skip to content

Commit 975a7a2

Browse files
author
Gustavo Romero
committed
v8: fix compilation on PPC64 when libc musl is used instead of glibc
Musl on Power does not define regs member as a pt_regs pointer type, hence it's necessary to use member gp_regs instead.
1 parent 66e7dc5 commit 975a7a2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

deps/v8/src/libsampler/sampler.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,17 @@ void SignalHandler::FillRegisterState(void* context, RegisterState* state) {
450450
state->sp = reinterpret_cast<void*>(mcontext.gregs[29]);
451451
state->fp = reinterpret_cast<void*>(mcontext.gregs[30]);
452452
#elif V8_HOST_ARCH_PPC
453+
#if V8_LIBC_GLIBC
453454
state->pc = reinterpret_cast<void*>(ucontext->uc_mcontext.regs->nip);
454-
state->sp =
455-
reinterpret_cast<void*>(ucontext->uc_mcontext.regs->gpr[PT_R1]);
456-
state->fp =
457-
reinterpret_cast<void*>(ucontext->uc_mcontext.regs->gpr[PT_R31]);
455+
state->sp = reinterpret_cast<void*>(ucontext->uc_mcontext.regs->gpr[PT_R1]);
456+
state->fp = reinterpret_cast<void*>(ucontext->uc_mcontext.regs->gpr[PT_R31]);
457+
#else
458+
// Some C libraries, notably Musl, define regs member as a void pointer,
459+
// so gp_regs is used instead.
460+
state->pc = reinterpret_cast<void*>(ucontext->uc_mcontext.gp_regs[32]);
461+
state->sp = reinterpret_cast<void*>(ucontext->uc_mcontext.gp_regs[1]);
462+
state->fp = reinterpret_cast<void*>(ucontext->uc_mcontext.gp_regs[31]);
463+
#endif
458464
#elif V8_HOST_ARCH_S390
459465
#if V8_TARGET_ARCH_32_BIT
460466
// 31-bit target will have bit 0 (MSB) of the PSW set to denote addressing

0 commit comments

Comments
 (0)