summaryrefslogtreecommitdiff
path: root/ldso
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-12-03 23:38:43 +0000
committerEric Andersen <andersen@codepoet.org>2003-12-03 23:38:43 +0000
commit0152631ea758c8756c8c350d3ad9f0f33fc9e211 (patch)
treeb15d28c3e5bb817f859d8d5697e88dd8cf2e8a93 /ldso
parent4f94490ef4045c1cc13542142414f6e0c96dee15 (diff)
Henrik Grindal Bakken writes:
The patch touches a minor (well, not that minor, but perhaps only rarely encountered) bug in the powerpc dynamic linker. The problem is that addi is called in inline assembly, but there is no restriction on the second argument. In powerpc assembler, if the second argument to addi is r0, it is taken as the value 0, not the contents of r0. This happened to me, making the stack pointer 0 on the invocation on the application. The patch is against 0.9.22, but there didn't seem to be any changes to the relevant section in 0.9.23.
Diffstat (limited to 'ldso')
-rw-r--r--ldso/ldso/powerpc/dl-sysdep.h12
-rw-r--r--ldso/ldso/powerpc/ld_sysdep.h12
2 files changed, 20 insertions, 4 deletions
diff --git a/ldso/ldso/powerpc/dl-sysdep.h b/ldso/ldso/powerpc/dl-sysdep.h
index fb22d1585..abd426830 100644
--- a/ldso/ldso/powerpc/dl-sysdep.h
+++ b/ldso/ldso/powerpc/dl-sysdep.h
@@ -99,13 +99,21 @@
* is done. This routine has to exit the current function, then
* call the _dl_elf_main function.
*/
+
+/* hgb@ifi.uio.no:
+ * Adding a clobber list consisting of r0 for %1. addi on PowerPC
+ * takes a register as the second argument, but if the register is
+ * r0, the value 0 is used instead. If r0 is used here, the stack
+ * pointer (r1) will be zeroed, and the dynamically linked
+ * application will seg.fault immediatly when receiving control.
+ */
#define START() \
__asm__ volatile ( \
"addi 1,%1,0\n\t" \
"mtlr %0\n\t" \
"blrl\n\t" \
- : : "r" (_dl_elf_main), "r" (args))
-
+ : : "r" (_dl_elf_main), "r" (args) \
+ : "r0")
/* Here we define the magic numbers that this dynamic loader should accept */
diff --git a/ldso/ldso/powerpc/ld_sysdep.h b/ldso/ldso/powerpc/ld_sysdep.h
index fb22d1585..abd426830 100644
--- a/ldso/ldso/powerpc/ld_sysdep.h
+++ b/ldso/ldso/powerpc/ld_sysdep.h
@@ -99,13 +99,21 @@
* is done. This routine has to exit the current function, then
* call the _dl_elf_main function.
*/
+
+/* hgb@ifi.uio.no:
+ * Adding a clobber list consisting of r0 for %1. addi on PowerPC
+ * takes a register as the second argument, but if the register is
+ * r0, the value 0 is used instead. If r0 is used here, the stack
+ * pointer (r1) will be zeroed, and the dynamically linked
+ * application will seg.fault immediatly when receiving control.
+ */
#define START() \
__asm__ volatile ( \
"addi 1,%1,0\n\t" \
"mtlr %0\n\t" \
"blrl\n\t" \
- : : "r" (_dl_elf_main), "r" (args))
-
+ : : "r" (_dl_elf_main), "r" (args) \
+ : "r0")
/* Here we define the magic numbers that this dynamic loader should accept */