Message ID | 20170112023038.13449-5-palmer@dabbelt.com |
---|---|
State | New |
Headers | show |
Have these changes been sent upstream? Although at the present development stage applying selected changes might be better than a bulk merge from upstream libsanitizer, they should still go upstream so they aren't a local patch at the time of the next merge.
On 12 January 2017 03:30:36 CET, Palmer Dabbelt <palmer@dabbelt.com> wrote: >--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc >+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc >@@ -64,7 +64,7 @@ namespace __sanitizer { > >#if !defined(__powerpc64__) && !defined(__x86_64__) && >!defined(__aarch64__)\ > && !defined(__mips__) && !defined(__s390__)\ >- && !defined(__sparc__) >+ && !defined(__sparc__) && && >!defined(__riscv) Lots of ampersands.. how would that compile?
On Thu, 12 Jan 2017 15:39:54 PST (-0800), joseph@codesourcery.com wrote: > Have these changes been sent upstream? Although at the present > development stage applying selected changes might be better than a bulk > merge from upstream libsanitizer, they should still go upstream so they > aren't a local patch at the time of the next merge. Sorry, I didn't know there was an upstream to this. I went to send this upstream to the LLVM compiler-rt repo, but I think this port is actually broken: it turns out we hadn't built it in a while (which is why the double-&& wasn't noticed, it must have come from a rebase) and it looks like we don't quite have a sane set of Linux headers right now so we don't quite match up with the SANITIZER_USES_CANONICAL_LINUX_SYSCALLS macro any more. I think it'd be best if we just drop this for now and wait for our Linux port to stabilize a bit (which we're planning on doing after the GCC code reviews). There's a bit too much stuff in flight for me to be able to keep track of it all right now. Sorry! Also, thanks for finding the "&& &&" bug -- I hadn't noticed we weren't compiling libsanitizer any more.
diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.cc b/libsanitizer/sanitizer_common/sanitizer_linux.cc index 806fcd5..4de9d16 100644 --- a/libsanitizer/sanitizer_common/sanitizer_linux.cc +++ b/libsanitizer/sanitizer_common/sanitizer_linux.cc @@ -1369,6 +1369,11 @@ void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) { *pc = ucontext->uc_mcontext.pc; *bp = ucontext->uc_mcontext.gregs[30]; *sp = ucontext->uc_mcontext.gregs[29]; +#elif defined(__riscv) + ucontext_t *ucontext = (ucontext_t*)context; + *pc = ucontext->uc_mcontext.gregs[REG_PC]; + *bp = ucontext->uc_mcontext.gregs[REG_S0]; + *sp = ucontext->uc_mcontext.gregs[REG_SP]; #elif defined(__s390__) ucontext_t *ucontext = (ucontext_t*)context; # if defined(__s390x__) diff --git a/libsanitizer/sanitizer_common/sanitizer_platform.h b/libsanitizer/sanitizer_common/sanitizer_platform.h index 428709d..5519bc6 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform.h +++ b/libsanitizer/sanitizer_common/sanitizer_platform.h @@ -188,9 +188,9 @@ // The AArch64 linux port uses the canonical syscall set as mandated by // the upstream linux community for all new ports. Other ports may still -// use legacy syscalls. +// use legacy syscalls. The RISC-V port also does this. #ifndef SANITIZER_USES_CANONICAL_LINUX_SYSCALLS -# if defined(__aarch64__) && SANITIZER_LINUX +# if (defined(__aarch64__) || defined(__riscv)) && SANITIZER_LINUX # define SANITIZER_USES_CANONICAL_LINUX_SYSCALLS 1 # else # define SANITIZER_USES_CANONICAL_LINUX_SYSCALLS 0 diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc index 23a0148..11a3850 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc @@ -64,7 +64,7 @@ namespace __sanitizer { #if !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__aarch64__)\ && !defined(__mips__) && !defined(__s390__)\ - && !defined(__sparc__) + && !defined(__sparc__) && && !defined(__riscv) COMPILER_CHECK(struct___old_kernel_stat_sz == sizeof(struct __old_kernel_stat)); #endif diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h index c139322..dddcef2 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h @@ -83,6 +83,9 @@ namespace __sanitizer { SANITIZER_ANDROID ? FIRST_32_SECOND_64(104, 128) : FIRST_32_SECOND_64(144, 216); const unsigned struct_kernel_stat64_sz = 104; +#elif defined(__riscv) + const unsigned struct_kernel_stat_sz = 128; + const unsigned struct_kernel_stat64_sz = 128; #elif defined(__s390__) && !defined(__s390x__) const unsigned struct_kernel_stat_sz = 64; const unsigned struct_kernel_stat64_sz = 104; @@ -117,7 +120,7 @@ namespace __sanitizer { #if SANITIZER_LINUX || SANITIZER_FREEBSD -#if defined(__powerpc64__) || defined(__s390__) +#if defined(__powerpc64__) || defined(__riscv) || defined(__s390__) const unsigned struct___old_kernel_stat_sz = 0; #elif !defined(__sparc__) const unsigned struct___old_kernel_stat_sz = 32; @@ -540,7 +543,7 @@ namespace __sanitizer { typedef long __sanitizer___kernel_off_t; #endif -#if defined(__powerpc__) || defined(__mips__) +#if defined(__powerpc__) || defined(__mips__) || defined(__riscv) typedef unsigned int __sanitizer___kernel_old_uid_t; typedef unsigned int __sanitizer___kernel_old_gid_t; #else