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