Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: gcc 5.3 version of libasan is broken



In article <86442cf7-1763-9b78-0c4e-173e4e27e1e3%rk.phys.keio.ac.jp@localhost>,
Rin Okuyama  <rokuyama%rk.phys.keio.ac.jp@localhost> wrote:
>I found two problems on libasan of gcc 5.3.
>
>(1) build fails on arm:
>
>http://releng.netbsd.org/builds/HEAD/201606061330Z/
>
>As we use dwarf EH, we must disable __arm__ specific codes in
>sanitizer_unwind_posix_libcdep.cc, cf. gcc.old version of
>sanitizer_netbsd.cc:
>
>  
>https://nxr.netbsd.org/xref/src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_netbsd.cc#393
>
>(2) binaries compiled with -fsanitize=address receive SEGV_MAPERR on
>32bit big-endian machines. This is because the original code assumes
>32bit little-endian or 64bit environments in sanitizer_linux.cc;
>return values of internal_syscall(SYSCALL(mmap), ...) == __syscall(
>SYS_mmap, ...) are quad_t == int64_t. Therefore, we need a special
>care for 32bit big-endian machines to extract the mapped address.
>The arguments for mmap are also reordered for ours.
>
>Please apply the attached patch, which was tested on evbearmv7hf-eb.
>It works also on amd64 and i386. I will send a PR if necessary.
>
>Thanks,
>Rin
>
>---
>src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_unwind_posix_libcdep.cc.orig	2016-06-07 03:02:26.599568511 +0900
>+++
>src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_unwind_posix_libcdep.cc	2016-06-07 03:02:51.632737172 +0900
>@@ -71,7 +71,8 @@
>  }
>  #endif
>  
>-#ifdef __arm__
>+#if defined(__arm__) && !SANITIZER_NETBSD
>+// NetBSD uses dwarf EH
>  #define UNWIND_STOP _URC_END_OF_STACK
>  #define UNWIND_CONTINUE _URC_NO_REASON
>  #else
>@@ -80,7 +81,7 @@
>  #endif
>  
>  uptr Unwind_GetIP(struct _Unwind_Context *ctx) {
>-#ifdef __arm__
>+#if defined(__arm__) && !SANITIZER_NETBSD
>    uptr val;
>    _Unwind_VRS_Result res = _Unwind_VRS_Get(ctx, _UVRSC_CORE,
>        15 /* r15 = PC */, _UVRSD_UINT32, &val);
>---
>src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc.orig
>2016-06-07 03:02:26.596812764 +0900
>+++
>src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc
>2016-06-07 04:19:50.028342374 +0900
>@@ -101,7 +101,12 @@
>  // --------------- sanitizer_libc.h
>  uptr internal_mmap(void *addr, uptr length, int prot, int flags,
>                      int fd, u64 offset) {
>-#if SANITIZER_NETBSD || SANITIZER_FREEBSD ||
>SANITIZER_LINUX_USES_64BIT_SYSCALLS
>+#if SANITIZER_NETBSD
>+  s64 s = internal_syscall(SYSCALL(mmap), (uptr)addr, length, prot, flags, fd,
>+			   (long)0, offset);
>+  uptr *p = (uptr *)&s;
>+  return *p;

Are you sure this works for 64 bit? I am worried about the (long)0, padding.

christos



Home | Main Index | Thread Index | Old Index