Added set_return_addr() to sysdeps/linux-gnu/*/regs.c
diff --git a/sysdeps/linux-gnu/alpha/plt.c b/sysdeps/linux-gnu/alpha/plt.c
index 11950c2..83337b2 100644
--- a/sysdeps/linux-gnu/alpha/plt.c
+++ b/sysdeps/linux-gnu/alpha/plt.c
@@ -1,6 +1,5 @@
 #include <gelf.h>
 #include "common.h"
-#include "elf.h"
 
 GElf_Addr
 arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela) {
diff --git a/sysdeps/linux-gnu/alpha/regs.c b/sysdeps/linux-gnu/alpha/regs.c
index 5521e84..7e02eb2 100644
--- a/sysdeps/linux-gnu/alpha/regs.c
+++ b/sysdeps/linux-gnu/alpha/regs.c
@@ -35,3 +35,8 @@
 get_return_addr(Process *proc, void *stack_pointer) {
 	return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, 26 /* RA */ , 0);
 }
+
+void
+set_return_addr(Process *proc, void *addr) {
+	ptrace(PTRACE_POKEUSER, proc->pid, 26 /* RA */ , addr);
+}
diff --git a/sysdeps/linux-gnu/arm/plt.c b/sysdeps/linux-gnu/arm/plt.c
index 8866705..bd92a63 100644
--- a/sysdeps/linux-gnu/arm/plt.c
+++ b/sysdeps/linux-gnu/arm/plt.c
@@ -1,6 +1,5 @@
 #include <gelf.h>
 #include "common.h"
-#include "elf.h"
 
 GElf_Addr
 arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela) {
diff --git a/sysdeps/linux-gnu/arm/regs.c b/sysdeps/linux-gnu/arm/regs.c
index 1566e1c..49ccb90 100644
--- a/sysdeps/linux-gnu/arm/regs.c
+++ b/sysdeps/linux-gnu/arm/regs.c
@@ -46,3 +46,8 @@
 		addr &= ~1;
 	return (void *)addr;
 }
+
+void
+set_return_addr(Process *proc, void *addr) {
+	ptrace(PTRACE_POKEUSER, proc->pid, off_lr, addr);
+}
diff --git a/sysdeps/linux-gnu/breakpoint.c b/sysdeps/linux-gnu/breakpoint.c
index ebd8d8a..f005c6b 100644
--- a/sysdeps/linux-gnu/breakpoint.c
+++ b/sysdeps/linux-gnu/breakpoint.c
@@ -6,6 +6,7 @@
 #include <string.h>
 
 #include "common.h"
+#include "arch.h"
 
 static unsigned char break_insn[] = BREAKPOINT_VALUE;
 
diff --git a/sysdeps/linux-gnu/i386/plt.c b/sysdeps/linux-gnu/i386/plt.c
index 834d3a3..b53ff44 100644
--- a/sysdeps/linux-gnu/i386/plt.c
+++ b/sysdeps/linux-gnu/i386/plt.c
@@ -1,6 +1,5 @@
 #include <gelf.h>
 #include "common.h"
-#include "elf.h"
 
 GElf_Addr
 arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela) {
diff --git a/sysdeps/linux-gnu/i386/regs.c b/sysdeps/linux-gnu/i386/regs.c
index 0884217..c2518e7 100644
--- a/sysdeps/linux-gnu/i386/regs.c
+++ b/sysdeps/linux-gnu/i386/regs.c
@@ -35,3 +35,8 @@
 get_return_addr(Process *proc, void *stack_pointer) {
 	return (void *)ptrace(PTRACE_PEEKTEXT, proc->pid, stack_pointer, 0);
 }
+
+void
+set_return_addr(Process *proc, void *addr) {
+	ptrace(PTRACE_POKETEXT, proc->pid, proc->stack_pointer, (long)addr);
+}
diff --git a/sysdeps/linux-gnu/ia64/plt.c b/sysdeps/linux-gnu/ia64/plt.c
index 5b8bbb0..7fd451b 100644
--- a/sysdeps/linux-gnu/ia64/plt.c
+++ b/sysdeps/linux-gnu/ia64/plt.c
@@ -1,7 +1,5 @@
 #include <gelf.h>
 #include "common.h"
-#include "elf.h"
-#include "debug.h"
 
 /* A bundle is 128 bits */
 #define BUNDLE_SIZE 16
diff --git a/sysdeps/linux-gnu/ia64/regs.c b/sysdeps/linux-gnu/ia64/regs.c
index e08f495..b8b8ea1 100644
--- a/sysdeps/linux-gnu/ia64/regs.c
+++ b/sysdeps/linux-gnu/ia64/regs.c
@@ -46,3 +46,8 @@
 get_return_addr(Process *proc, void *stack_pointer) {
 	return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, PT_B0, 0);
 }
