|
|
e7106e |
From eea4ad2cce289753aaa35b4e0258a76d8f8f367c Mon Sep 17 00:00:00 2001
|
|
|
e7106e |
From: Thierry Fauck <thierry@linux.vnet.ibm.com>
|
|
|
e7106e |
Date: Tue, 13 May 2014 07:48:24 -0400
|
|
|
e7106e |
Subject: [PATCH] Support for powerpc64 arch ppc64el
|
|
|
e7106e |
|
|
|
e7106e |
Signed-off-by: Thierry Fauck <thierry@linux.vnet.ibm.com>
|
|
|
e7106e |
|
|
|
e7106e |
Add support for ppc64le proc and ELF ABIv2.
|
|
|
e7106e |
Provides support for irelative and wchar
|
|
|
e7106e |
---
|
|
|
e7106e |
ltrace-elf.c | 2 +-
|
|
|
e7106e |
ltrace-elf.h | 1 +
|
|
|
e7106e |
sysdeps/linux-gnu/ppc/arch.h | 35 ++++-
|
|
|
e7106e |
sysdeps/linux-gnu/ppc/fetch.c | 244 +++++++++++++++++++++++++++++---
|
|
|
e7106e |
sysdeps/linux-gnu/ppc/plt.c | 98 ++++++++++++--
|
|
|
e7106e |
sysdeps/linux-gnu/ppc/trace.c | 10 ++
|
|
|
e7106e |
testsuite/ltrace.main/system_calls.exp | 2 +-
|
|
|
e7106e |
7 files changed, 356 insertions(+), 36 deletions(-)
|
|
|
e7106e |
|
|
|
e7106e |
diff --git a/ltrace-elf.c b/ltrace-elf.c
|
|
|
e7106e |
index 8997518..f638342 100644
|
|
|
e7106e |
--- a/ltrace-elf.c
|
|
|
e7106e |
+++ b/ltrace-elf.c
|
|
|
e7106e |
@@ -859,7 +859,7 @@ populate_plt(struct process *proc, const char *filename,
|
|
|
e7106e |
return 0;
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
-static void
|
|
|
e7106e |
+void
|
|
|
e7106e |
delete_symbol_chain(struct library_symbol *libsym)
|
|
|
e7106e |
{
|
|
|
e7106e |
while (libsym != NULL) {
|
|
|
e7106e |
diff --git a/ltrace-elf.h b/ltrace-elf.h
|
|
|
e7106e |
index db4ffe9..4a824c4 100644
|
|
|
e7106e |
--- a/ltrace-elf.h
|
|
|
e7106e |
+++ b/ltrace-elf.h
|
|
|
e7106e |
@@ -166,6 +166,7 @@ int elf_read_next_uleb128(Elf_Data *data, GElf_Xword *offset, uint64_t *retp);
|
|
|
e7106e |
/* Return whether there's AMOUNT more bytes after OFFSET in DATA. */
|
|
|
e7106e |
int elf_can_read_next(Elf_Data *data, GElf_Xword offset, GElf_Xword amount);
|
|
|
e7106e |
|
|
|
e7106e |
+void delete_symbol_chain(struct library_symbol *);
|
|
|
e7106e |
#if __WORDSIZE == 32
|
|
|
e7106e |
#define PRI_ELF_ADDR PRIx32
|
|
|
e7106e |
#define GELF_ADDR_CAST(x) (void *)(uint32_t)(x)
|
|
|
e7106e |
diff --git a/sysdeps/linux-gnu/ppc/arch.h b/sysdeps/linux-gnu/ppc/arch.h
|
|
|
e7106e |
index bf9b5dc..7918a13 100644
|
|
|
e7106e |
--- a/sysdeps/linux-gnu/ppc/arch.h
|
|
|
e7106e |
+++ b/sysdeps/linux-gnu/ppc/arch.h
|
|
|
e7106e |
@@ -23,8 +23,8 @@
|
|
|
e7106e |
#define LTRACE_PPC_ARCH_H
|
|
|
e7106e |
|
|
|
e7106e |
#include <gelf.h>
|
|
|
e7106e |
+#include <stdbool.h>
|
|
|
e7106e |
|
|
|
e7106e |
-#define BREAKPOINT_VALUE { 0x7f, 0xe0, 0x00, 0x08 }
|
|
|
e7106e |
#define BREAKPOINT_LENGTH 4
|
|
|
e7106e |
#define DECR_PC_AFTER_BREAK 0
|
|
|
e7106e |
|
|
|
e7106e |
@@ -34,8 +34,33 @@
|
|
|
e7106e |
#ifdef __powerpc64__ // Says 'ltrace' is 64 bits, says nothing about target.
|
|
|
e7106e |
#define LT_ELFCLASS2 ELFCLASS64
|
|
|
e7106e |
#define LT_ELF_MACHINE2 EM_PPC64
|
|
|
e7106e |
-#define ARCH_SUPPORTS_OPD
|
|
|
e7106e |
-#endif
|
|
|
e7106e |
+
|
|
|
e7106e |
+# ifdef __LITTLE_ENDIAN__
|
|
|
e7106e |
+# define BREAKPOINT_VALUE { 0x08, 0x00, 0xe0, 0x7f }
|
|
|
e7106e |
+# define ARCH_ENDIAN_LITTLE
|
|
|
e7106e |
+# else
|
|
|
e7106e |
+# define BREAKPOINT_VALUE { 0x7f, 0xe0, 0x00, 0x08 }
|
|
|
e7106e |
+# define ARCH_SUPPORTS_OPD
|
|
|
e7106e |
+# define ARCH_ENDIAN_BIG
|
|
|
e7106e |
+# endif
|
|
|
e7106e |
+
|
|
|
e7106e |
+# if _CALL_ELF != 2
|
|
|
e7106e |
+# define ARCH_SUPPORTS_OPD
|
|
|
e7106e |
+# define STACK_FRAME_OVERHEAD 112
|
|
|
e7106e |
+# ifndef EF_PPC64_ABI
|
|
|
e7106e |
+# define EF_PPC64_ABI 3
|
|
|
e7106e |
+# endif
|
|
|
e7106e |
+# else /* _CALL_ELF == 2 ABIv2 */
|
|
|
e7106e |
+# define STACK_FRAME_OVERHEAD 32
|
|
|
e7106e |
+# endif /* CALL_ELF */
|
|
|
e7106e |
+
|
|
|
e7106e |
+#else
|
|
|
e7106e |
+#define BREAKPOINT_VALUE { 0x7f, 0xe0, 0x00, 0x08 }
|
|
|
e7106e |
+#define ARCH_ENDIAN_BIG
|
|
|
e7106e |
+# ifndef EF_PPC64_ABI
|
|
|
e7106e |
+# define EF_PPC64_ABI 3
|
|
|
e7106e |
+# endif
|
|
|
e7106e |
+#endif /* __powerpc64__ */
|
|
|
e7106e |
|
|
|
e7106e |
#define ARCH_HAVE_SW_SINGLESTEP
|
|
|
e7106e |
#define ARCH_HAVE_ADD_PLT_ENTRY
|
|
|
e7106e |
@@ -43,7 +68,6 @@
|
|
|
e7106e |
#define ARCH_HAVE_TRANSLATE_ADDRESS
|
|
|
e7106e |
#define ARCH_HAVE_DYNLINK_DONE
|
|
|
e7106e |
#define ARCH_HAVE_FETCH_ARG
|
|
|
e7106e |
-#define ARCH_ENDIAN_BIG
|
|
|
e7106e |
#define ARCH_HAVE_SIZEOF
|
|
|
e7106e |
#define ARCH_HAVE_ALIGNOF
|
|
|
e7106e |
|
|
|
e7106e |
@@ -56,7 +80,8 @@ struct arch_ltelf_data {
|
|
|
e7106e |
Elf_Data *opd_data;
|
|
|
e7106e |
GElf_Addr opd_base;
|
|
|
e7106e |
GElf_Xword opd_size;
|
|
|
e7106e |
- int secure_plt;
|
|
|
e7106e |
+ bool secure_plt : 1;
|
|
|
e7106e |
+ bool elfv2_abi : 1;
|
|
|
e7106e |
|
|
|
e7106e |
Elf_Data *reladyn;
|
|
|
e7106e |
size_t reladyn_count;
|
|
|
e7106e |
diff --git a/sysdeps/linux-gnu/ppc/fetch.c b/sysdeps/linux-gnu/ppc/fetch.c
|
|
|
e7106e |
index ed38336..c9381c3 100644
|
|
|
e7106e |
--- a/sysdeps/linux-gnu/ppc/fetch.c
|
|
|
e7106e |
+++ b/sysdeps/linux-gnu/ppc/fetch.c
|
|
|
e7106e |
@@ -30,9 +30,11 @@
|
|
|
e7106e |
#include "ptrace.h"
|
|
|
e7106e |
#include "proc.h"
|
|
|
e7106e |
#include "value.h"
|
|
|
e7106e |
+#include "ltrace-elf.h"
|
|
|
e7106e |
|
|
|
e7106e |
static int allocate_gpr(struct fetch_context *ctx, struct process *proc,
|
|
|
e7106e |
- struct arg_type_info *info, struct value *valuep);
|
|
|
e7106e |
+ struct arg_type_info *info, struct value *valuep,
|
|
|
e7106e |
+ size_t off, bool is_hfa_type);
|
|
|
e7106e |
|
|
|
e7106e |
/* Floating point registers have the same width on 32-bit as well as
|
|
|
e7106e |
* 64-bit PPC, but <ucontext.h> presents a different API depending on
|
|
|
e7106e |
@@ -62,7 +64,10 @@ struct fetch_context {
|
|
|
e7106e |
gregs64_t r64;
|
|
|
e7106e |
} regs;
|
|
|
e7106e |
struct fpregs_t fpregs;
|
|
|
e7106e |
-
|
|
|
e7106e |
+ int vgreg;
|
|
|
e7106e |
+ int struct_size;
|
|
|
e7106e |
+ int struct_hfa_size;
|
|
|
e7106e |
+ int struct_hfa_count;
|
|
|
e7106e |
};
|
|
|
e7106e |
|
|
|
e7106e |
static int
|
|
|
e7106e |
@@ -74,7 +79,8 @@ fetch_context_init(struct process *proc, struct fetch_context *context)
|
|
|
e7106e |
if (proc->e_machine == EM_PPC)
|
|
|
e7106e |
context->stack_pointer = proc->stack_pointer + 8;
|
|
|
e7106e |
else
|
|
|
e7106e |
- context->stack_pointer = proc->stack_pointer + 112;
|
|
|
e7106e |
+ context->stack_pointer = proc->stack_pointer
|
|
|
e7106e |
+ + STACK_FRAME_OVERHEAD;
|
|
|
e7106e |
|
|
|
e7106e |
/* When ltrace is 64-bit, we might use PTRACE_GETREGS to
|
|
|
e7106e |
* obtain 64-bit as well as 32-bit registers. But if we do it
|
|
|
e7106e |
@@ -118,6 +124,11 @@ arch_fetch_arg_init(enum tof type, struct process *proc,
|
|
|
e7106e |
return NULL;
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
+ context->vgreg = context->greg;
|
|
|
e7106e |
+ context->struct_size = 0;
|
|
|
e7106e |
+ context->struct_hfa_size = 0;
|
|
|
e7106e |
+ context->struct_hfa_count = 0;
|
|
|
e7106e |
+
|
|
|
e7106e |
/* Aggregates or unions of any length, and character strings
|
|
|
e7106e |
* of length longer than 8 bytes, will be returned in a
|
|
|
e7106e |
* storage buffer allocated by the caller. The caller will
|
|
|
e7106e |
@@ -125,8 +136,20 @@ arch_fetch_arg_init(enum tof type, struct process *proc,
|
|
|
e7106e |
* in r3, causing the first explicit argument to be passed in
|
|
|
e7106e |
* r4. */
|
|
|
e7106e |
context->ret_struct = ret_info->type == ARGTYPE_STRUCT;
|
|
|
e7106e |
- if (context->ret_struct)
|
|
|
e7106e |
+ if (context->ret_struct) {
|
|
|
e7106e |
+#if _CALL_ELF == 2
|
|
|
e7106e |
+ /* if R3 points to stack, parameters will be in R4. */
|
|
|
e7106e |
+ uint64_t pstack_end = ptrace(PTRACE_PEEKTEXT, proc->pid,
|
|
|
e7106e |
+ proc->stack_pointer, 0);
|
|
|
e7106e |
+ if (((arch_addr_t)context->regs.r64[3] > proc->stack_pointer)
|
|
|
e7106e |
+ && (context->regs.r64[3] < pstack_end)) {
|
|
|
e7106e |
+ context->greg++;
|
|
|
e7106e |
+ context->stack_pointer += 8;
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+#else
|
|
|
e7106e |
context->greg++;
|
|
|
e7106e |
+#endif
|
|
|
e7106e |
+ }
|
|
|
e7106e |
|
|
|
e7106e |
return context;
|
|
|
e7106e |
}
|
|
|
e7106e |
@@ -144,7 +167,8 @@ arch_fetch_arg_clone(struct process *proc,
|
|
|
e7106e |
|
|
|
e7106e |
static int
|
|
|
e7106e |
allocate_stack_slot(struct fetch_context *ctx, struct process *proc,
|
|
|
e7106e |
- struct arg_type_info *info, struct value *valuep)
|
|
|
e7106e |
+ struct arg_type_info *info, struct value *valuep,
|
|
|
e7106e |
+ bool is_hfa_type)
|
|
|
e7106e |
{
|
|
|
e7106e |
size_t sz = type_sizeof(proc, info);
|
|
|
e7106e |
if (sz == (size_t)-1)
|
|
|
e7106e |
@@ -154,7 +178,14 @@ allocate_stack_slot(struct fetch_context *ctx, struct process *proc,
|
|
|
e7106e |
size_t off = 0;
|
|
|
e7106e |
if (proc->e_machine == EM_PPC && a < 4)
|
|
|
e7106e |
a = 4;
|
|
|
e7106e |
+#if _CALL_ELF == 2
|
|
|
e7106e |
+ else if (proc->e_machine == EM_PPC64 && sz == 4 && is_hfa_type)
|
|
|
e7106e |
+ a = 4;
|
|
|
e7106e |
+ else
|
|
|
e7106e |
+ a = 8;
|
|
|
e7106e |
+#else
|
|
|
e7106e |
else if (proc->e_machine == EM_PPC64 && a < 8)
|
|
|
e7106e |
+#endif
|
|
|
e7106e |
a = 8;
|
|
|
e7106e |
|
|
|
e7106e |
/* XXX Remove the two double casts when arch_addr_t
|
|
|
e7106e |
@@ -164,7 +195,7 @@ allocate_stack_slot(struct fetch_context *ctx, struct process *proc,
|
|
|
e7106e |
|
|
|
e7106e |
if (valuep != NULL)
|
|
|
e7106e |
value_in_inferior(valuep, ctx->stack_pointer + off);
|
|
|
e7106e |
- ctx->stack_pointer += sz;
|
|
|
e7106e |
+ ctx->stack_pointer += a;
|
|
|
e7106e |
|
|
|
e7106e |
return 0;
|
|
|
e7106e |
}
|
|
|
e7106e |
@@ -216,19 +247,34 @@ align_small_int(unsigned char *buf, size_t w, size_t sz)
|
|
|
e7106e |
|
|
|
e7106e |
static int
|
|
|
e7106e |
allocate_gpr(struct fetch_context *ctx, struct process *proc,
|
|
|
e7106e |
- struct arg_type_info *info, struct value *valuep)
|
|
|
e7106e |
+ struct arg_type_info *info, struct value *valuep,
|
|
|
e7106e |
+ size_t off, bool is_hfa_type)
|
|
|
e7106e |
{
|
|
|
e7106e |
if (ctx->greg > 10)
|
|
|
e7106e |
- return allocate_stack_slot(ctx, proc, info, valuep);
|
|
|
e7106e |
+ return allocate_stack_slot(ctx, proc, info, valuep, is_hfa_type);
|
|
|
e7106e |
|
|
|
e7106e |
- int reg_num = ctx->greg++;
|
|
|
e7106e |
- if (valuep == NULL)
|
|
|
e7106e |
- return 0;
|
|
|
e7106e |
+ int reg_num = ctx->greg;
|
|
|
e7106e |
|
|
|
e7106e |
size_t sz = type_sizeof(proc, info);
|
|
|
e7106e |
if (sz == (size_t)-1)
|
|
|
e7106e |
return -1;
|
|
|
e7106e |
assert(sz == 1 || sz == 2 || sz == 4 || sz == 8);
|
|
|
e7106e |
+#if _CALL_ELF == 2
|
|
|
e7106e |
+ /* Consume the stack slot corresponding to this arg. */
|
|
|
e7106e |
+ if ((sz + off) >= 8)
|
|
|
e7106e |
+ ctx->greg++;
|
|
|
e7106e |
+
|
|
|
e7106e |
+ if (is_hfa_type)
|
|
|
e7106e |
+ ctx->stack_pointer += sz;
|
|
|
e7106e |
+ else
|
|
|
e7106e |
+ ctx->stack_pointer += 8;
|
|
|
e7106e |
+#else
|
|
|
e7106e |
+ ctx->greg++;
|
|
|
e7106e |
+#endif
|
|
|
e7106e |
+
|
|
|
e7106e |
+ if (valuep == NULL)
|
|
|
e7106e |
+ return 0;
|
|
|
e7106e |
+
|
|
|
e7106e |
if (value_reserve(valuep, sz) == NULL)
|
|
|
e7106e |
return -1;
|
|
|
e7106e |
|
|
|
e7106e |
@@ -240,13 +286,14 @@ allocate_gpr(struct fetch_context *ctx, struct process *proc,
|
|
|
e7106e |
u.i64 = read_gpr(ctx, proc, reg_num);
|
|
|
e7106e |
if (proc->e_machine == EM_PPC)
|
|
|
e7106e |
align_small_int(u.buf, 8, sz);
|
|
|
e7106e |
- memcpy(value_get_raw_data(valuep), u.buf, sz);
|
|
|
e7106e |
+ memcpy(value_get_raw_data(valuep), u.buf + off, sz);
|
|
|
e7106e |
return 0;
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
static int
|
|
|
e7106e |
allocate_float(struct fetch_context *ctx, struct process *proc,
|
|
|
e7106e |
- struct arg_type_info *info, struct value *valuep)
|
|
|
e7106e |
+ struct arg_type_info *info, struct value *valuep,
|
|
|
e7106e |
+ size_t off, bool is_hfa_type)
|
|
|
e7106e |
{
|
|
|
e7106e |
int pool = proc->e_machine == EM_PPC64 ? 13 : 8;
|
|
|
e7106e |
if (ctx->freg <= pool) {
|
|
|
e7106e |
@@ -257,8 +304,12 @@ allocate_float(struct fetch_context *ctx, struct process *proc,
|
|
|
e7106e |
} u = { .d = ctx->fpregs.fpregs[ctx->freg] };
|
|
|
e7106e |
|
|
|
e7106e |
ctx->freg++;
|
|
|
e7106e |
+
|
|
|
e7106e |
+ if (!is_hfa_type)
|
|
|
e7106e |
+ ctx->vgreg++;
|
|
|
e7106e |
+
|
|
|
e7106e |
if (proc->e_machine == EM_PPC64)
|
|
|
e7106e |
- allocate_gpr(ctx, proc, info, NULL);
|
|
|
e7106e |
+ allocate_gpr(ctx, proc, info, NULL, off, is_hfa_type);
|
|
|
e7106e |
|
|
|
e7106e |
size_t sz = sizeof(double);
|
|
|
e7106e |
if (info->type == ARGTYPE_FLOAT) {
|
|
|
e7106e |
@@ -272,8 +323,128 @@ allocate_float(struct fetch_context *ctx, struct process *proc,
|
|
|
e7106e |
memcpy(value_get_raw_data(valuep), u.buf, sz);
|
|
|
e7106e |
return 0;
|
|
|
e7106e |
}
|
|
|
e7106e |
- return allocate_stack_slot(ctx, proc, info, valuep);
|
|
|
e7106e |
+ return allocate_stack_slot(ctx, proc, info, valuep, is_hfa_type);
|
|
|
e7106e |
+}
|
|
|
e7106e |
+
|
|
|
e7106e |
+#if _CALL_ELF == 2
|
|
|
e7106e |
+static int
|
|
|
e7106e |
+allocate_hfa(struct fetch_context *ctx, struct process *proc,
|
|
|
e7106e |
+ struct arg_type_info *info, struct value *valuep,
|
|
|
e7106e |
+ enum arg_type hfa_type, size_t hfa_count)
|
|
|
e7106e |
+{
|
|
|
e7106e |
+ size_t sz = type_sizeof(proc, info);
|
|
|
e7106e |
+ if (sz == (size_t)-1)
|
|
|
e7106e |
+ return -1;
|
|
|
e7106e |
+
|
|
|
e7106e |
+ ctx->struct_hfa_size += sz;
|
|
|
e7106e |
+
|
|
|
e7106e |
+ /* There are two changes regarding structure return types:
|
|
|
e7106e |
+ * * heterogeneous float/vector structs are returned
|
|
|
e7106e |
+ * in (multiple) FP/vector registers,
|
|
|
e7106e |
+ * instead of via implicit reference.
|
|
|
e7106e |
+ * * small structs (up to 16 bytes) are return
|
|
|
e7106e |
+ * in one or two GPRs, instead of via implicit reference.
|
|
|
e7106e |
+ *
|
|
|
e7106e |
+ * Other structures (larger than 16 bytes, not heterogeneous)
|
|
|
e7106e |
+ * are still returned via implicit reference (i.e. a pointer
|
|
|
e7106e |
+ * to memory where to return the struct being passed in r3).
|
|
|
e7106e |
+ * Of course, whether or not an implicit reference pointer
|
|
|
e7106e |
+ * is present will shift the remaining arguments,
|
|
|
e7106e |
+ * so you need to get this right for ELFv2 in order
|
|
|
e7106e |
+ * to get the arguments correct.
|
|
|
e7106e |
+ * If an actual parameter is known to correspond to an HFA
|
|
|
e7106e |
+ * formal parameter, each element is passed in the next
|
|
|
e7106e |
+ * available floating-point argument register starting at fp1
|
|
|
e7106e |
+ * until the fp13. The remaining elements of the aggregate are
|
|
|
e7106e |
+ * passed on the stack. */
|
|
|
e7106e |
+ size_t slot_off = 0;
|
|
|
e7106e |
+
|
|
|
e7106e |
+ unsigned char *buf = value_reserve(valuep, sz);
|
|
|
e7106e |
+ if (buf == NULL)
|
|
|
e7106e |
+ return -1;
|
|
|
e7106e |
+
|
|
|
e7106e |
+ struct arg_type_info *hfa_info = type_get_simple(hfa_type);
|
|
|
e7106e |
+ size_t hfa_sz = type_sizeof(proc, hfa_info);
|
|
|
e7106e |
+
|
|
|
e7106e |
+ if (hfa_count > 8)
|
|
|
e7106e |
+ ctx->struct_hfa_count += hfa_count;
|
|
|
e7106e |
+
|
|
|
e7106e |
+ while (hfa_count > 0 && ctx->freg <= 13) {
|
|
|
e7106e |
+ int rc;
|
|
|
e7106e |
+ struct value tmp;
|
|
|
e7106e |
+
|
|
|
e7106e |
+ value_init(&tmp, proc, NULL, hfa_info, 0);
|
|
|
e7106e |
+
|
|
|
e7106e |
+ /* Hetereogeneous struct - get value on GPR or stack. */
|
|
|
e7106e |
+ if (((hfa_type == ARGTYPE_FLOAT
|
|
|
e7106e |
+ || hfa_type == ARGTYPE_DOUBLE)
|
|
|
e7106e |
+ && hfa_count <= 8))
|
|
|
e7106e |
+ rc = allocate_float(ctx, proc, hfa_info, &tmp,
|
|
|
e7106e |
+ slot_off, true);
|
|
|
e7106e |
+ else
|
|
|
e7106e |
+ rc = allocate_gpr(ctx, proc, hfa_info, &tmp,
|
|
|
e7106e |
+ slot_off, true);
|
|
|
e7106e |
+
|
|
|
e7106e |
+ memcpy(buf, value_get_data(&tmp, NULL), hfa_sz);
|
|
|
e7106e |
+
|
|
|
e7106e |
+ slot_off += hfa_sz;
|
|
|
e7106e |
+ buf += hfa_sz;
|
|
|
e7106e |
+ hfa_count--;
|
|
|
e7106e |
+ if (slot_off == 8) {
|
|
|
e7106e |
+ slot_off = 0;
|
|
|
e7106e |
+ ctx->vgreg++;
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+
|
|
|
e7106e |
+ value_destroy(&tmp);
|
|
|
e7106e |
+ if (rc < 0)
|
|
|
e7106e |
+ return -1;
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+ if (hfa_count == 0)
|
|
|
e7106e |
+ return 0;
|
|
|
e7106e |
+
|
|
|
e7106e |
+ /* if no remaining FP, GPR corresponding to slot is used
|
|
|
e7106e |
+ * Mostly it is in part of r10. */
|
|
|
e7106e |
+ if (ctx->struct_hfa_size <= 64 && ctx->vgreg == 10) {
|
|
|
e7106e |
+ while (ctx->vgreg <= 10) {
|
|
|
e7106e |
+ struct value tmp;
|
|
|
e7106e |
+ value_init(&tmp, proc, NULL, hfa_info, 0);
|
|
|
e7106e |
+ union {
|
|
|
e7106e |
+ uint64_t i64;
|
|
|
e7106e |
+ unsigned char buf[0];
|
|
|
e7106e |
+ } u;
|
|
|
e7106e |
+
|
|
|
e7106e |
+ u.i64 = read_gpr(ctx, proc, ctx->vgreg);
|
|
|
e7106e |
+
|
|
|
e7106e |
+ memcpy(buf, u.buf + slot_off, hfa_sz);
|
|
|
e7106e |
+ slot_off += hfa_sz;
|
|
|
e7106e |
+ buf += hfa_sz;
|
|
|
e7106e |
+ hfa_count--;
|
|
|
e7106e |
+ ctx->stack_pointer += hfa_sz;
|
|
|
e7106e |
+ if (slot_off >= 8 ) {
|
|
|
e7106e |
+ slot_off = 0;
|
|
|
e7106e |
+ ctx->vgreg++;
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+ value_destroy(&tmp);
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+
|
|
|
e7106e |
+ if (hfa_count == 0)
|
|
|
e7106e |
+ return 0;
|
|
|
e7106e |
+
|
|
|
e7106e |
+ /* Remaining values are on stack */
|
|
|
e7106e |
+ while (hfa_count) {
|
|
|
e7106e |
+ struct value tmp;
|
|
|
e7106e |
+ value_init(&tmp, proc, NULL, hfa_info, 0);
|
|
|
e7106e |
+
|
|
|
e7106e |
+ value_in_inferior(&tmp, ctx->stack_pointer);
|
|
|
e7106e |
+ memcpy(buf, value_get_data(&tmp, NULL), hfa_sz);
|
|
|
e7106e |
+ ctx->stack_pointer += hfa_sz;
|
|
|
e7106e |
+ buf += hfa_sz;
|
|
|
e7106e |
+ hfa_count--;
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+ return 0;
|
|
|
e7106e |
}
|
|
|
e7106e |
+#endif
|
|
|
e7106e |
|
|
|
e7106e |
static int
|
|
|
e7106e |
allocate_argument(struct fetch_context *ctx, struct process *proc,
|
|
|
e7106e |
@@ -287,13 +458,25 @@ allocate_argument(struct fetch_context *ctx, struct process *proc,
|
|
|
e7106e |
|
|
|
e7106e |
case ARGTYPE_FLOAT:
|
|
|
e7106e |
case ARGTYPE_DOUBLE:
|
|
|
e7106e |
- return allocate_float(ctx, proc, info, valuep);
|
|
|
e7106e |
+ return allocate_float(ctx, proc, info, valuep,
|
|
|
e7106e |
+ 8 - type_sizeof(proc,info), false);
|
|
|
e7106e |
|
|
|
e7106e |
case ARGTYPE_STRUCT:
|
|
|
e7106e |
if (proc->e_machine == EM_PPC) {
|
|
|
e7106e |
if (value_pass_by_reference(valuep) < 0)
|
|
|
e7106e |
return -1;
|
|
|
e7106e |
} else {
|
|
|
e7106e |
+#if _CALL_ELF == 2
|
|
|
e7106e |
+ struct arg_type_info *hfa_info;
|
|
|
e7106e |
+ size_t hfa_size;
|
|
|
e7106e |
+ hfa_info = type_get_hfa_type(info, &hfa_size);
|
|
|
e7106e |
+ if (hfa_info != NULL ) {
|
|
|
e7106e |
+ size_t sz = type_sizeof(proc, info);
|
|
|
e7106e |
+ ctx->struct_size += sz;
|
|
|
e7106e |
+ return allocate_hfa(ctx, proc, info, valuep,
|
|
|
e7106e |
+ hfa_info->type, hfa_size);
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+#endif
|
|
|
e7106e |
/* PPC64: Fixed size aggregates and unions passed by
|
|
|
e7106e |
* value are mapped to as many doublewords of the
|
|
|
e7106e |
* parameter save area as the value uses in memory.
|
|
|
e7106e |
@@ -326,6 +509,10 @@ allocate_argument(struct fetch_context *ctx, struct process *proc,
|
|
|
e7106e |
size_t sz = type_sizeof(proc, valuep->type);
|
|
|
e7106e |
if (sz == (size_t)-1)
|
|
|
e7106e |
return -1;
|
|
|
e7106e |
+
|
|
|
e7106e |
+ if (ctx->ret_struct)
|
|
|
e7106e |
+ ctx->struct_size += sz;
|
|
|
e7106e |
+
|
|
|
e7106e |
size_t slots = (sz + width - 1) / width; /* Round up. */
|
|
|
e7106e |
unsigned char *buf = value_reserve(valuep, slots * width);
|
|
|
e7106e |
if (buf == NULL)
|
|
|
e7106e |
@@ -346,9 +533,11 @@ allocate_argument(struct fetch_context *ctx, struct process *proc,
|
|
|
e7106e |
struct arg_type_info *fp_info
|
|
|
e7106e |
= type_get_fp_equivalent(valuep->type);
|
|
|
e7106e |
if (fp_info != NULL)
|
|
|
e7106e |
- rc = allocate_float(ctx, proc, fp_info, &val;;
|
|
|
e7106e |
+ rc = allocate_float(ctx, proc, fp_info, &val,
|
|
|
e7106e |
+ 8-type_sizeof(proc,info), false);
|
|
|
e7106e |
else
|
|
|
e7106e |
- rc = allocate_gpr(ctx, proc, long_info, &val;;
|
|
|
e7106e |
+ rc = allocate_gpr(ctx, proc, long_info, &val,
|
|
|
e7106e |
+ 0, false);
|
|
|
e7106e |
|
|
|
e7106e |
if (rc >= 0) {
|
|
|
e7106e |
memcpy(ptr, value_get_data(&val, NULL), width);
|
|
|
e7106e |
@@ -363,6 +552,7 @@ allocate_argument(struct fetch_context *ctx, struct process *proc,
|
|
|
e7106e |
return rc;
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
+#ifndef __LITTLE_ENDIAN__
|
|
|
e7106e |
/* Small values need post-processing. */
|
|
|
e7106e |
if (sz < width) {
|
|
|
e7106e |
switch (info->type) {
|
|
|
e7106e |
@@ -394,6 +584,7 @@ allocate_argument(struct fetch_context *ctx, struct process *proc,
|
|
|
e7106e |
break;
|
|
|
e7106e |
}
|
|
|
e7106e |
}
|
|
|
e7106e |
+#endif
|
|
|
e7106e |
|
|
|
e7106e |
return 0;
|
|
|
e7106e |
}
|
|
|
e7106e |
@@ -411,7 +602,22 @@ arch_fetch_retval(struct fetch_context *ctx, enum tof type,
|
|
|
e7106e |
struct process *proc, struct arg_type_info *info,
|
|
|
e7106e |
struct value *valuep)
|
|
|
e7106e |
{
|
|
|
e7106e |
+ if (fetch_context_init(proc, ctx) < 0)
|
|
|
e7106e |
+ return -1;
|
|
|
e7106e |
+
|
|
|
e7106e |
+#if _CALL_ELF == 2
|
|
|
e7106e |
+ void *ptr = (void *)(ctx->regs.r64[1]+32);
|
|
|
e7106e |
+ uint64_t val = ptrace(PTRACE_PEEKTEXT, proc->pid, ptr, 0);
|
|
|
e7106e |
+
|
|
|
e7106e |
+ if (ctx->ret_struct
|
|
|
e7106e |
+ && ((ctx->struct_size > 64
|
|
|
e7106e |
+ || ctx->struct_hfa_count > 8
|
|
|
e7106e |
+ || (ctx->struct_hfa_size == 0 && ctx->struct_size > 56)
|
|
|
e7106e |
+ || (ctx->regs.r64[3] == ctx->regs.r64[1]+32)
|
|
|
e7106e |
+ || (ctx->regs.r64[3] == val )))) {
|
|
|
e7106e |
+#else
|
|
|
e7106e |
if (ctx->ret_struct) {
|
|
|
e7106e |
+#endif
|
|
|
e7106e |
assert(info->type == ARGTYPE_STRUCT);
|
|
|
e7106e |
|
|
|
e7106e |
uint64_t addr = read_gpr(ctx, proc, 3);
|
|
|
e7106e |
@@ -424,8 +630,6 @@ arch_fetch_retval(struct fetch_context *ctx, enum tof type,
|
|
|
e7106e |
return 0;
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
- if (fetch_context_init(proc, ctx) < 0)
|
|
|
e7106e |
- return -1;
|
|
|
e7106e |
return allocate_argument(ctx, proc, info, valuep);
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
diff --git a/sysdeps/linux-gnu/ppc/plt.c b/sysdeps/linux-gnu/ppc/plt.c
|
|
|
e7106e |
index 332daa8..45ed7fb 100644
|
|
|
e7106e |
--- a/sysdeps/linux-gnu/ppc/plt.c
|
|
|
e7106e |
+++ b/sysdeps/linux-gnu/ppc/plt.c
|
|
|
e7106e |
@@ -136,7 +136,11 @@
|
|
|
e7106e |
*/
|
|
|
e7106e |
|
|
|
e7106e |
#define PPC_PLT_STUB_SIZE 16
|
|
|
e7106e |
-#define PPC64_PLT_STUB_SIZE 8 //xxx
|
|
|
e7106e |
+#if _CALL_ELF != 2
|
|
|
e7106e |
+#define PPC64_PLT_STUB_SIZE 8
|
|
|
e7106e |
+#else
|
|
|
e7106e |
+#define PPC64_PLT_STUB_SIZE 4
|
|
|
e7106e |
+#endif
|
|
|
e7106e |
|
|
|
e7106e |
static inline int
|
|
|
e7106e |
host_powerpc64()
|
|
|
e7106e |
@@ -186,8 +190,13 @@ ppc32_delayed_symbol(struct library_symbol *libsym)
|
|
|
e7106e |
if ((insn1 & BRANCH_MASK) == B_INSN
|
|
|
e7106e |
|| ((insn2 & BRANCH_MASK) == B_INSN
|
|
|
e7106e |
/* XXX double cast */
|
|
|
e7106e |
+#ifdef __LITTLE_ENDIAN__
|
|
|
e7106e |
+ && (ppc_branch_dest(libsym->enter_addr + 4, insn1)
|
|
|
e7106e |
+ == (arch_addr_t) (long) libsym->lib->arch.pltgot_addr)))
|
|
|
e7106e |
+#else
|
|
|
e7106e |
&& (ppc_branch_dest(libsym->enter_addr + 4, insn2)
|
|
|
e7106e |
== (arch_addr_t) (long) libsym->lib->arch.pltgot_addr)))
|
|
|
e7106e |
+#endif
|
|
|
e7106e |
{
|
|
|
e7106e |
mark_as_resolved(libsym, libsym->arch.resolved_value);
|
|
|
e7106e |
}
|
|
|
e7106e |
@@ -206,7 +215,7 @@ arch_dynlink_done(struct process *proc)
|
|
|
e7106e |
"couldn't read PLT value for %s(%p): %s\n",
|
|
|
e7106e |
libsym->name, libsym->enter_addr,
|
|
|
e7106e |
strerror(errno));
|
|
|
e7106e |
- return;
|
|
|
e7106e |
+ return;
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
if (proc->e_machine == EM_PPC)
|
|
|
e7106e |
@@ -227,8 +236,14 @@ reloc_is_irelative(int machine, GElf_Rela *rela)
|
|
|
e7106e |
{
|
|
|
e7106e |
bool irelative = false;
|
|
|
e7106e |
if (machine == EM_PPC64) {
|
|
|
e7106e |
-#ifdef R_PPC64_JMP_IREL
|
|
|
e7106e |
+#ifdef __LITTLE_ENDIAN__
|
|
|
e7106e |
+# ifdef R_PPC64_IRELATIVE
|
|
|
e7106e |
+ irelative = GELF_R_TYPE(rela->r_info) == R_PPC64_IRELATIVE;
|
|
|
e7106e |
+# endif
|
|
|
e7106e |
+#else
|
|
|
e7106e |
+# ifdef R_PPC64_JMP_IREL
|
|
|
e7106e |
irelative = GELF_R_TYPE(rela->r_info) == R_PPC64_JMP_IREL;
|
|
|
e7106e |
+# endif
|
|
|
e7106e |
#endif
|
|
|
e7106e |
} else {
|
|
|
e7106e |
assert(machine == EM_PPC);
|
|
|
e7106e |
@@ -285,6 +300,7 @@ arch_translate_address_dyn(struct process *proc,
|
|
|
e7106e |
arch_addr_t addr, arch_addr_t *ret)
|
|
|
e7106e |
{
|
|
|
e7106e |
if (proc->e_machine == EM_PPC64) {
|
|
|
e7106e |
+#if _CALL_ELF != 2
|
|
|
e7106e |
uint64_t value;
|
|
|
e7106e |
if (proc_read_64(proc, addr, &value) < 0) {
|
|
|
e7106e |
fprintf(stderr,
|
|
|
e7106e |
@@ -296,6 +312,7 @@ arch_translate_address_dyn(struct process *proc,
|
|
|
e7106e |
* arch_addr_t becomes integral type. */
|
|
|
e7106e |
*ret = (arch_addr_t)(uintptr_t)value;
|
|
|
e7106e |
return 0;
|
|
|
e7106e |
+#endif
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
*ret = addr;
|
|
|
e7106e |
@@ -306,7 +323,8 @@ int
|
|
|
e7106e |
arch_translate_address(struct ltelf *lte,
|
|
|
e7106e |
arch_addr_t addr, arch_addr_t *ret)
|
|
|
e7106e |
{
|
|
|
e7106e |
- if (lte->ehdr.e_machine == EM_PPC64) {
|
|
|
e7106e |
+ if (lte->ehdr.e_machine == EM_PPC64
|
|
|
e7106e |
+ && !lte->arch.elfv2_abi) {
|
|
|
e7106e |
/* XXX The double cast should be removed when
|
|
|
e7106e |
* arch_addr_t becomes integral type. */
|
|
|
e7106e |
GElf_Xword offset
|
|
|
e7106e |
@@ -430,7 +448,16 @@ reloc_copy_if_irelative(GElf_Rela *rela, void *data)
|
|
|
e7106e |
int
|
|
|
e7106e |
arch_elf_init(struct ltelf *lte, struct library *lib)
|
|
|
e7106e |
{
|
|
|
e7106e |
+
|
|
|
e7106e |
+ /* Check for ABIv2 in ELF header processor specific flag. */
|
|
|
e7106e |
+#ifndef EF_PPC64_ABI
|
|
|
e7106e |
+ assert (! (lte->ehdr.e_flags & 3 ) == 2)
|
|
|
e7106e |
+#else
|
|
|
e7106e |
+ lte->arch.elfv2_abi=((lte->ehdr.e_flags & EF_PPC64_ABI) == 2) ;
|
|
|
e7106e |
+#endif
|
|
|
e7106e |
+
|
|
|
e7106e |
if (lte->ehdr.e_machine == EM_PPC64
|
|
|
e7106e |
+ && !lte->arch.elfv2_abi
|
|
|
e7106e |
&& load_opd_data(lte, lib) < 0)
|
|
|
e7106e |
return -1;
|
|
|
e7106e |
|
|
|
e7106e |
@@ -599,7 +626,7 @@ read_plt_slot_value(struct process *proc, GElf_Addr addr, GElf_Addr *valp)
|
|
|
e7106e |
uint64_t l;
|
|
|
e7106e |
/* XXX double cast. */
|
|
|
e7106e |
if (proc_read_64(proc, (arch_addr_t)(uintptr_t)addr, &l) < 0) {
|
|
|
e7106e |
- fprintf(stderr, "ptrace .plt slot value @%#" PRIx64": %s\n",
|
|
|
e7106e |
+ debug(DEBUG_EVENT, "ptrace .plt slot value @%#" PRIx64": %s",
|
|
|
e7106e |
addr, strerror(errno));
|
|
|
e7106e |
return -1;
|
|
|
e7106e |
}
|
|
|
e7106e |
@@ -616,7 +643,7 @@ unresolve_plt_slot(struct process *proc, GElf_Addr addr, GElf_Addr value)
|
|
|
e7106e |
* pointers intact. Hence the only adjustment that we need to
|
|
|
e7106e |
* do is to IP. */
|
|
|
e7106e |
if (ptrace(PTRACE_POKETEXT, proc->pid, addr, value) < 0) {
|
|
|
e7106e |
- fprintf(stderr, "failed to unresolve .plt slot: %s\n",
|
|
|
e7106e |
+ debug(DEBUG_EVENT, "failed to unresolve .plt slot: %s",
|
|
|
e7106e |
strerror(errno));
|
|
|
e7106e |
return -1;
|
|
|
e7106e |
}
|
|
|
e7106e |
@@ -629,9 +656,48 @@ arch_elf_add_func_entry(struct process *proc, struct ltelf *lte,
|
|
|
e7106e |
arch_addr_t addr, const char *name,
|
|
|
e7106e |
struct library_symbol **ret)
|
|
|
e7106e |
{
|
|
|
e7106e |
- if (lte->ehdr.e_machine != EM_PPC || lte->ehdr.e_type == ET_DYN)
|
|
|
e7106e |
+#ifndef PPC64_LOCAL_ENTRY_OFFSET
|
|
|
e7106e |
+ assert(! lte->arch.elfv2_abi);
|
|
|
e7106e |
+#else
|
|
|
e7106e |
+ /* With ABIv2 st_other field contains an offset. */
|
|
|
e7106e |
+ if (lte->arch.elfv2_abi)
|
|
|
e7106e |
+ addr += PPC64_LOCAL_ENTRY_OFFSET(sym->st_other);
|
|
|
e7106e |
+#endif
|
|
|
e7106e |
+
|
|
|
e7106e |
+ int st_info = GELF_ST_TYPE(sym->st_info);
|
|
|
e7106e |
+
|
|
|
e7106e |
+ if ((lte->ehdr.e_machine != EM_PPC && sym->st_other == 0)
|
|
|
e7106e |
+ || lte->ehdr.e_type == ET_DYN
|
|
|
e7106e |
+ || (st_info == STT_FUNC && ! sym->st_other))
|
|
|
e7106e |
return PLT_DEFAULT;
|
|
|
e7106e |
|
|
|
e7106e |
+ if (st_info == STT_FUNC) {
|
|
|
e7106e |
+ /* Put the default symbol to the chain.
|
|
|
e7106e |
+ * The addr has already been updated with
|
|
|
e7106e |
+ * symbol offset */
|
|
|
e7106e |
+ char *full_name = strdup(name);
|
|
|
e7106e |
+ if (full_name == NULL) {
|
|
|
e7106e |
+ fprintf(stderr, "couldn't copy name of %s: %s\n",
|
|
|
e7106e |
+ name, strerror(errno));
|
|
|
e7106e |
+ free(full_name);
|
|
|
e7106e |
+ return PLT_FAIL;
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+ struct library_symbol *libsym = malloc(sizeof *libsym);
|
|
|
e7106e |
+ if (libsym == NULL
|
|
|
e7106e |
+ || library_symbol_init(libsym, addr, full_name, 1,
|
|
|
e7106e |
+ LS_TOPLT_NONE) < 0) {
|
|
|
e7106e |
+ free(libsym);
|
|
|
e7106e |
+ delete_symbol_chain(libsym);
|
|
|
e7106e |
+ libsym = NULL;
|
|
|
e7106e |
+ fprintf(stderr, "Couldn't add symbol %s"
|
|
|
e7106e |
+ "for tracing.\n", name);
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+ full_name = NULL;
|
|
|
e7106e |
+ libsym->next = *ret;
|
|
|
e7106e |
+ *ret = libsym;
|
|
|
e7106e |
+ return PLT_OK;
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+
|
|
|
e7106e |
bool ifunc = false;
|
|
|
e7106e |
#ifdef STT_GNU_IFUNC
|
|
|
e7106e |
ifunc = GELF_ST_TYPE(sym->st_info) == STT_GNU_IFUNC;
|
|
|
e7106e |
@@ -761,9 +827,15 @@ arch_elf_add_plt_entry(struct process *proc, struct ltelf *lte,
|
|
|
e7106e |
assert(plt_slot_addr >= lte->plt_addr
|
|
|
e7106e |
|| plt_slot_addr < lte->plt_addr + lte->plt_size);
|
|
|
e7106e |
|
|
|
e7106e |
+ /* Should avoid to do read if dynamic linker hasn't run yet
|
|
|
e7106e |
+ * or allow -1 a valid return code. */
|
|
|
e7106e |
GElf_Addr plt_slot_value;
|
|
|
e7106e |
- if (read_plt_slot_value(proc, plt_slot_addr, &plt_slot_value) < 0)
|
|
|
e7106e |
- goto fail;
|
|
|
e7106e |
+ if (read_plt_slot_value(proc, plt_slot_addr, &plt_slot_value) < 0) {
|
|
|
e7106e |
+ if (!lte->arch.elfv2_abi)
|
|
|
e7106e |
+ goto fail;
|
|
|
e7106e |
+ else
|
|
|
e7106e |
+ return PPC_PLT_UNRESOLVED;
|
|
|
e7106e |
+ }
|
|
|
e7106e |
|
|
|
e7106e |
struct library_symbol *libsym = malloc(sizeof(*libsym));
|
|
|
e7106e |
if (libsym == NULL) {
|
|
|
e7106e |
@@ -997,8 +1069,12 @@ ppc_plt_bp_continue(struct breakpoint *bp, struct process *proc)
|
|
|
e7106e |
return;
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
+#if _CALL_ELF == 2
|
|
|
e7106e |
+ continue_after_breakpoint(proc, bp);
|
|
|
e7106e |
+#else
|
|
|
e7106e |
jump_to_entry_point(proc, bp);
|
|
|
e7106e |
continue_process(proc->pid);
|
|
|
e7106e |
+#endif
|
|
|
e7106e |
return;
|
|
|
e7106e |
|
|
|
e7106e |
case PPC64_PLT_STUB:
|
|
|
e7106e |
@@ -1123,7 +1199,11 @@ arch_library_symbol_init(struct library_symbol *libsym)
|
|
|
e7106e |
/* We set type explicitly in the code above, where we have the
|
|
|
e7106e |
* necessary context. This is for calls from ltrace-elf.c and
|
|
|
e7106e |
* such. */
|
|
|
e7106e |
+#if _CALL_ELF == 2
|
|
|
e7106e |
+ libsym->arch.type = PPC_PLT_UNRESOLVED;
|
|
|
e7106e |
+#else
|
|
|
e7106e |
libsym->arch.type = PPC_DEFAULT;
|
|
|
e7106e |
+#endif
|
|
|
e7106e |
return 0;
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
diff --git a/sysdeps/linux-gnu/ppc/trace.c b/sysdeps/linux-gnu/ppc/trace.c
|
|
|
e7106e |
index ee9a6b5..5aab538 100644
|
|
|
e7106e |
--- a/sysdeps/linux-gnu/ppc/trace.c
|
|
|
e7106e |
+++ b/sysdeps/linux-gnu/ppc/trace.c
|
|
|
e7106e |
@@ -65,9 +65,15 @@ syscall_p(struct process *proc, int status, int *sysnum)
|
|
|
e7106e |
if (WIFSTOPPED(status)
|
|
|
e7106e |
&& WSTOPSIG(status) == (SIGTRAP | proc->tracesysgood)) {
|
|
|
e7106e |
long pc = (long)get_instruction_pointer(proc);
|
|
|
e7106e |
+#ifndef __LITTLE_ENDIAN__
|
|
|
e7106e |
int insn =
|
|
|
e7106e |
(int)ptrace(PTRACE_PEEKTEXT, proc->pid, pc - sizeof(long),
|
|
|
e7106e |
0);
|
|
|
e7106e |
+#else
|
|
|
e7106e |
+ int insn =
|
|
|
e7106e |
+ (int)ptrace(PTRACE_PEEKTEXT, proc->pid, pc - sizeof(int),
|
|
|
e7106e |
+ 0);
|
|
|
e7106e |
+#endif
|
|
|
e7106e |
|
|
|
e7106e |
if (insn == SYSCALL_INSN) {
|
|
|
e7106e |
*sysnum =
|
|
|
e7106e |
diff -up ltrace-0.7.91/sysdeps/linux-gnu/ppc/trace.c\~ ltrace-0.7.91/sysdeps/linux-gnu/ppc/trace.c
|
|
|
e7106e |
--- ltrace-0.7.91/sysdeps/linux-gnu/ppc/trace.c~ 2014-08-08 14:05:58.000000000 +0200
|
|
|
e7106e |
+++ ltrace-0.7.91/sysdeps/linux-gnu/ppc/trace.c 2014-08-08 14:07:55.000000000 +0200
|
|
|
e7106e |
@@ -133,7 +133,11 @@ arch_sw_singlestep(struct process *proc,
|
|
|
e7106e |
return SWS_FAIL;
|
|
|
e7106e |
uint32_t insn;
|
|
|
e7106e |
#ifdef __powerpc64__
|
|
|
e7106e |
+# ifdef __LITTLE_ENDIAN__
|
|
|
e7106e |
+ insn = (uint32_t) l;
|
|
|
e7106e |
+# else
|
|
|
e7106e |
insn = l >> 32;
|
|
|
e7106e |
+# endif
|
|
|
e7106e |
#else
|
|
|
e7106e |
insn = l;
|
|
|
e7106e |
#endif
|
|
|
e7106e |
diff -up ltrace-0.7.91/configure\~ ltrace-0.7.91/configure
|
|
|
e7106e |
--- ltrace-0.7.91/configure~ 2014-08-08 14:09:12.000000000 +0200
|
|
|
e7106e |
+++ ltrace-0.7.91/configure 2014-08-08 14:18:30.000000000 +0200
|
|
|
e7106e |
@@ -2555,7 +2555,7 @@ case "${host_cpu}" in
|
|
|
e7106e |
arm*|sa110) HOST_CPU="arm" ;;
|
|
|
e7106e |
cris*) HOST_CPU="cris" ;;
|
|
|
e7106e |
mips*) HOST_CPU="mips" ;;
|
|
|
e7106e |
- powerpc|powerpc64) HOST_CPU="ppc" ;;
|
|
|
e7106e |
+ powerpc|powerpc64|powerpc64le) HOST_CPU="ppc" ;;
|
|
|
e7106e |
sun4u|sparc64) HOST_CPU="sparc" ;;
|
|
|
e7106e |
s390x) HOST_CPU="s390" ;;
|
|
|
e7106e |
i?86|x86_64) HOST_CPU="x86" ;;
|
|
|
e7106e |
@@ -12094,7 +12094,7 @@ if test x"$enable_libunwind" = xyes; the
|
|
|
e7106e |
arm*|sa110) UNWIND_ARCH="arm" ;;
|
|
|
e7106e |
i?86) UNWIND_ARCH="x86" ;;
|
|
|
e7106e |
powerpc) UNWIND_ARCH="ppc32" ;;
|
|
|
e7106e |
- powerpc64) UNWIND_ARCH="ppc64" ;;
|
|
|
e7106e |
+ powerpc64|powerpc64le) UNWIND_ARCH="ppc64" ;;
|
|
|
e7106e |
mips*) UNWIND_ARCH="mips" ;;
|
|
|
e7106e |
*) UNWIND_ARCH="${host_cpu}" ;;
|
|
|
e7106e |
esac
|