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