PATCH: PR other/55292: libsanitizer doesn't support x32

H.J. Lu hjl.tools@gmail.com
Mon Nov 12 23:36:00 GMT 2012


Hi,

Linux/x32 doesn't have __NR_mmap2/__NR_fstat64 and uses
__NR_mmap/__NR_fstat, just like Linux/x86-64.  Tested on Linux/x32.
OK to install?

Thanks.


H.J.
--
2012-11-12  H.J. Lu  <hongjiu.lu@intel.com>

	PR other/55292
	* sanitizer_common/sanitizer_linux.cc (internal_mmap): Use
	__NR_mmap if __x86_64__ is defined.
	(internal_filesize): Use __NR_fstat if __x86_64__ is defined.

diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.cc b/libsanitizer/sanitizer_common/sanitizer_linux.cc
index ab6c5a4..5d29018 100644
--- a/libsanitizer/sanitizer_common/sanitizer_linux.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_linux.cc
@@ -34,7 +34,7 @@ namespace __sanitizer {
 // --------------- sanitizer_libc.h
 void *internal_mmap(void *addr, uptr length, int prot, int flags,
                     int fd, u64 offset) {
-#if __WORDSIZE == 64
+#if __WORDSIZE == 64 || defined __x86_64__
   return (void *)syscall(__NR_mmap, addr, length, prot, flags, fd, offset);
 #else
   return (void *)syscall(__NR_mmap2, addr, length, prot, flags, fd, offset);
@@ -67,7 +67,7 @@ uptr internal_write(fd_t fd, const void *buf, uptr count) {
 }
 
 uptr internal_filesize(fd_t fd) {
-#if __WORDSIZE == 64
+#if __WORDSIZE == 64 || defined __x86_64__
   struct stat st;
   if (syscall(__NR_fstat, fd, &st))
     return -1;



More information about the Gcc-patches mailing list