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