summaryrefslogtreecommitdiff
path: root/libsanitizer
diff options
context:
space:
mode:
authorhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-06 21:50:42 +0000
committerhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-06 21:50:42 +0000
commit010ebb27536c2cdb4d0dba6f42380a48bd6a2b5c (patch)
tree69851a8c1b8b2b57f8cff2a7ff551f6c93367edf /libsanitizer
parent23e9a412c5e41d3abc48e13184e440bcf8ac6c83 (diff)
downloadgcc-010ebb27536c2cdb4d0dba6f42380a48bd6a2b5c.tar.gz
Fix internal_clone for x32
PR sanitizer/59018 * sanitizer_common/sanitizer_linux.cc (internal_clone): Allocate 2 64-bit integers to save and restore fn and arg. Properly load newtls/child_tidptr into r8/r10. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204481 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libsanitizer')
-rw-r--r--libsanitizer/ChangeLog7
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_linux.cc16
2 files changed, 15 insertions, 8 deletions
diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog
index b874b13c4f3..6103d62b329 100644
--- a/libsanitizer/ChangeLog
+++ b/libsanitizer/ChangeLog
@@ -1,6 +1,13 @@
2013-11-05 H.J. Lu <hongjiu.lu@intel.com>
PR sanitizer/59018
+ * sanitizer_common/sanitizer_linux.cc (internal_clone): Allocate
+ 2 64-bit integers to save and restore fn and arg. Properly load
+ newtls/child_tidptr into r8/r10.
+
+2013-11-05 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR sanitizer/59018
* sanitizer_common/sanitizer_linux.cc (internal_mmap,
internal_munmap, internal_open, internal_read, internal_write,
internal_stat, internal_lstat, internal_fstat, internal_readlink,
diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.cc b/libsanitizer/sanitizer_common/sanitizer_linux.cc
index e48bee5be6e..2763313015a 100644
--- a/libsanitizer/sanitizer_common/sanitizer_linux.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_linux.cc
@@ -772,9 +772,11 @@ uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg,
if (!fn || !child_stack)
return -EINVAL;
CHECK_EQ(0, (uptr)child_stack % 16);
- child_stack = (char *)child_stack - 2 * sizeof(void *);
- ((void **)child_stack)[0] = (void *)(uptr)fn;
- ((void **)child_stack)[1] = arg;
+ child_stack = (char *)child_stack - 2 * sizeof(unsigned long long);
+ ((unsigned long long *)child_stack)[0] = (uptr)fn;
+ ((unsigned long long *)child_stack)[1] = (uptr)arg;
+ register void *r8 __asm__ ("r8") = newtls;
+ register int *r10 __asm__ ("r10") = child_tidptr;
__asm__ __volatile__(
/* %rax = syscall(%rax = __NR_clone,
* %rdi = flags,
@@ -783,8 +785,6 @@ uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg,
* %r8 = new_tls,
* %r10 = child_tidptr)
*/
- "movq %6,%%r8\n"
- "movq %7,%%r10\n"
".cfi_endproc\n"
"syscall\n"
@@ -816,9 +816,9 @@ uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg,
"S"(child_stack),
"D"(flags),
"d"(parent_tidptr),
- "r"(newtls),
- "r"(child_tidptr)
- : "rsp", "memory", "r8", "r10", "r11", "rcx");
+ "r"(r8),
+ "r"(r10)
+ : "rsp", "memory", "r11", "rcx");
return res;
}
#endif // defined(__x86_64__)