|
|
244288 |
diff --git a/ltrace-elf.c b/ltrace-elf.c
|
|
|
244288 |
index 92b642b..6f86d56 100644
|
|
|
244288 |
--- a/ltrace-elf.c
|
|
|
244288 |
+++ b/ltrace-elf.c
|
|
|
244288 |
@@ -531,6 +531,38 @@ elf_read_relocs(struct ltelf *lte, Elf_Scn *scn, GElf_Shdr *shdr,
|
|
|
244288 |
return 0;
|
|
|
244288 |
}
|
|
|
244288 |
|
|
|
244288 |
+int
|
|
|
244288 |
+elf_load_dynamic_entry(struct ltelf *lte, int tag, GElf_Addr *valuep)
|
|
|
244288 |
+{
|
|
|
244288 |
+ Elf_Scn *scn;
|
|
|
244288 |
+ GElf_Shdr shdr;
|
|
|
244288 |
+ if (elf_get_section_type(lte, SHT_DYNAMIC, &scn, &shdr) < 0
|
|
|
244288 |
+ || scn == NULL) {
|
|
|
244288 |
+ fail:
|
|
|
244288 |
+ fprintf(stderr, "Couldn't get SHT_DYNAMIC: %s\n",
|
|
|
244288 |
+ elf_errmsg(-1));
|
|
|
244288 |
+ return -1;
|
|
|
244288 |
+ }
|
|
|
244288 |
+
|
|
|
244288 |
+ Elf_Data *data = elf_loaddata(scn, &shdr);
|
|
|
244288 |
+ if (data == NULL)
|
|
|
244288 |
+ goto fail;
|
|
|
244288 |
+
|
|
|
244288 |
+ size_t j;
|
|
|
244288 |
+ for (j = 0; j < shdr.sh_size / shdr.sh_entsize; ++j) {
|
|
|
244288 |
+ GElf_Dyn dyn;
|
|
|
244288 |
+ if (gelf_getdyn(data, j, &dyn) == NULL)
|
|
|
244288 |
+ goto fail;
|
|
|
244288 |
+
|
|
|
244288 |
+ if(dyn.d_tag == tag) {
|
|
|
244288 |
+ *valuep = dyn.d_un.d_ptr;
|
|
|
244288 |
+ return 0;
|
|
|
244288 |
+ }
|
|
|
244288 |
+ }
|
|
|
244288 |
+
|
|
|
244288 |
+ return -1;
|
|
|
244288 |
+}
|
|
|
244288 |
+
|
|
|
244288 |
static int
|
|
|
244288 |
ltelf_read_elf(struct ltelf *lte, const char *filename)
|
|
|
244288 |
{
|
|
|
244288 |
diff --git a/ltrace-elf.h b/ltrace-elf.h
|
|
|
244288 |
index ea14512..db4ffe9 100644
|
|
|
244288 |
--- a/ltrace-elf.h
|
|
|
244288 |
+++ b/ltrace-elf.h
|
|
|
244288 |
@@ -139,6 +139,10 @@ struct elf_each_symbol_t {
|
|
|
244288 |
int elf_read_relocs(struct ltelf *lte, Elf_Scn *scn, GElf_Shdr *shdr,
|
|
|
244288 |
struct vect *rela_vec);
|
|
|
244288 |
|
|
|
244288 |
+/* Read a given DT_ TAG from LTE. Value is returned in *VALUEP.
|
|
|
244288 |
+ * Returns 0 on success or a negative value on failure. */
|
|
|
244288 |
+int elf_load_dynamic_entry(struct ltelf *lte, int tag, GElf_Addr *valuep);
|
|
|
244288 |
+
|
|
|
244288 |
/* Read, respectively, 1, 2, 4, or 8 bytes from Elf data at given
|
|
|
244288 |
* OFFSET, and store it in *RETP. Returns 0 on success or a negative
|
|
|
244288 |
* value if there's not enough data. */
|
|
|
244288 |
diff --git a/sysdeps/linux-gnu/arm/arch.h b/sysdeps/linux-gnu/arm/arch.h
|
|
|
244288 |
index 58a7fdf..6d0d902 100644
|
|
|
244288 |
--- a/sysdeps/linux-gnu/arm/arch.h
|
|
|
244288 |
+++ b/sysdeps/linux-gnu/arm/arch.h
|
|
|
244288 |
@@ -22,6 +22,8 @@
|
|
|
244288 |
#ifndef LTRACE_ARM_ARCH_H
|
|
|
244288 |
#define LTRACE_ARM_ARCH_H
|
|
|
244288 |
|
|
|
244288 |
+#include <libelf.h>
|
|
|
244288 |
+
|
|
|
244288 |
#define ARCH_HAVE_ENABLE_BREAKPOINT 1
|
|
|
244288 |
#define ARCH_HAVE_DISABLE_BREAKPOINT 1
|
|
|
244288 |
|
|
|
244288 |
@@ -47,7 +49,7 @@ struct arch_breakpoint_data {
|
|
|
244288 |
|
|
|
244288 |
#define ARCH_HAVE_LTELF_DATA
|
|
|
244288 |
struct arch_ltelf_data {
|
|
|
244288 |
- /* We have this only for the hooks. */
|
|
|
244288 |
+ Elf_Data *jmprel_data;
|
|
|
244288 |
};
|
|
|
244288 |
|
|
|
244288 |
#define ARCH_HAVE_LIBRARY_DATA
|
|
|
244288 |
diff --git a/sysdeps/linux-gnu/arm/fetch.c b/sysdeps/linux-gnu/arm/fetch.c
|
|
|
244288 |
index 5081d78..b500448 100644
|
|
|
244288 |
--- a/sysdeps/linux-gnu/arm/fetch.c
|
|
|
244288 |
+++ b/sysdeps/linux-gnu/arm/fetch.c
|
|
|
244288 |
@@ -32,200 +32,12 @@
|
|
|
244288 |
#include "backend.h"
|
|
|
244288 |
#include "fetch.h"
|
|
|
244288 |
#include "library.h"
|
|
|
244288 |
-#include "ltrace-elf.h"
|
|
|
244288 |
#include "proc.h"
|
|
|
244288 |
#include "ptrace.h"
|
|
|
244288 |
#include "regs.h"
|
|
|
244288 |
#include "type.h"
|
|
|
244288 |
#include "value.h"
|
|
|
244288 |
|
|
|
244288 |
-static int
|
|
|
244288 |
-get_hardfp(uint64_t abi_vfp_args)
|
|
|
244288 |
-{
|
|
|
244288 |
- if (abi_vfp_args == 2)
|
|
|
244288 |
- fprintf(stderr,
|
|
|
244288 |
- "Tag_ABI_VFP_args value 2 (tool chain-specific "
|
|
|
244288 |
- "conventions) not supported.\n");
|
|
|
244288 |
- return abi_vfp_args == 1;
|
|
|
244288 |
-}
|
|
|
244288 |
-
|
|
|
244288 |
-int
|
|
|
244288 |
-arch_elf_init(struct ltelf *lte, struct library *lib)
|
|
|
244288 |
-{
|
|
|
244288 |
- /* Nothing in this section is strictly critical. It's not
|
|
|
244288 |
- * that much of a deal if we fail to guess right whether the
|
|
|
244288 |
- * ABI is softfp or hardfp. */
|
|
|
244288 |
- unsigned hardfp = 0;
|
|
|
244288 |
-
|
|
|
244288 |
- Elf_Scn *scn;
|
|
|
244288 |
- Elf_Data *data;
|
|
|
244288 |
- GElf_Shdr shdr;
|
|
|
244288 |
- if (elf_get_section_type(lte, SHT_ARM_ATTRIBUTES, &scn, &shdr) < 0
|
|
|
244288 |
- || (scn != NULL && (data = elf_loaddata(scn, &shdr)) == NULL)) {
|
|
|
244288 |
- fprintf(stderr,
|
|
|
244288 |
- "Error when obtaining ARM attribute section: %s\n",
|
|
|
244288 |
- elf_errmsg(-1));
|
|
|
244288 |
- goto done;
|
|
|
244288 |
-
|
|
|
244288 |
- } else if (scn != NULL && data != NULL) {
|
|
|
244288 |
- GElf_Xword offset = 0;
|
|
|
244288 |
- uint8_t version;
|
|
|
244288 |
- if (elf_read_next_u8(data, &offset, &version) < 0) {
|
|
|
244288 |
- goto done;
|
|
|
244288 |
- } else if (version != 'A') {
|
|
|
244288 |
- fprintf(stderr, "Unsupported ARM attribute section "
|
|
|
244288 |
- "version %d ('%c').\n", version, version);
|
|
|
244288 |
- goto done;
|
|
|
244288 |
- }
|
|
|
244288 |
-
|
|
|
244288 |
- do {
|
|
|
244288 |
- const char signature[] = "aeabi";
|
|
|
244288 |
- /* N.B. LEN is including the length field
|
|
|
244288 |
- * itself. */
|
|
|
244288 |
- uint32_t sec_len;
|
|
|
244288 |
- if (elf_read_u32(data, offset, &sec_len) < 0
|
|
|
244288 |
- || !elf_can_read_next(data, offset, sec_len)) {
|
|
|
244288 |
- goto done;
|
|
|
244288 |
- }
|
|
|
244288 |
- const GElf_Xword next_offset = offset + sec_len;
|
|
|
244288 |
- offset += 4;
|
|
|
244288 |
-
|
|
|
244288 |
- if (sec_len < 4 + sizeof signature
|
|
|
244288 |
- || strcmp(signature, data->d_buf + offset) != 0)
|
|
|
244288 |
- goto skip;
|
|
|
244288 |
- offset += sizeof signature;
|
|
|
244288 |
-
|
|
|
244288 |
- const GElf_Xword offset0 = offset;
|
|
|
244288 |
- uint64_t tag;
|
|
|
244288 |
- uint32_t sub_len;
|
|
|
244288 |
- if (elf_read_next_uleb128(data, &offset, &tag) < 0
|
|
|
244288 |
- || elf_read_next_u32(data, &offset, &sub_len) < 0
|
|
|
244288 |
- || !elf_can_read_next(data, offset0, sub_len))
|
|
|
244288 |
- goto done;
|
|
|
244288 |
-
|
|
|
244288 |
- if (tag != 1)
|
|
|
244288 |
- /* IHI0045D_ABI_addenda: "section and
|
|
|
244288 |
- * symbol attributes are deprecated
|
|
|
244288 |
- * [...] consumers are permitted to
|
|
|
244288 |
- * ignore them." */
|
|
|
244288 |
- goto skip;
|
|
|
244288 |
-
|
|
|
244288 |
- while (offset < offset0 + sub_len) {
|
|
|
244288 |
- if (elf_read_next_uleb128(data,
|
|
|
244288 |
- &offset, &tag) < 0)
|
|
|
244288 |
- goto done;
|
|
|
244288 |
-
|
|
|
244288 |
- switch (tag) {
|
|
|
244288 |
- uint64_t v;
|
|
|
244288 |
- case 6: /* Tag_CPU_arch */
|
|
|
244288 |
- case 7: /* Tag_CPU_arch_profile */
|
|
|
244288 |
- case 8: /* Tag_ARM_ISA_use */
|
|
|
244288 |
- case 9: /* Tag_THUMB_ISA_use */
|
|
|
244288 |
- case 10: /* Tag_FP_arch */
|
|
|
244288 |
- case 11: /* Tag_WMMX_arch */
|
|
|
244288 |
- case 12: /* Tag_Advanced_SIMD_arch */
|
|
|
244288 |
- case 13: /* Tag_PCS_config */
|
|
|
244288 |
- case 14: /* Tag_ABI_PCS_R9_use */
|
|
|
244288 |
- case 15: /* Tag_ABI_PCS_RW_data */
|
|
|
244288 |
- case 16: /* Tag_ABI_PCS_RO_data */
|
|
|
244288 |
- case 17: /* Tag_ABI_PCS_GOT_use */
|
|
|
244288 |
- case 18: /* Tag_ABI_PCS_wchar_t */
|
|
|
244288 |
- case 19: /* Tag_ABI_FP_rounding */
|
|
|
244288 |
- case 20: /* Tag_ABI_FP_denormal */
|
|
|
244288 |
- case 21: /* Tag_ABI_FP_exceptions */
|
|
|
244288 |
- case 22: /* Tag_ABI_FP_user_exceptions */
|
|
|
244288 |
- case 23: /* Tag_ABI_FP_number_model */
|
|
|
244288 |
- case 24: /* Tag_ABI_align_needed */
|
|
|
244288 |
- case 25: /* Tag_ABI_align_preserved */
|
|
|
244288 |
- case 26: /* Tag_ABI_enum_size */
|
|
|
244288 |
- case 27: /* Tag_ABI_HardFP_use */
|
|
|
244288 |
- case 28: /* Tag_ABI_VFP_args */
|
|
|
244288 |
- case 29: /* Tag_ABI_WMMX_args */
|
|
|
244288 |
- case 30: /* Tag_ABI_optimization_goals */
|
|
|
244288 |
- case 31: /* Tag_ABI_FP_optimization_goals */
|
|
|
244288 |
- case 32: /* Tag_compatibility */
|
|
|
244288 |
- case 34: /* Tag_CPU_unaligned_access */
|
|
|
244288 |
- case 36: /* Tag_FP_HP_extension */
|
|
|
244288 |
- case 38: /* Tag_ABI_FP_16bit_format */
|
|
|
244288 |
- case 42: /* Tag_MPextension_use */
|
|
|
244288 |
- case 70: /* Tag_MPextension_use as well */
|
|
|
244288 |
- case 44: /* Tag_DIV_use */
|
|
|
244288 |
- case 64: /* Tag_nodefaults */
|
|
|
244288 |
- case 66: /* Tag_T2EE_use */
|
|
|
244288 |
- case 68: /* Tag_Virtualization_use */
|
|
|
244288 |
- uleb128:
|
|
|
244288 |
- if (elf_read_next_uleb128
|
|
|
244288 |
- (data, &offset, &v) < 0)
|
|
|
244288 |
- goto done;
|
|
|
244288 |
- if (tag == 28)
|
|
|
244288 |
- hardfp = get_hardfp(v);
|
|
|
244288 |
- if (tag != 32)
|
|
|
244288 |
- continue;
|
|
|
244288 |
-
|
|
|
244288 |
- /* Tag 32 has two arguments,
|
|
|
244288 |
- * fall through. */
|
|
|
244288 |
-
|
|
|
244288 |
- case 4: /* Tag_CPU_raw_name */
|
|
|
244288 |
- case 5: /* Tag_CPU_name */
|
|
|
244288 |
- case 65: /* Tag_also_compatible_with */
|
|
|
244288 |
- case 67: /* Tag_conformance */
|
|
|
244288 |
- ntbs:
|
|
|
244288 |
- offset += strlen(data->d_buf
|
|
|
244288 |
- + offset) + 1;
|
|
|
244288 |
- continue;
|
|
|
244288 |
- }
|
|
|
244288 |
-
|
|
|
244288 |
- /* Handle unknown tags in a generic
|
|
|
244288 |
- * manner, if possible. */
|
|
|
244288 |
- if (tag <= 32) {
|
|
|
244288 |
- fprintf(stderr,
|
|
|
244288 |
- "Unknown tag %lld "
|
|
|
244288 |
- "at offset %#llx "
|
|
|
244288 |
- "of ARM attribute section.",
|
|
|
244288 |
- tag, offset);
|
|
|
244288 |
- goto skip;
|
|
|
244288 |
- } else if (tag % 2 == 0) {
|
|
|
244288 |
- goto uleb128;
|
|
|
244288 |
- } else {
|
|
|
244288 |
- goto ntbs;
|
|
|
244288 |
- }
|
|
|
244288 |
- }
|
|
|
244288 |
-
|
|
|
244288 |
- skip:
|
|
|
244288 |
- offset = next_offset;
|
|
|
244288 |
-
|
|
|
244288 |
- } while (elf_can_read_next(data, offset, 1));
|
|
|
244288 |
-
|
|
|
244288 |
- }
|
|
|
244288 |
-
|
|
|
244288 |
-done:
|
|
|
244288 |
- lib->arch.hardfp = hardfp;
|
|
|
244288 |
- return 0;
|
|
|
244288 |
-}
|
|
|
244288 |
-
|
|
|
244288 |
-void
|
|
|
244288 |
-arch_elf_destroy(struct ltelf *lte)
|
|
|
244288 |
-{
|
|
|
244288 |
-}
|
|
|
244288 |
-
|
|
|
244288 |
-int
|
|
|
244288 |
-arch_library_init(struct library *lib)
|
|
|
244288 |
-{
|
|
|
244288 |
- return 0;
|
|
|
244288 |
-}
|
|
|
244288 |
-
|
|
|
244288 |
-void
|
|
|
244288 |
-arch_library_destroy(struct library *lib)
|
|
|
244288 |
-{
|
|
|
244288 |
-}
|
|
|
244288 |
-
|
|
|
244288 |
-int
|
|
|
244288 |
-arch_library_clone(struct library *retp, struct library *lib)
|
|
|
244288 |
-{
|
|
|
244288 |
- retp->arch = lib->arch;
|
|
|
244288 |
- return 0;
|
|
|
244288 |
-}
|
|
|
244288 |
-
|
|
|
244288 |
enum {
|
|
|
244288 |
/* How many (double) VFP registers the AAPCS uses for
|
|
|
244288 |
* parameter passing. */
|
|
|
244288 |
diff --git a/sysdeps/linux-gnu/arm/plt.c b/sysdeps/linux-gnu/arm/plt.c
|
|
|
244288 |
index d1bf7ca..9e9e37f 100644
|
|
|
244288 |
--- a/sysdeps/linux-gnu/arm/plt.c
|
|
|
244288 |
+++ b/sysdeps/linux-gnu/arm/plt.c
|
|
|
244288 |
@@ -1,5 +1,6 @@
|
|
|
244288 |
/*
|
|
|
244288 |
* This file is part of ltrace.
|
|
|
244288 |
+ * Copyright (C) 2013 Petr Machata, Red Hat Inc.
|
|
|
244288 |
* Copyright (C) 2010 Zach Welch, CodeSourcery
|
|
|
244288 |
* Copyright (C) 2004,2008,2009 Juan Cespedes
|
|
|
244288 |
*
|
|
|
244288 |
@@ -20,20 +21,205 @@
|
|
|
244288 |
*/
|
|
|
244288 |
|
|
|
244288 |
#include <gelf.h>
|
|
|
244288 |
+#include <stdio.h>
|
|
|
244288 |
+#include <string.h>
|
|
|
244288 |
|
|
|
244288 |
#include "proc.h"
|
|
|
244288 |
#include "library.h"
|
|
|
244288 |
#include "ltrace-elf.h"
|
|
|
244288 |
|
|
|
244288 |
static int
|
|
|
244288 |
+get_hardfp(uint64_t abi_vfp_args)
|
|
|
244288 |
+{
|
|
|
244288 |
+ if (abi_vfp_args == 2)
|
|
|
244288 |
+ fprintf(stderr,
|
|
|
244288 |
+ "Tag_ABI_VFP_args value 2 (tool chain-specific "
|
|
|
244288 |
+ "conventions) not supported.\n");
|
|
|
244288 |
+ return abi_vfp_args == 1;
|
|
|
244288 |
+}
|
|
|
244288 |
+
|
|
|
244288 |
+int
|
|
|
244288 |
+arch_elf_init(struct ltelf *lte, struct library *lib)
|
|
|
244288 |
+{
|
|
|
244288 |
+ GElf_Addr jmprel_addr;
|
|
|
244288 |
+ Elf_Scn *jmprel_sec;
|
|
|
244288 |
+ GElf_Shdr jmprel_shdr;
|
|
|
244288 |
+ if (elf_load_dynamic_entry(lte, DT_JMPREL, &jmprel_addr) < 0
|
|
|
244288 |
+ || elf_get_section_covering(lte, jmprel_addr,
|
|
|
244288 |
+ &jmprel_sec, &jmprel_shdr) < 0
|
|
|
244288 |
+ || jmprel_sec == NULL)
|
|
|
244288 |
+ return -1;
|
|
|
244288 |
+
|
|
|
244288 |
+ lte->arch.jmprel_data = elf_loaddata(jmprel_sec, &jmprel_shdr);
|
|
|
244288 |
+ if (lte->arch.jmprel_data == NULL)
|
|
|
244288 |
+ return -1;
|
|
|
244288 |
+
|
|
|
244288 |
+ /* Nothing in this section is strictly critical. It's not
|
|
|
244288 |
+ * that much of a deal if we fail to guess right whether the
|
|
|
244288 |
+ * ABI is softfp or hardfp. */
|
|
|
244288 |
+ unsigned hardfp = 0;
|
|
|
244288 |
+
|
|
|
244288 |
+ Elf_Scn *scn;
|
|
|
244288 |
+ Elf_Data *data;
|
|
|
244288 |
+ GElf_Shdr shdr;
|
|
|
244288 |
+ if (elf_get_section_type(lte, SHT_ARM_ATTRIBUTES, &scn, &shdr) < 0
|
|
|
244288 |
+ || (scn != NULL && (data = elf_loaddata(scn, &shdr)) == NULL)) {
|
|
|
244288 |
+ fprintf(stderr,
|
|
|
244288 |
+ "Error when obtaining ARM attribute section: %s\n",
|
|
|
244288 |
+ elf_errmsg(-1));
|
|
|
244288 |
+ goto done;
|
|
|
244288 |
+
|
|
|
244288 |
+ } else if (scn != NULL && data != NULL) {
|
|
|
244288 |
+ GElf_Xword offset = 0;
|
|
|
244288 |
+ uint8_t version;
|
|
|
244288 |
+ if (elf_read_next_u8(data, &offset, &version) < 0) {
|
|
|
244288 |
+ goto done;
|
|
|
244288 |
+ } else if (version != 'A') {
|
|
|
244288 |
+ fprintf(stderr, "Unsupported ARM attribute section "
|
|
|
244288 |
+ "version %d ('%c').\n", version, version);
|
|
|
244288 |
+ goto done;
|
|
|
244288 |
+ }
|
|
|
244288 |
+
|
|
|
244288 |
+ do {
|
|
|
244288 |
+ const char signature[] = "aeabi";
|
|
|
244288 |
+ /* N.B. LEN is including the length field
|
|
|
244288 |
+ * itself. */
|
|
|
244288 |
+ uint32_t sec_len;
|
|
|
244288 |
+ if (elf_read_u32(data, offset, &sec_len) < 0
|
|
|
244288 |
+ || !elf_can_read_next(data, offset, sec_len)) {
|
|
|
244288 |
+ goto done;
|
|
|
244288 |
+ }
|
|
|
244288 |
+ const GElf_Xword next_offset = offset + sec_len;
|
|
|
244288 |
+ offset += 4;
|
|
|
244288 |
+
|
|
|
244288 |
+ if (sec_len < 4 + sizeof signature
|
|
|
244288 |
+ || strcmp(signature, data->d_buf + offset) != 0)
|
|
|
244288 |
+ goto skip;
|
|
|
244288 |
+ offset += sizeof signature;
|
|
|
244288 |
+
|
|
|
244288 |
+ const GElf_Xword offset0 = offset;
|
|
|
244288 |
+ uint64_t tag;
|
|
|
244288 |
+ uint32_t sub_len;
|
|
|
244288 |
+ if (elf_read_next_uleb128(data, &offset, &tag) < 0
|
|
|
244288 |
+ || elf_read_next_u32(data, &offset, &sub_len) < 0
|
|
|
244288 |
+ || !elf_can_read_next(data, offset0, sub_len))
|
|
|
244288 |
+ goto done;
|
|
|
244288 |
+
|
|
|
244288 |
+ if (tag != 1)
|
|
|
244288 |
+ /* IHI0045D_ABI_addenda: "section and
|
|
|
244288 |
+ * symbol attributes are deprecated
|
|
|
244288 |
+ * [...] consumers are permitted to
|
|
|
244288 |
+ * ignore them." */
|
|
|
244288 |
+ goto skip;
|
|
|
244288 |
+
|
|
|
244288 |
+ while (offset < offset0 + sub_len) {
|
|
|
244288 |
+ if (elf_read_next_uleb128(data,
|
|
|
244288 |
+ &offset, &tag) < 0)
|
|
|
244288 |
+ goto done;
|
|
|
244288 |
+
|
|
|
244288 |
+ switch (tag) {
|
|
|
244288 |
+ uint64_t v;
|
|
|
244288 |
+ case 6: /* Tag_CPU_arch */
|
|
|
244288 |
+ case 7: /* Tag_CPU_arch_profile */
|
|
|
244288 |
+ case 8: /* Tag_ARM_ISA_use */
|
|
|
244288 |
+ case 9: /* Tag_THUMB_ISA_use */
|
|
|
244288 |
+ case 10: /* Tag_FP_arch */
|
|
|
244288 |
+ case 11: /* Tag_WMMX_arch */
|
|
|
244288 |
+ case 12: /* Tag_Advanced_SIMD_arch */
|
|
|
244288 |
+ case 13: /* Tag_PCS_config */
|
|
|
244288 |
+ case 14: /* Tag_ABI_PCS_R9_use */
|
|
|
244288 |
+ case 15: /* Tag_ABI_PCS_RW_data */
|
|
|
244288 |
+ case 16: /* Tag_ABI_PCS_RO_data */
|
|
|
244288 |
+ case 17: /* Tag_ABI_PCS_GOT_use */
|
|
|
244288 |
+ case 18: /* Tag_ABI_PCS_wchar_t */
|
|
|
244288 |
+ case 19: /* Tag_ABI_FP_rounding */
|
|
|
244288 |
+ case 20: /* Tag_ABI_FP_denormal */
|
|
|
244288 |
+ case 21: /* Tag_ABI_FP_exceptions */
|
|
|
244288 |
+ case 22: /* Tag_ABI_FP_user_exceptions */
|
|
|
244288 |
+ case 23: /* Tag_ABI_FP_number_model */
|
|
|
244288 |
+ case 24: /* Tag_ABI_align_needed */
|
|
|
244288 |
+ case 25: /* Tag_ABI_align_preserved */
|
|
|
244288 |
+ case 26: /* Tag_ABI_enum_size */
|
|
|
244288 |
+ case 27: /* Tag_ABI_HardFP_use */
|
|
|
244288 |
+ case 28: /* Tag_ABI_VFP_args */
|
|
|
244288 |
+ case 29: /* Tag_ABI_WMMX_args */
|
|
|
244288 |
+ case 30: /* Tag_ABI_optimization_goals */
|
|
|
244288 |
+ case 31: /* Tag_ABI_FP_optimization_goals */
|
|
|
244288 |
+ case 32: /* Tag_compatibility */
|
|
|
244288 |
+ case 34: /* Tag_CPU_unaligned_access */
|
|
|
244288 |
+ case 36: /* Tag_FP_HP_extension */
|
|
|
244288 |
+ case 38: /* Tag_ABI_FP_16bit_format */
|
|
|
244288 |
+ case 42: /* Tag_MPextension_use */
|
|
|
244288 |
+ case 70: /* Tag_MPextension_use as well */
|
|
|
244288 |
+ case 44: /* Tag_DIV_use */
|
|
|
244288 |
+ case 64: /* Tag_nodefaults */
|
|
|
244288 |
+ case 66: /* Tag_T2EE_use */
|
|
|
244288 |
+ case 68: /* Tag_Virtualization_use */
|
|
|
244288 |
+ uleb128:
|
|
|
244288 |
+ if (elf_read_next_uleb128
|
|
|
244288 |
+ (data, &offset, &v) < 0)
|
|
|
244288 |
+ goto done;
|
|
|
244288 |
+ if (tag == 28)
|
|
|
244288 |
+ hardfp = get_hardfp(v);
|
|
|
244288 |
+ if (tag != 32)
|
|
|
244288 |
+ continue;
|
|
|
244288 |
+
|
|
|
244288 |
+ /* Tag 32 has two arguments,
|
|
|
244288 |
+ * fall through. */
|
|
|
244288 |
+
|
|
|
244288 |
+ case 4: /* Tag_CPU_raw_name */
|
|
|
244288 |
+ case 5: /* Tag_CPU_name */
|
|
|
244288 |
+ case 65: /* Tag_also_compatible_with */
|
|
|
244288 |
+ case 67: /* Tag_conformance */
|
|
|
244288 |
+ ntbs:
|
|
|
244288 |
+ offset += strlen(data->d_buf
|
|
|
244288 |
+ + offset) + 1;
|
|
|
244288 |
+ continue;
|
|
|
244288 |
+ }
|
|
|
244288 |
+
|
|
|
244288 |
+ /* Handle unknown tags in a generic
|
|
|
244288 |
+ * manner, if possible. */
|
|
|
244288 |
+ if (tag <= 32) {
|
|
|
244288 |
+ fprintf(stderr,
|
|
|
244288 |
+ "Unknown tag %lld "
|
|
|
244288 |
+ "at offset %#llx "
|
|
|
244288 |
+ "of ARM attribute section.",
|
|
|
244288 |
+ tag, offset);
|
|
|
244288 |
+ goto skip;
|
|
|
244288 |
+ } else if (tag % 2 == 0) {
|
|
|
244288 |
+ goto uleb128;
|
|
|
244288 |
+ } else {
|
|
|
244288 |
+ goto ntbs;
|
|
|
244288 |
+ }
|
|
|
244288 |
+ }
|
|
|
244288 |
+
|
|
|
244288 |
+ skip:
|
|
|
244288 |
+ offset = next_offset;
|
|
|
244288 |
+
|
|
|
244288 |
+ } while (elf_can_read_next(data, offset, 1));
|
|
|
244288 |
+
|
|
|
244288 |
+ }
|
|
|
244288 |
+
|
|
|
244288 |
+done:
|
|
|
244288 |
+ lib->arch.hardfp = hardfp;
|
|
|
244288 |
+ return 0;
|
|
|
244288 |
+}
|
|
|
244288 |
+
|
|
|
244288 |
+void
|
|
|
244288 |
+arch_elf_destroy(struct ltelf *lte)
|
|
|
244288 |
+{
|
|
|
244288 |
+}
|
|
|
244288 |
+
|
|
|
244288 |
+static int
|
|
|
244288 |
arch_plt_entry_has_stub(struct ltelf *lte, size_t off) {
|
|
|
244288 |
- uint16_t op = *(uint16_t *)((char *)lte->relplt->d_buf + off);
|
|
|
244288 |
+ char *buf = (char *) lte->arch.jmprel_data->d_buf;
|
|
|
244288 |
+ uint16_t op = *(uint16_t *) (buf + off);
|
|
|
244288 |
return op == 0x4778;
|
|
|
244288 |
}
|
|
|
244288 |
|
|
|
244288 |
GElf_Addr
|
|
|
244288 |
arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela) {
|
|
|
244288 |
- size_t start = lte->relplt->d_size + 12;
|
|
|
244288 |
+ size_t start = lte->arch.jmprel_data->d_size + 12;
|
|
|
244288 |
size_t off = start + 20, i;
|
|
|
244288 |
for (i = 0; i < ndx; i++)
|
|
|
244288 |
off += arch_plt_entry_has_stub(lte, off) ? 16 : 12;
|
|
|
244288 |
@@ -47,3 +233,21 @@ sym2addr(struct process *proc, struct library_symbol *sym)
|
|
|
244288 |
{
|
|
|
244288 |
return sym->enter_addr;
|
|
|
244288 |
}
|
|
|
244288 |
+
|
|
|
244288 |
+int
|
|
|
244288 |
+arch_library_init(struct library *lib)
|
|
|
244288 |
+{
|
|
|
244288 |
+ return 0;
|
|
|
244288 |
+}
|
|
|
244288 |
+
|
|
|
244288 |
+void
|
|
|
244288 |
+arch_library_destroy(struct library *lib)
|
|
|
244288 |
+{
|
|
|
244288 |
+}
|
|
|
244288 |
+
|
|
|
244288 |
+int
|
|
|
244288 |
+arch_library_clone(struct library *retp, struct library *lib)
|
|
|
244288 |
+{
|
|
|
244288 |
+ retp->arch = lib->arch;
|
|
|
244288 |
+ return 0;
|
|
|
244288 |
+}
|
|
|
244288 |
diff --git a/sysdeps/linux-gnu/ppc/plt.c b/sysdeps/linux-gnu/ppc/plt.c
|
|
|
244288 |
index 5e3ffe1..3ec1397 100644
|
|
|
244288 |
--- a/sysdeps/linux-gnu/ppc/plt.c
|
|
|
244288 |
+++ b/sysdeps/linux-gnu/ppc/plt.c
|
|
|
244288 |
@@ -402,38 +402,6 @@ get_glink_vma(struct ltelf *lte, GElf_Addr ppcgot, Elf_Data *plt_data)
|
|
|
244288 |
}
|
|
|
244288 |
|
|
|
244288 |
static int
|
|
|
244288 |
-load_dynamic_entry(struct ltelf *lte, int tag, GElf_Addr *valuep)
|
|
|
244288 |
-{
|
|
|
244288 |
- Elf_Scn *scn;
|
|
|
244288 |
- GElf_Shdr shdr;
|
|
|
244288 |
- if (elf_get_section_type(lte, SHT_DYNAMIC, &scn, &shdr) < 0
|
|
|
244288 |
- || scn == NULL) {
|
|
|
244288 |
- fail:
|
|
|
244288 |
- fprintf(stderr, "Couldn't get SHT_DYNAMIC: %s\n",
|
|
|
244288 |
- elf_errmsg(-1));
|
|
|
244288 |
- return -1;
|
|
|
244288 |
- }
|
|
|
244288 |
-
|
|
|
244288 |
- Elf_Data *data = elf_loaddata(scn, &shdr);
|
|
|
244288 |
- if (data == NULL)
|
|
|
244288 |
- goto fail;
|
|
|
244288 |
-
|
|
|
244288 |
- size_t j;
|
|
|
244288 |
- for (j = 0; j < shdr.sh_size / shdr.sh_entsize; ++j) {
|
|
|
244288 |
- GElf_Dyn dyn;
|
|
|
244288 |
- if (gelf_getdyn(data, j, &dyn) == NULL)
|
|
|
244288 |
- goto fail;
|
|
|
244288 |
-
|
|
|
244288 |
- if(dyn.d_tag == tag) {
|
|
|
244288 |
- *valuep = dyn.d_un.d_ptr;
|
|
|
244288 |
- return 0;
|
|
|
244288 |
- }
|
|
|
244288 |
- }
|
|
|
244288 |
-
|
|
|
244288 |
- return -1;
|
|
|
244288 |
-}
|
|
|
244288 |
-
|
|
|
244288 |
-static int
|
|
|
244288 |
nonzero_data(Elf_Data *data)
|
|
|
244288 |
{
|
|
|
244288 |
/* We are not supposed to get here if there's no PLT. */
|
|
|
244288 |
@@ -488,8 +456,8 @@ arch_elf_init(struct ltelf *lte, struct library *lib)
|
|
|
244288 |
Elf_Scn *rela_sec;
|
|
|
244288 |
GElf_Shdr rela_shdr;
|
|
|
244288 |
if ((lte->ehdr.e_machine == EM_PPC64 || lte->arch.secure_plt)
|
|
|
244288 |
- && load_dynamic_entry(lte, DT_RELA, &rela) == 0
|
|
|
244288 |
- && load_dynamic_entry(lte, DT_RELASZ, &relasz) == 0
|
|
|
244288 |
+ && elf_load_dynamic_entry(lte, DT_RELA, &rela) == 0
|
|
|
244288 |
+ && elf_load_dynamic_entry(lte, DT_RELASZ, &relasz) == 0
|
|
|
244288 |
&& elf_get_section_covering(lte, rela, &rela_sec, &rela_shdr) == 0
|
|
|
244288 |
&& rela_sec != NULL) {
|
|
|
244288 |
|
|
|
244288 |
@@ -509,7 +477,7 @@ arch_elf_init(struct ltelf *lte, struct library *lib)
|
|
|
244288 |
|
|
|
244288 |
if (lte->ehdr.e_machine == EM_PPC && lte->arch.secure_plt) {
|
|
|
244288 |
GElf_Addr ppcgot;
|
|
|
244288 |
- if (load_dynamic_entry(lte, DT_PPC_GOT, &ppcgot) < 0) {
|
|
|
244288 |
+ if (elf_load_dynamic_entry(lte, DT_PPC_GOT, &ppcgot) < 0) {
|
|
|
244288 |
fprintf(stderr, "couldn't find DT_PPC_GOT\n");
|
|
|
244288 |
return -1;
|
|
|
244288 |
}
|
|
|
244288 |
@@ -522,7 +490,8 @@ arch_elf_init(struct ltelf *lte, struct library *lib)
|
|
|
244288 |
|
|
|
244288 |
} else if (lte->ehdr.e_machine == EM_PPC64) {
|
|
|
244288 |
GElf_Addr glink_vma;
|
|
|
244288 |
- if (load_dynamic_entry(lte, DT_PPC64_GLINK, &glink_vma) < 0) {
|
|
|
244288 |
+ if (elf_load_dynamic_entry(lte, DT_PPC64_GLINK,
|
|
|
244288 |
+ &glink_vma) < 0) {
|
|
|
244288 |
fprintf(stderr, "couldn't find DT_PPC64_GLINK\n");
|
|
|
244288 |
return -1;
|
|
|
244288 |
}
|
|
|
244288 |
@@ -532,8 +501,8 @@ arch_elf_init(struct ltelf *lte, struct library *lib)
|
|
|
244288 |
|
|
|
244288 |
} else {
|
|
|
244288 |
/* By exhaustion--PPC32 BSS. */
|
|
|
244288 |
- if (load_dynamic_entry(lte, DT_PLTGOT,
|
|
|
244288 |
- &lib->arch.pltgot_addr) < 0) {
|
|
|
244288 |
+ if (elf_load_dynamic_entry(lte, DT_PLTGOT,
|
|
|
244288 |
+ &lib->arch.pltgot_addr) < 0) {
|
|
|
244288 |
fprintf(stderr, "couldn't find DT_PLTGOT\n");
|
|
|
244288 |
return -1;
|
|
|
244288 |
}
|