Files
gentoo/net-libs/nodejs/files/nodejs-24.11.1-restore-ppc64be.patch
2026-03-11 17:52:21 +10:00

110 lines
4.0 KiB
Diff

https://bugs.gentoo.org/971054
From: Marcus Comstedt <marcus@mc.pp.se>
Date: Wed, 6 Jan 2021 13:51:28 +0100
Subject: [PATCH 1/3] Restrict range of random addresses on big endian PPC64
--- a/deps/v8/src/base/platform/platform-posix.cc
+++ b/deps/v8/src/base/platform/platform-posix.cc
@@ -372,6 +372,9 @@ void* OS::GetRandomMmapAddr() {
raw_addr &= uint64_t{0x3FFFF000};
// Use extra address space to isolate the mmap regions.
raw_addr += uint64_t{0x400000000000};
+#elif V8_TARGET_BIG_ENDIAN
+ // Big-endian Linux: 42 bits of virtual addressing.
+ raw_addr &= uint64_t{0x03FFFFFF0000};
#else
// Little-endian Linux: 46 bits of virtual addressing.
raw_addr &= uint64_t{0x3FFFFFFF0000};
--
2.52.0
From f1cd67ed2bb7ef682609cbc271b9fa87f65aa118 Mon Sep 17 00:00:00 2001
From: Marcus Comstedt <marcus@mc.pp.se>
Date: Tue, 4 Jul 2023 18:23:41 +0200
Subject: [PATCH 2/3] Use AIX calling conventions also for Linux with ELFv1
--- a/deps/v8/src/heap/base/asm/ppc/push_registers_asm.cc
+++ b/deps/v8/src/heap/base/asm/ppc/push_registers_asm.cc
@@ -16,9 +16,22 @@
// AIX Runtime process stack:
// https://www.ibm.com/support/knowledgecenter/ssw_aix_71/assembler/idalangref_runtime_process.html
+
+#include "src/codegen/ppc/constants-ppc.h"
+
asm(
+#if ABI_USES_FUNCTION_DESCRIPTORS
#if defined(_AIX)
".csect .text[PR] \n"
+#else
+ /* Linux linker requires the function descriptor to be provided */
+ ".section \".opd\",\"aw\" \n"
+ ".align 3 \n"
+ ".globl PushAllRegistersAndIterateStack, hidden \n"
+ "PushAllRegistersAndIterateStack: \n"
+ ".quad .PushAllRegistersAndIterateStack,.TOC.@tocbase,0 \n"
+ ".text \n"
+#endif
".align 2 \n"
".globl .PushAllRegistersAndIterateStack, hidden \n"
".PushAllRegistersAndIterateStack: \n"
@@ -36,7 +49,7 @@ asm(
// At anytime, SP (r1) needs to be multiple of 16 (i.e. 16-aligned).
" mflr 0 \n"
" std 0, 16(1) \n"
-#if defined(_AIX)
+#if ABI_USES_FUNCTION_DESCRIPTORS
" std 2, 40(1) \n"
#else
" std 2, 24(1) \n"
@@ -64,7 +77,7 @@ asm(
// Pass 2nd parameter (r4) unchanged (StackVisitor*).
// Save 3rd parameter (r5; IterateStackCallback).
" mr 6, 5 \n"
-#if defined(_AIX)
+#if ABI_USES_FUNCTION_DESCRIPTORS
// Set up TOC for callee.
" ld 2,8(5) \n"
// AIX uses function descriptors, which means that
@@ -75,7 +88,7 @@ asm(
#endif
// Pass 3rd parameter as sp (stack pointer).
" mr 5, 1 \n"
-#if !defined(_AIX)
+#if !ABI_USES_FUNCTION_DESCRIPTORS
// Set up r12 to be equal to the callee address (in order for TOC
// relocation). Only needed on LE Linux.
" mr 12, 6 \n"
@@ -88,7 +101,7 @@ asm(
// Restore lr.
" ld 0, 16(1) \n"
" mtlr 0 \n"
-#if defined(_AIX)
+#if ABI_USES_FUNCTION_DESCRIPTORS
// Restore TOC pointer.
" ld 2, 40(1) \n"
#else
--
2.52.0
From 06dfa8798dd4b6d42fb323b86a1a6581d5d9af07 Mon Sep 17 00:00:00 2001
From: Marcus Comstedt <marcus@mc.pp.se>
Date: Thu, 17 Jul 2025 22:32:38 +0200
Subject: [PATCH 3/3] Define V8_TARGET_BIG_ENDIAN for linux/ppc64
--- a/deps/v8/include/v8config.h
+++ b/deps/v8/include/v8config.h
@@ -976,7 +976,7 @@ V8 shared library set USING_V8_SHARED.
#define V8_TARGET_LITTLE_ENDIAN 1
#endif
#elif V8_TARGET_ARCH_PPC64
-#if V8_OS_AIX
+#if defined(__BIG_ENDIAN__) || defined(V8_OS_AIX)
#define V8_TARGET_BIG_ENDIAN 1
#else
#define V8_TARGET_LITTLE_ENDIAN 1
--
2.52.0