Recognize all NetBSD architectures in UBSan
Summary: Use uniform accessors for Program Pointer, Stack Pointer and Frame Pointer. Remove CPU check in UBSan supported platforms and rely only on the OS type. This adds NetBSD support in GetPcSpBp() for: - ARM - ARM64 - HPPA - PowerPC/PowerPC64 - SPARC/SPARC64 - MIPS - DEC Alpha AXP - DEC VAX - M68K and M68010 - SH3 - IA64 - OR1K - RISCV Sponsored by <The NetBSD Foundation> Reviewers: joerg, vitalybuka, ro Reviewed By: vitalybuka Subscribers: aemerson, jyknight, sdardis, kubamracek, arichardson, llvm-commits, kristof.beyls, fedor.sergeev, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D43021 llvm-svn: 325431
This commit is contained in:
		
							parent
							
								
									7d4a974d8b
								
							
						
					
					
						commit
						7cde46764a
					
				| 
						 | 
				
			
			@ -1725,7 +1725,13 @@ void SignalContext::DumpAllRegisters(void *context) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
 | 
			
		||||
#if defined(__arm__)
 | 
			
		||||
#if SANITIZER_NETBSD
 | 
			
		||||
  // This covers all NetBSD architectures
 | 
			
		||||
  ucontext_t *ucontext = (ucontext_t *)context;
 | 
			
		||||
  *pc = _UC_MACHINE_PC(ucontext);
 | 
			
		||||
  *bp = _UC_MACHINE_FP(ucontext);
 | 
			
		||||
  *sp = _UC_MACHINE_SP(ucontext);
 | 
			
		||||
#elif defined(__arm__)
 | 
			
		||||
  ucontext_t *ucontext = (ucontext_t*)context;
 | 
			
		||||
  *pc = ucontext->uc_mcontext.arm_pc;
 | 
			
		||||
  *bp = ucontext->uc_mcontext.arm_fp;
 | 
			
		||||
| 
						 | 
				
			
			@ -1747,11 +1753,6 @@ static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
 | 
			
		|||
  *pc = ucontext->uc_mcontext.mc_rip;
 | 
			
		||||
  *bp = ucontext->uc_mcontext.mc_rbp;
 | 
			
		||||
  *sp = ucontext->uc_mcontext.mc_rsp;
 | 
			
		||||
#elif SANITIZER_NETBSD
 | 
			
		||||
  ucontext_t *ucontext = (ucontext_t *)context;
 | 
			
		||||
  *pc = ucontext->uc_mcontext.__gregs[_REG_RIP];
 | 
			
		||||
  *bp = ucontext->uc_mcontext.__gregs[_REG_RBP];
 | 
			
		||||
  *sp = ucontext->uc_mcontext.__gregs[_REG_RSP];
 | 
			
		||||
# else
 | 
			
		||||
  ucontext_t *ucontext = (ucontext_t*)context;
 | 
			
		||||
  *pc = ucontext->uc_mcontext.gregs[REG_RIP];
 | 
			
		||||
| 
						 | 
				
			
			@ -1764,11 +1765,6 @@ static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
 | 
			
		|||
  *pc = ucontext->uc_mcontext.mc_eip;
 | 
			
		||||
  *bp = ucontext->uc_mcontext.mc_ebp;
 | 
			
		||||
  *sp = ucontext->uc_mcontext.mc_esp;
 | 
			
		||||
#elif SANITIZER_NETBSD
 | 
			
		||||
  ucontext_t *ucontext = (ucontext_t *)context;
 | 
			
		||||
  *pc = ucontext->uc_mcontext.__gregs[_REG_EIP];
 | 
			
		||||
  *bp = ucontext->uc_mcontext.__gregs[_REG_EBP];
 | 
			
		||||
  *sp = ucontext->uc_mcontext.__gregs[_REG_ESP];
 | 
			
		||||
# else
 | 
			
		||||
  ucontext_t *ucontext = (ucontext_t*)context;
 | 
			
		||||
# if SANITIZER_SOLARIS
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,13 +14,9 @@
 | 
			
		|||
#define UBSAN_PLATFORM_H
 | 
			
		||||
 | 
			
		||||
// Other platforms should be easy to add, and probably work as-is.
 | 
			
		||||
#if (defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) ||       \
 | 
			
		||||
     defined(__NetBSD__)) &&                                                   \
 | 
			
		||||
    (defined(__x86_64__) || defined(__i386__) || defined(__arm__) ||           \
 | 
			
		||||
     defined(__aarch64__) || defined(__mips__) || defined(__powerpc64__) ||    \
 | 
			
		||||
     defined(__s390__)) || (defined(__sun__) && defined(__svr4__))
 | 
			
		||||
# define CAN_SANITIZE_UB 1
 | 
			
		||||
#elif defined(_WIN32) || defined(__Fuchsia__)
 | 
			
		||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) ||        \
 | 
			
		||||
    defined(__NetBSD__) || (defined(__sun__) && defined(__svr4__)) ||          \
 | 
			
		||||
    defined(_WIN32) || defined(__Fuchsia__)
 | 
			
		||||
# define CAN_SANITIZE_UB 1
 | 
			
		||||
#else
 | 
			
		||||
# define CAN_SANITIZE_UB 0
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue