Index: lib/sanitizer_common/sanitizer_platform_limits_posix.h =================================================================== --- lib/sanitizer_common/sanitizer_platform_limits_posix.h +++ lib/sanitizer_common/sanitizer_platform_limits_posix.h @@ -18,18 +18,32 @@ #include "sanitizer_internal_defs.h" #include "sanitizer_platform.h" +#define _GET_LINK_MAP_BY_DLOPEN_HANDLE(handle, shift) \ + ((link_map *)((handle) == nullptr ? nullptr : ((char *)(handle) + (shift)))) + +// FreeBSD's and NetBSD's dlopen() returns a pointer to an Obj_Entry structure +// that incorporates the map structure. #if SANITIZER_FREEBSD -// FreeBSD's dlopen() returns a pointer to an Obj_Entry structure that -// incorporates the map structure. -# define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \ - ((link_map*)((handle) == nullptr ? nullptr : ((char*)(handle) + 544))) -// Get sys/_types.h, because that tells us whether 64-bit inodes are -// used in struct dirent below. -#include +#define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \ + _GET_LINK_MAP_BY_DLOPEN_HANDLE(handle, 544) +#elif SANITIZER_NETBSD +#if defined(__x86_64__) +#define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \ + _GET_LINK_MAP_BY_DLOPEN_HANDLE(handle, 608) +#elif defined(__i386__) +#define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \ + _GET_LINK_MAP_BY_DLOPEN_HANDLE(handle, 324) +#endif #else # define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) ((link_map*)(handle)) #endif // !SANITIZER_FREEBSD +#if SANITIZER_FREEBSD +// Get sys/_types.h, because that tells us whether 64-bit inodes are +// used in struct dirent below. +#include +#endif + #ifndef __GLIBC_PREREQ #define __GLIBC_PREREQ(x, y) 0 #endif @@ -37,7 +51,7 @@ namespace __sanitizer { extern unsigned struct_utsname_sz; extern unsigned struct_stat_sz; -#if !SANITIZER_FREEBSD && !SANITIZER_IOS +#if !SANITIZER_FREEBSD && !SANITIZER_IOS && !SANITIZER_NETBSD extern unsigned struct_stat64_sz; #endif extern unsigned struct_rusage_sz; @@ -55,8 +69,13 @@ extern unsigned struct_itimerspec_sz; extern unsigned struct_sigevent_sz; extern unsigned struct_sched_param_sz; +#if !SANITIZER_NETBSD extern unsigned struct_statfs64_sz; +#endif +#if !SANITIZER_ANDROID && !SANITIZER_NETBSD + extern unsigned struct_statfs_sz; +#endif #if !SANITIZER_ANDROID extern unsigned struct_statfs_sz; extern unsigned struct_sockaddr_sz; @@ -127,12 +146,16 @@ #elif !defined(__sparc__) const unsigned struct___old_kernel_stat_sz = 32; #endif +#endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD extern unsigned struct_rlimit_sz; extern unsigned struct_utimbuf_sz; extern unsigned struct_timespec_sz; struct __sanitizer_iocb { +#if SANITIZER_LINUX || SANITIZER_FREEBSD u64 aio_data; u32 aio_key_or_aio_reserved1; // Simply crazy. u32 aio_reserved1_or_aio_key; // Luckily, we don't need these. @@ -144,19 +167,40 @@ s64 aio_offset; u64 aio_reserved2; u64 aio_reserved3; +#elif SANITIZER_NETBSD + u64 aio_offset; + uptr aio_buf; + long aio_nbytes; + u32 aio_fildes; + u32 aio_lio_opcode; + long aio_reqprio; +#if _LP64 + u8 aio_sigevent[32]; +#else + u8 aio_sigevent[20]; +#endif + u32 _state; + u32 _errno; + long _retval; +#endif }; +#endif +#if SANITIZER_LINUX || SANITIZER_FREEBSD struct __sanitizer_io_event { u64 data; u64 obj; u64 res; u64 res2; }; +#endif +#if SANITIZER_LINUX || SANITIZER_FREEBSD const unsigned iocb_cmd_pread = 0; const unsigned iocb_cmd_pwrite = 1; const unsigned iocb_cmd_preadv = 7; const unsigned iocb_cmd_pwritev = 8; +#endif struct __sanitizer___sysctl_args { int *name; @@ -165,11 +209,16 @@ uptr *oldlenp; void *newval; uptr newlen; +#if SANITIZER_LINUX || SANITIZER_FREEBSD unsigned long ___unused[4]; +#endif }; +#if SANITIZER_LINUX || SANITIZER_FREEBSD const unsigned old_sigset_t_sz = sizeof(unsigned long); +#endif +#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD struct __sanitizer_sem_t { #if SANITIZER_ANDROID && defined(_LP64) int data[4]; @@ -179,9 +228,11 @@ uptr data[4]; #elif SANITIZER_FREEBSD u32 data[4]; +#elif SANITIZER_NETBSD + uptr data[5]; #endif }; -#endif // SANITIZER_LINUX || SANITIZER_FREEBSD +#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD #if SANITIZER_ANDROID struct __sanitizer_mallinfo { @@ -324,14 +375,39 @@ unsigned long shm_dtime; unsigned long shm_ctime; }; + +#elif SANITIZER_NETBSD + struct __sanitizer_ipc_perm { + u32 uid; + u32 gid; + u32 cuid; + u32 cgid; + u32 mode; + unsigned short _seq; + long _key; + }; + + struct __sanitizer_shmid_ds { + __sanitizer_ipc_perm shm_perm; + unsigned long shm_segsz; + u32 shm_lpid; + u32 shm_cpid; + unsigned int shm_nattch; + u64 shm_atime; + u64 shm_dtime; + u64 shm_ctime; + void *_shm_internal; + }; #endif -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID +#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \ + !SANITIZER_ANDROID extern unsigned struct_msqid_ds_sz; extern unsigned struct_mq_attr_sz; extern unsigned struct_timex_sz; extern unsigned struct_statvfs_sz; -#endif // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID +#endif // (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && + // !SANITIZER_ANDROID struct __sanitizer_iovec { void *iov_base; @@ -351,6 +427,9 @@ # endif void *ifa_dstaddr; // (struct sockaddr *) void *ifa_data; +#if SANITIZER_NETBSD + unsigned int ifa_addrflags; +#endif }; #endif // !SANITIZER_ANDROID @@ -376,13 +455,19 @@ const int __sanitizer_XDR_FREE = 2; #endif +#if SANITIZER_NETBSD || (defined(__x86_64__) && !defined(_LP64)) + typedef long long __sanitizer_time_t; +#else + typedef long __sanitizer_time_t; +#endif + struct __sanitizer_passwd { char *pw_name; char *pw_passwd; int pw_uid; int pw_gid; -#if SANITIZER_MAC || SANITIZER_FREEBSD - long pw_change; +#if SANITIZER_MAC || SANITIZER_FREEBSD || SANITIZER_NETBSD + __sanitizer_time_t pw_change; char *pw_class; #endif #if !(SANITIZER_ANDROID && (SANITIZER_WORDSIZE == 32)) @@ -390,8 +475,8 @@ #endif char *pw_dir; char *pw_shell; -#if SANITIZER_MAC || SANITIZER_FREEBSD - long pw_expire; +#if SANITIZER_MAC || SANITIZER_FREEBSD || SANITIZER_NETBSD + __sanitizer_time_t pw_expire; #endif #if SANITIZER_FREEBSD int pw_fields; @@ -405,12 +490,6 @@ char **gr_mem; }; -#if defined(__x86_64__) && !defined(_LP64) - typedef long long __sanitizer_time_t; -#else - typedef long __sanitizer_time_t; -#endif - struct __sanitizer_timeb { __sanitizer_time_t time; unsigned short millitm; @@ -447,7 +526,7 @@ }; #endif -#if SANITIZER_MAC || SANITIZER_FREEBSD +#if SANITIZER_MAC || SANITIZER_FREEBSD || SANITIZER_NETBSD struct __sanitizer_msghdr { void *msg_name; unsigned msg_namelen; @@ -497,6 +576,12 @@ unsigned short d_reclen; // more fields that we don't care about }; +#elif SANITIZER_NETBSD + struct __sanitizer_dirent { + u64 d_fileno; + u16 d_reclen; + // more fields that we don't care about + }; #elif SANITIZER_ANDROID || defined(__x86_64__) struct __sanitizer_dirent { unsigned long long d_ino; @@ -522,8 +607,7 @@ }; #endif -// 'clock_t' is 32 bits wide on x64 FreeBSD -#if SANITIZER_FREEBSD +#if SANITIZER_FREEBSD || SANITIZER_NETBSD typedef int __sanitizer_clock_t; #elif defined(__x86_64__) && !defined(_LP64) typedef long long __sanitizer_clock_t; @@ -531,7 +615,7 @@ typedef long __sanitizer_clock_t; #endif -#if SANITIZER_LINUX +#if SANITIZER_LINUX || SANITIZER_NETBSD typedef int __sanitizer_clockid_t; #endif @@ -562,8 +646,22 @@ typedef struct { unsigned long fds_bits[1024 / (8 * sizeof(long))]; } __sanitizer___kernel_fd_set; +#elif SANITIZER_NETBSD + typedef u32 __sanitizer___kernel_uid_t; + typedef u32 __sanitizer___kernel_gid_t; + typedef u64 __sanitizer___kernel_off_t; + typedef struct { + u32 fds_bits[8]; + } __sanitizer___kernel_fd_set; #endif +#if SANITIZER_NETBSD + typedef struct { + unsigned int pta_magic; + int pta_flags; + void *pta_private; + } __sanitizer_pthread_attr_t; +#else // This thing depends on the platform. We are only interested in the upper // limit. Verified with a compiler assert in .cc. const int pthread_attr_t_max_sz = 128; @@ -571,6 +669,7 @@ char size[pthread_attr_t_max_sz]; // NOLINT void *align; }; +#endif #if SANITIZER_ANDROID # if SANITIZER_MIPS @@ -585,7 +684,7 @@ // The size is determined by looking at sizeof of real sigset_t on linux. uptr val[128 / sizeof(uptr)]; }; -#elif SANITIZER_FREEBSD +#elif SANITIZER_FREEBSD || SANITIZER_NETBSD struct __sanitizer_sigset_t { // uint32_t * 4 unsigned int __bits[4]; @@ -622,7 +721,16 @@ uptr sa_flags; void (*sa_restorer)(); }; -#else // !SANITIZER_ANDROID +#elif SANITIZER_NETBSD + struct __sanitizer_sigaction { + union { + void (*handler)(int sig); + void (*sigaction)(int sig, void *siginfo, void *uctx); + }; + __sanitizer_sigset_t sa_mask; + int sa_flags; + }; +#else struct __sanitizer_sigaction { #if defined(__mips__) && !SANITIZER_FREEBSD unsigned int sa_flags; @@ -670,7 +778,7 @@ }; #endif // !SANITIZER_ANDROID -#if SANITIZER_FREEBSD +#if SANITIZER_FREEBSD || SANITIZER_NETBSD typedef __sanitizer_sigset_t __sanitizer_kernel_sigset_t; #elif defined(__mips__) struct __sanitizer_kernel_sigset_t { @@ -717,7 +825,7 @@ extern int af_inet6; uptr __sanitizer_in_addr_sz(int af); -#if SANITIZER_LINUX || SANITIZER_FREEBSD +#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD struct __sanitizer_dl_phdr_info { uptr dlpi_addr; const char *dlpi_name; @@ -733,7 +841,7 @@ int ai_family; int ai_socktype; int ai_protocol; -#if SANITIZER_ANDROID || SANITIZER_MAC || SANITIZER_FREEBSD +#if SANITIZER_ANDROID || SANITIZER_MAC || SANITIZER_FREEBSD || SANITIZER_NETBSD unsigned ai_addrlen; char *ai_canonname; void *ai_addr; @@ -759,7 +867,7 @@ short revents; }; -#if SANITIZER_ANDROID || SANITIZER_MAC || SANITIZER_FREEBSD +#if SANITIZER_ANDROID || SANITIZER_MAC || SANITIZER_FREEBSD || SANITIZER_NETBSD typedef unsigned __sanitizer_nfds_t; #else typedef unsigned long __sanitizer_nfds_t; @@ -779,7 +887,7 @@ int (*gl_lstat)(const char *, void *); int (*gl_stat)(const char *, void *); }; -# elif SANITIZER_FREEBSD +#elif SANITIZER_FREEBSD || SANITIZER_NETBSD struct __sanitizer_glob_t { uptr gl_pathc; uptr gl_matchc; @@ -793,9 +901,9 @@ int (*gl_lstat)(const char*, void* /* struct stat* */); int (*gl_stat)(const char*, void* /* struct stat* */); }; -# endif // SANITIZER_FREEBSD +#endif // SANITIZER_FREEBSD || SANITIZER_NETBSD -# if SANITIZER_LINUX || SANITIZER_FREEBSD +#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD extern int glob_nomatch; extern int glob_altdirfunc; # endif @@ -807,7 +915,7 @@ uptr we_wordc; char **we_wordv; uptr we_offs; -#if SANITIZER_FREEBSD +#if SANITIZER_FREEBSD || SANITIZER_NETBSD char *we_strings; uptr we_nbytes; #endif @@ -864,7 +972,8 @@ extern int ptrace_geteventmsg; #endif -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID +#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \ + !SANITIZER_ANDROID extern unsigned struct_shminfo_sz; extern unsigned struct_shm_info_sz; extern int shmctl_ipc_stat; @@ -967,38 +1076,41 @@ #define IOC_SIZE(nr) (((nr) >> IOC_SIZESHIFT) & IOC_SIZEMASK) #endif - extern unsigned struct_ifreq_sz; - extern unsigned struct_termios_sz; - extern unsigned struct_winsize_sz; +extern unsigned struct_ifreq_sz; +extern unsigned struct_termios_sz; +extern unsigned struct_winsize_sz; + +#if SANITIZER_LINUX || SANITIZER_NETBSD +extern unsigned struct_arpreq_sz; +#endif #if SANITIZER_LINUX - extern unsigned struct_arpreq_sz; - extern unsigned struct_cdrom_msf_sz; - extern unsigned struct_cdrom_multisession_sz; - extern unsigned struct_cdrom_read_audio_sz; - extern unsigned struct_cdrom_subchnl_sz; - extern unsigned struct_cdrom_ti_sz; - extern unsigned struct_cdrom_tocentry_sz; - extern unsigned struct_cdrom_tochdr_sz; - extern unsigned struct_cdrom_volctrl_sz; - extern unsigned struct_ff_effect_sz; - extern unsigned struct_floppy_drive_params_sz; - extern unsigned struct_floppy_drive_struct_sz; - extern unsigned struct_floppy_fdc_state_sz; - extern unsigned struct_floppy_max_errors_sz; - extern unsigned struct_floppy_raw_cmd_sz; - extern unsigned struct_floppy_struct_sz; - extern unsigned struct_floppy_write_errors_sz; - extern unsigned struct_format_descr_sz; - extern unsigned struct_hd_driveid_sz; - extern unsigned struct_hd_geometry_sz; - extern unsigned struct_input_absinfo_sz; - extern unsigned struct_input_id_sz; - extern unsigned struct_mtpos_sz; - extern unsigned struct_termio_sz; - extern unsigned struct_vt_consize_sz; - extern unsigned struct_vt_sizes_sz; - extern unsigned struct_vt_stat_sz; +extern unsigned struct_cdrom_msf_sz; +extern unsigned struct_cdrom_multisession_sz; +extern unsigned struct_cdrom_read_audio_sz; +extern unsigned struct_cdrom_subchnl_sz; +extern unsigned struct_cdrom_ti_sz; +extern unsigned struct_cdrom_tocentry_sz; +extern unsigned struct_cdrom_tochdr_sz; +extern unsigned struct_cdrom_volctrl_sz; +extern unsigned struct_ff_effect_sz; +extern unsigned struct_floppy_drive_params_sz; +extern unsigned struct_floppy_drive_struct_sz; +extern unsigned struct_floppy_fdc_state_sz; +extern unsigned struct_floppy_max_errors_sz; +extern unsigned struct_floppy_raw_cmd_sz; +extern unsigned struct_floppy_struct_sz; +extern unsigned struct_floppy_write_errors_sz; +extern unsigned struct_format_descr_sz; +extern unsigned struct_hd_driveid_sz; +extern unsigned struct_hd_geometry_sz; +extern unsigned struct_input_absinfo_sz; +extern unsigned struct_input_id_sz; +extern unsigned struct_mtpos_sz; +extern unsigned struct_termio_sz; +extern unsigned struct_vt_consize_sz; +extern unsigned struct_vt_sizes_sz; +extern unsigned struct_vt_stat_sz; #endif // SANITIZER_LINUX #if SANITIZER_LINUX || SANITIZER_FREEBSD @@ -1006,6 +1118,9 @@ extern unsigned struct_copr_debug_buf_sz; extern unsigned struct_copr_msg_sz; extern unsigned struct_midi_info_sz; +#endif + +#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD extern unsigned struct_mtget_sz; extern unsigned struct_mtop_sz; extern unsigned struct_rtentry_sz; @@ -1013,7 +1128,7 @@ extern unsigned struct_seq_event_rec_sz; extern unsigned struct_synth_info_sz; extern unsigned struct_vt_mode_sz; -#endif // SANITIZER_LINUX || SANITIZER_FREEBSD +#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD #if SANITIZER_LINUX && !SANITIZER_ANDROID extern unsigned struct_ax25_parms_struct_sz; @@ -1035,10 +1150,12 @@ extern unsigned struct_unimapinit_sz; #endif // SANITIZER_LINUX && !SANITIZER_ANDROID -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID +#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \ + !SANITIZER_ANDROID extern unsigned struct_audio_buf_info_sz; extern unsigned struct_ppp_stats_sz; -#endif // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID +#endif // (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && + // !SANITIZER_ANDROID #if !SANITIZER_ANDROID && !SANITIZER_MAC extern unsigned struct_sioc_sg_req_sz; @@ -1095,7 +1212,8 @@ extern unsigned IOCTL_TIOCSPGRP; extern unsigned IOCTL_TIOCSTI; extern unsigned IOCTL_TIOCSWINSZ; -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID +#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \ + !SANITIZER_ANDROID extern unsigned IOCTL_SIOCGETSGCNT; extern unsigned IOCTL_SIOCGETVIFCNT; #endif @@ -1258,7 +1376,7 @@ extern unsigned IOCTL_VT_RESIZEX; extern unsigned IOCTL_VT_SENDSIG; #endif // SANITIZER_LINUX -#if SANITIZER_LINUX || SANITIZER_FREEBSD +#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD extern unsigned IOCTL_MTIOCGET; extern unsigned IOCTL_MTIOCTOP; extern unsigned IOCTL_SIOCADDRT; @@ -1359,7 +1477,7 @@ extern unsigned IOCTL_VT_RELDISP; extern unsigned IOCTL_VT_SETMODE; extern unsigned IOCTL_VT_WAITACTIVE; -#endif // SANITIZER_LINUX || SANITIZER_FREEBSD +#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD #if SANITIZER_LINUX && !SANITIZER_ANDROID extern unsigned IOCTL_CYGETDEFTHRESH; @@ -1448,21 +1566,28 @@ extern unsigned IOCTL_TIOCSSERIAL; #endif // SANITIZER_LINUX && !SANITIZER_ANDROID -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID +#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \ + !SANITIZER_ANDROID +#if !SANITIZER_NETBSD extern unsigned IOCTL_GIO_SCRNMAP; +#endif extern unsigned IOCTL_KDDISABIO; extern unsigned IOCTL_KDENABIO; extern unsigned IOCTL_KDGETLED; +#if !SANITIZER_NETBSD extern unsigned IOCTL_KDGETMODE; +#endif extern unsigned IOCTL_KDGKBMODE; extern unsigned IOCTL_KDGKBTYPE; extern unsigned IOCTL_KDMKTONE; extern unsigned IOCTL_KDSETLED; extern unsigned IOCTL_KDSETMODE; extern unsigned IOCTL_KDSKBMODE; +#if !SANITIZER_NETBSD extern unsigned IOCTL_KIOCSOUND; extern unsigned IOCTL_PIO_SCRNMAP; #endif +#endif extern const int si_SEGV_MAPERR; extern const int si_SEGV_ACCERR; Index: lib/sanitizer_common/sanitizer_platform_limits_posix.cc =================================================================== --- lib/sanitizer_common/sanitizer_platform_limits_posix.cc +++ lib/sanitizer_common/sanitizer_platform_limits_posix.cc @@ -14,7 +14,7 @@ #include "sanitizer_platform.h" -#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC +#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_NETBSD // Tests in this file assume that off_t-dependent data structures match the // libc ABI. For example, struct dirent here is what readdir() function (as // exported from libc) returns, and not the user-facing "dirent", which @@ -78,7 +78,7 @@ #include #endif -#if SANITIZER_FREEBSD +#if SANITIZER_FREEBSD || SANITIZER_NETBSD # include # include # include @@ -93,16 +93,18 @@ # include # include # include -# include -# include -# include # include # include -# include # include # include # include +#endif +#if SANITIZER_FREEBSD +#include +#include +#include +#include #define _KERNEL // to declare 'shminfo' structure # include #undef _KERNEL @@ -110,11 +112,19 @@ #undef INLINE // to avoid clashes with sanitizers' definitions #endif -#if SANITIZER_FREEBSD || SANITIZER_IOS +#if SANITIZER_NETBSD +#include +#include +#include +#define statfs statvfs +#define d_ino d_fileno +#endif + +#if SANITIZER_FREEBSD || SANITIZER_IOS || SANITIZER_NETBSD #undef IOC_DIRMASK #endif -#if SANITIZER_LINUX || SANITIZER_FREEBSD +#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD # include # include # if defined(__mips64) || defined(__aarch64__) || defined(__arm__) @@ -199,9 +209,9 @@ namespace __sanitizer { unsigned struct_utsname_sz = sizeof(struct utsname); unsigned struct_stat_sz = sizeof(struct stat); -#if !SANITIZER_IOS && !SANITIZER_FREEBSD +#if !SANITIZER_IOS && !SANITIZER_FREEBSD && !SANITIZER_NETBSD unsigned struct_stat64_sz = sizeof(struct stat64); -#endif // !SANITIZER_IOS && !SANITIZER_FREEBSD +#endif // !SANITIZER_IOS && !SANITIZER_FREEBSD && !SANITIZER_NETBSD unsigned struct_rusage_sz = sizeof(struct rusage); unsigned struct_tm_sz = sizeof(struct tm); unsigned struct_passwd_sz = sizeof(struct passwd); @@ -244,12 +254,12 @@ unsigned struct_oldold_utsname_sz = sizeof(struct oldold_utsname); #endif // SANITIZER_LINUX -#if SANITIZER_LINUX || SANITIZER_FREEBSD +#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD unsigned struct_rlimit_sz = sizeof(struct rlimit); unsigned struct_timespec_sz = sizeof(struct timespec); unsigned struct_utimbuf_sz = sizeof(struct utimbuf); unsigned struct_itimerspec_sz = sizeof(struct itimerspec); -#endif // SANITIZER_LINUX || SANITIZER_FREEBSD +#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD #if SANITIZER_LINUX && !SANITIZER_ANDROID unsigned struct_ustat_sz = sizeof(struct ustat); @@ -257,12 +267,14 @@ unsigned struct_statvfs64_sz = sizeof(struct statvfs64); #endif // SANITIZER_LINUX && !SANITIZER_ANDROID -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID +#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \ + !SANITIZER_ANDROID unsigned struct_timex_sz = sizeof(struct timex); unsigned struct_msqid_ds_sz = sizeof(struct msqid_ds); unsigned struct_mq_attr_sz = sizeof(struct mq_attr); unsigned struct_statvfs_sz = sizeof(struct statvfs); -#endif // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID +#endif // (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && + // !SANITIZER_ANDROID uptr sig_ign = (uptr)SIG_IGN; uptr sig_dfl = (uptr)SIG_DFL; @@ -272,10 +284,17 @@ int e_tabsz = (int)E_TABSZ; #endif - -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID +#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \ + !SANITIZER_ANDROID unsigned struct_shminfo_sz = sizeof(struct shminfo); +#if !SANITIZER_NETBSD unsigned struct_shm_info_sz = sizeof(struct shm_info); +#else +#define IPC_INFO -1 +#define SHM_INFO -1 +#define SHM_STAT -1 + unsigned struct_shm_info_sz = -1; +#endif int shmctl_ipc_stat = (int)IPC_STAT; int shmctl_ipc_info = (int)IPC_INFO; int shmctl_shm_info = (int)SHM_INFO; @@ -309,9 +328,10 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); #endif -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID - int glob_nomatch = GLOB_NOMATCH; - int glob_altdirfunc = GLOB_ALTDIRFUNC; +#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \ + !SANITIZER_ANDROID +int glob_nomatch = GLOB_NOMATCH; +int glob_altdirfunc = GLOB_ALTDIRFUNC; #endif #if SANITIZER_LINUX && !SANITIZER_ANDROID && \ @@ -451,7 +471,7 @@ unsigned struct_seq_event_rec_sz = sizeof(struct seq_event_rec); unsigned struct_synth_info_sz = sizeof(struct synth_info); unsigned struct_vt_mode_sz = sizeof(struct vt_mode); -#endif // SANITIZER_LINUX || SANITIZER_FREEBSD +#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD #if SANITIZER_LINUX && !SANITIZER_ANDROID unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); @@ -478,7 +498,8 @@ unsigned struct_unimapinit_sz = sizeof(struct unimapinit); #endif // SANITIZER_LINUX && !SANITIZER_ANDROID -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID +#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \ + !SANITIZER_ANDROID unsigned struct_audio_buf_info_sz = sizeof(struct audio_buf_info); unsigned struct_ppp_stats_sz = sizeof(struct ppp_stats); #endif // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID @@ -534,7 +555,8 @@ unsigned IOCTL_TIOCSPGRP = TIOCSPGRP; unsigned IOCTL_TIOCSTI = TIOCSTI; unsigned IOCTL_TIOCSWINSZ = TIOCSWINSZ; -#if ((SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID) +#if ((SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \ + !SANITIZER_ANDROID) unsigned IOCTL_SIOCGETSGCNT = SIOCGETSGCNT; unsigned IOCTL_SIOCGETVIFCNT = SIOCGETVIFCNT; #endif @@ -966,7 +988,7 @@ COMPILER_CHECK(IOC_TYPE(0x12345678) == _IOC_TYPE(0x12345678)); #endif // SANITIZER_LINUX -#if SANITIZER_LINUX || SANITIZER_FREEBSD +#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD // There are more undocumented fields in dl_phdr_info that we are not interested // in. COMPILER_CHECK(sizeof(__sanitizer_dl_phdr_info) <= sizeof(dl_phdr_info)); @@ -974,9 +996,10 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_name); CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); -#endif // SANITIZER_LINUX || SANITIZER_FREEBSD +#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID +#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \ + !SANITIZER_ANDROID CHECK_TYPE_SIZE(glob_t); CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); @@ -1028,7 +1051,7 @@ CHECK_SIZE_AND_OFFSET(dirent, d_ino); #if SANITIZER_MAC CHECK_SIZE_AND_OFFSET(dirent, d_seekoff); -#elif SANITIZER_FREEBSD +#elif SANITIZER_FREEBSD || SANITIZER_NETBSD // There is no 'd_off' field on FreeBSD. #else CHECK_SIZE_AND_OFFSET(dirent, d_off); @@ -1125,11 +1148,15 @@ CHECK_TYPE_SIZE(ether_addr); -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID +#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \ + !SANITIZER_ANDROID CHECK_TYPE_SIZE(ipc_perm); # if SANITIZER_FREEBSD CHECK_SIZE_AND_OFFSET(ipc_perm, key); CHECK_SIZE_AND_OFFSET(ipc_perm, seq); +#elif SANITIZER_NETBSD +CHECK_SIZE_AND_OFFSET(ipc_perm, _key); +CHECK_SIZE_AND_OFFSET(ipc_perm, _seq); # else CHECK_SIZE_AND_OFFSET(ipc_perm, __key); CHECK_SIZE_AND_OFFSET(ipc_perm, __seq); @@ -1166,20 +1193,20 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_name); CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_addr); CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_netmask); -#if SANITIZER_LINUX || SANITIZER_FREEBSD +#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD // Compare against the union, because we can't reach into the union in a // compliant way. #ifdef ifa_dstaddr #undef ifa_dstaddr #endif -# if SANITIZER_FREEBSD +#if SANITIZER_FREEBSD || SANITIZER_NETBSD CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); # else COMPILER_CHECK(sizeof(((__sanitizer_ifaddrs *)nullptr)->ifa_dstaddr) == sizeof(((ifaddrs *)nullptr)->ifa_ifu)); COMPILER_CHECK(offsetof(__sanitizer_ifaddrs, ifa_dstaddr) == offsetof(ifaddrs, ifa_ifu)); -# endif // SANITIZER_FREEBSD +#endif // SANITIZER_FREEBSD || SANITIZER_NETBSD #else CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); #endif // SANITIZER_LINUX @@ -1280,4 +1307,5 @@ COMPILER_CHECK(ARM_VFPREGS_SIZE == ARM_VFPREGS_SIZE_ASAN); #endif -#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC +#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC || + // SANITIZER_NETBSD