+
+void
+set_return_addr(Process *proc, void *addr) {
+	ptrace(PTRACE_POKEUSER, proc->pid, PT_B0, addr);
+}
diff --git a/sysdeps/linux-gnu/m68k/plt.c b/sysdeps/linux-gnu/m68k/plt.c
index 79c1173..508d7fc 100644
--- a/sysdeps/linux-gnu/m68k/plt.c
+++ b/sysdeps/linux-gnu/m68k/plt.c
@@ -1,6 +1,5 @@
 #include <gelf.h>
 #include "common.h"
-#include "elf.h"
 
 GElf_Addr
 arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela) {
diff --git a/sysdeps/linux-gnu/m68k/regs.c b/sysdeps/linux-gnu/m68k/regs.c
index 5acfb61..f4a9a65 100644
--- a/sysdeps/linux-gnu/m68k/regs.c
+++ b/sysdeps/linux-gnu/m68k/regs.c
@@ -35,3 +35,8 @@
 get_return_addr(Process *proc, void *stack_pointer) {
 	return (void *)ptrace(PTRACE_PEEKTEXT, proc->pid, stack_pointer, 0);
 }
+
+void
+set_return_addr(Process *proc, void *addr) {
+	ptrace(PTRACE_POKETEXT, proc->pid, proc->stack_pointer, addr);
+}
diff --git a/sysdeps/linux-gnu/mipsel/plt.c b/sysdeps/linux-gnu/mipsel/plt.c
index 37fa0b1..003171b 100644
--- a/sysdeps/linux-gnu/mipsel/plt.c
+++ b/sysdeps/linux-gnu/mipsel/plt.c
@@ -2,7 +2,6 @@
 #include <gelf.h>
 #include <sys/ptrace.h>
 #include "common.h"
-#include "ltrace_elf.h"
 
 /**
    \addtogroup mipsel
diff --git a/sysdeps/linux-gnu/mipsel/regs.c b/sysdeps/linux-gnu/mipsel/regs.c
index c986c73..0a511b0 100644
--- a/sysdeps/linux-gnu/mipsel/regs.c
+++ b/sysdeps/linux-gnu/mipsel/regs.c
@@ -70,4 +70,8 @@
 get_return_addr(Process *proc, void *stack_pointer) {
 	return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, off_lr, 0);
 }
-/**@}*/
+
+void
+set_return_addr(Process *proc, void *addr) {
+	ptrace(PTRACE_POKEUSER, proc->pid, off_lr, addr);
+}
diff --git a/sysdeps/linux-gnu/ppc/plt.c b/sysdeps/linux-gnu/ppc/plt.c
index fb8af2c..31830fb 100644
--- a/sysdeps/linux-gnu/ppc/plt.c
+++ b/sysdeps/linux-gnu/ppc/plt.c
@@ -1,9 +1,5 @@
 #include <gelf.h>
 #include "common.h"
-#include "elf.h"
-#include "debug.h"
-#include "ptrace.h"
-#include "options.h"
 
 GElf_Addr
 arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela) {
diff --git a/sysdeps/linux-gnu/ppc/regs.c b/sysdeps/linux-gnu/ppc/regs.c
index 67df5c9..0468c9e 100644
--- a/sysdeps/linux-gnu/ppc/regs.c
+++ b/sysdeps/linux-gnu/ppc/regs.c
@@ -33,8 +33,12 @@
 
 void *
 get_return_addr(Process *proc, void *stack_pointer) {
-	return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, sizeof(long) * PT_LNK,
-			      0);
+	return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, sizeof(long)*PT_LNK, 0);
+}
+
+void
+set_return_addr(Process *proc, void *addr) {
+	ptrace(PTRACE_POKEUSER, proc->pid, sizeof(long)*PT_LNK, addr);
 }
 
 /* Grab the value of CTR registers.  */
