Blame SOURCES/ltrace-0.7.91-arm.patch

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