Commit 450ada04 authored by Shawn Anastasio's avatar Shawn Anastasio Committed by Commit Bot

ppc: Fix incorrect ABI detection

v8 currently detects ABI by checking OS and endianness,
but this is not sufficient to properly detect cases in
which the ELFv2 ABI is used on big-endian Linux systems.

Update these checks to use additionally use the _CALL_ELF
macro in order to properly handle such cases.

This issue was initially discovered by the Adélie Linux team.

Change-Id: Iefc0510963d93e59d6c62469a505c70c594bb14a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1555424Reviewed-by: 's avatarJunliang Yan <jyan@ca.ibm.com>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#60759}
parent 97562879
...@@ -159,6 +159,7 @@ Sander Mathijs van Veen <sander@leaningtech.com> ...@@ -159,6 +159,7 @@ Sander Mathijs van Veen <sander@leaningtech.com>
Sandro Santilli <strk@keybit.net> Sandro Santilli <strk@keybit.net>
Sanjoy Das <sanjoy@playingwithpointers.com> Sanjoy Das <sanjoy@playingwithpointers.com>
Seo Sanghyeon <sanxiyn@gmail.com> Seo Sanghyeon <sanxiyn@gmail.com>
Shawn Anastasio <shawnanastasio@gmail.com>
Stefan Penner <stefan.penner@gmail.com> Stefan Penner <stefan.penner@gmail.com>
Sylvestre Ledru <sledru@mozilla.com> Sylvestre Ledru <sledru@mozilla.com>
Taketoshi Aono <brn@b6n.ch> Taketoshi Aono <brn@b6n.ch>
......
...@@ -316,7 +316,8 @@ F FUNCTION_CAST(Address addr) { ...@@ -316,7 +316,8 @@ F FUNCTION_CAST(Address addr) {
// which provide a level of indirection between the function pointer // which provide a level of indirection between the function pointer
// and the function entrypoint. // and the function entrypoint.
#if V8_HOST_ARCH_PPC && \ #if V8_HOST_ARCH_PPC && \
(V8_OS_AIX || (V8_TARGET_ARCH_PPC64 && V8_TARGET_BIG_ENDIAN)) (V8_OS_AIX || (V8_TARGET_ARCH_PPC64 && V8_TARGET_BIG_ENDIAN && \
(!defined(_CALL_ELF) || _CALL_ELF == 1)))
#define USES_FUNCTION_DESCRIPTORS 1 #define USES_FUNCTION_DESCRIPTORS 1
#define FUNCTION_ENTRYPOINT_ADDRESS(f) \ #define FUNCTION_ENTRYPOINT_ADDRESS(f) \
(reinterpret_cast<v8::internal::Address*>( \ (reinterpret_cast<v8::internal::Address*>( \
......
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
#endif #endif
#if V8_HOST_ARCH_PPC && \ #if V8_HOST_ARCH_PPC && \
(V8_OS_AIX || (V8_TARGET_ARCH_PPC64 && V8_TARGET_BIG_ENDIAN)) (V8_OS_AIX || (V8_TARGET_ARCH_PPC64 && V8_TARGET_BIG_ENDIAN && \
(!defined(_CALL_ELF) || _CALL_ELF == 1)))
#define ABI_USES_FUNCTION_DESCRIPTORS 1 #define ABI_USES_FUNCTION_DESCRIPTORS 1
#else #else
#define ABI_USES_FUNCTION_DESCRIPTORS 0 #define ABI_USES_FUNCTION_DESCRIPTORS 0
...@@ -33,13 +34,15 @@ ...@@ -33,13 +34,15 @@
#define ABI_PASSES_HANDLES_IN_REGS 0 #define ABI_PASSES_HANDLES_IN_REGS 0
#endif #endif
#if !V8_HOST_ARCH_PPC || !V8_TARGET_ARCH_PPC64 || V8_TARGET_LITTLE_ENDIAN #if !V8_HOST_ARCH_PPC || !V8_TARGET_ARCH_PPC64 || \
V8_TARGET_LITTLE_ENDIAN || (defined(_CALL_ELF) && _CALL_ELF == 2)
#define ABI_RETURNS_OBJECT_PAIRS_IN_REGS 1 #define ABI_RETURNS_OBJECT_PAIRS_IN_REGS 1
#else #else
#define ABI_RETURNS_OBJECT_PAIRS_IN_REGS 0 #define ABI_RETURNS_OBJECT_PAIRS_IN_REGS 0
#endif #endif
#if !V8_HOST_ARCH_PPC || (V8_TARGET_ARCH_PPC64 && V8_TARGET_LITTLE_ENDIAN) #if !V8_HOST_ARCH_PPC || (V8_TARGET_ARCH_PPC64 && (V8_TARGET_LITTLE_ENDIAN || \
(defined(_CALL_ELF) && _CALL_ELF == 2)))
#define ABI_CALL_VIA_IP 1 #define ABI_CALL_VIA_IP 1
#else #else
#define ABI_CALL_VIA_IP 0 #define ABI_CALL_VIA_IP 0
......
...@@ -145,7 +145,8 @@ const int kNumSafepointRegisters = 32; ...@@ -145,7 +145,8 @@ const int kNumSafepointRegisters = 32;
// The following constants describe the stack frame linkage area as // The following constants describe the stack frame linkage area as
// defined by the ABI. Note that kNumRequiredStackFrameSlots must // defined by the ABI. Note that kNumRequiredStackFrameSlots must
// satisfy alignment requirements (rounding up if required). // satisfy alignment requirements (rounding up if required).
#if V8_TARGET_ARCH_PPC64 && V8_TARGET_LITTLE_ENDIAN // ppc64le linux #if V8_TARGET_ARCH_PPC64 && (V8_TARGET_LITTLE_ENDIAN || \
(defined(_CALL_ELF) && _CALL_ELF == 2)) // ELFv2 ABI
// [0] back chain // [0] back chain
// [1] condition register save area // [1] condition register save area
// [2] link register save area // [2] link register save area
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment