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