diff --git a/sysdeps/linux-gnu/s390/plt.c b/sysdeps/linux-gnu/s390/plt.c
index c474b39..85a1dd1 100644
--- a/sysdeps/linux-gnu/s390/plt.c
+++ b/sysdeps/linux-gnu/s390/plt.c
@@ -1,6 +1,5 @@
 #include <gelf.h>
 #include "common.h"
-#include "elf.h"
 
 GElf_Addr
 arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela) {
diff --git a/sysdeps/linux-gnu/s390/regs.c b/sysdeps/linux-gnu/s390/regs.c
index 7d9e3d8..d6a7f7e 100644
--- a/sysdeps/linux-gnu/s390/regs.c
+++ b/sysdeps/linux-gnu/s390/regs.c
@@ -66,3 +66,12 @@
 #endif
 	return (void *)ret;
 }
+
+void
+set_return_addr(Process *proc, void *addr) {
+#ifdef __s390x__
+	if (proc->mask_32bit)
+		addr = (void *)((long)addr & PSW_MASK31);
+#endif
+	ptrace(PTRACE_POKEUSER, proc->pid, PT_GPR14, addr);
+}
diff --git a/sysdeps/linux-gnu/sparc/plt.c b/sysdeps/linux-gnu/sparc/plt.c
index 7f1920d..f9e6d80 100644
--- a/sysdeps/linux-gnu/sparc/plt.c
+++ b/sysdeps/linux-gnu/sparc/plt.c
@@ -1,6 +1,5 @@
 #include <gelf.h>
 #include "common.h"
-#include "elf.h"
 
 GElf_Addr
 arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela) {
diff --git a/sysdeps/linux-gnu/sparc/regs.c b/sysdeps/linux-gnu/sparc/regs.c
index 6ba359c..b14d6cd 100644
--- a/sysdeps/linux-gnu/sparc/regs.c
+++ b/sysdeps/linux-gnu/sparc/regs.c
@@ -41,3 +41,12 @@
 		return (void *)a->regs.r_o7 + 12;
 	return (void *)a->regs.r_o7 + 8;
 }
+
+void
+set_return_addr(Process *proc, void *addr) {
+	proc_archdep *a = (proc_archdep *) (proc->arch_ptr);
+	unsigned int t;
+	if (!a->valid)
+		return;
+	ptrace(PTRACE_POKETEXT, proc->pid, a->regs.r_o7 + 8, addr);
+}
diff --git a/sysdeps/linux-gnu/x86_64/plt.c b/sysdeps/linux-gnu/x86_64/plt.c
index 834d3a3..b53ff44 100644
--- a/sysdeps/linux-gnu/x86_64/plt.c
+++ b/sysdeps/linux-gnu/x86_64/plt.c
@@ -1,6 +1,5 @@
 #include <gelf.h>
 #include "common.h"
-#include "elf.h"
 
 GElf_Addr
 arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela) {
diff --git a/sysdeps/linux-gnu/x86_64/regs.c b/sysdeps/linux-gnu/x86_64/regs.c
index c865d09..3eb2453 100644
--- a/sysdeps/linux-gnu/x86_64/regs.c
+++ b/sysdeps/linux-gnu/x86_64/regs.c
@@ -47,3 +47,10 @@
 		ret &= 0xffffffff;
 	return (void *)ret;
 }
+
+void
+set_return_addr(Process *proc, void *addr) {
+	if (proc->mask_32bit)
+		addr = (void *)((long int)addr & 0xffffffff);
+	ptrace(PTRACE_POKETEXT, proc->pid, proc->stack_pointer, addr);
+}