Index: lib/interception/interception_linux.h =================================================================== --- lib/interception/interception_linux.h +++ lib/interception/interception_linux.h @@ -12,7 +12,7 @@ // Linux-specific interception methods. //===----------------------------------------------------------------------===// -#if defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) #if !defined(INCLUDED_FROM_INTERCEPTION_LIB) # error "interception_linux.h should be included from interception library only" @@ -44,4 +44,4 @@ #endif // !defined(__ANDROID__) #endif // INTERCEPTION_LINUX_H -#endif // __linux__ || __FreeBSD__ +#endif // __linux__ || __FreeBSD__ || __NetBSD__ Index: lib/interception/interception_linux.cc =================================================================== --- lib/interception/interception_linux.cc +++ lib/interception/interception_linux.cc @@ -12,14 +12,26 @@ // Linux-specific interception methods. //===----------------------------------------------------------------------===// -#if defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) #include "interception.h" #include // for dlsym() and dlvsym() +#ifdef __NetBSD__ +static int mystrcmp(const char *s1, const char *s2) { + while (*s1 == *s2++) + if (*s1++ == 0) return (0); + return (*(const unsigned char *)s1 - *(const unsigned char *)--s2); +} +#endif + namespace __interception { bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, uptr real, uptr wrapper) { +#ifdef __NetBSD__ + // XXX: Find a better way to handle renames + if (mystrcmp(func_name, "sigaction") == 0) func_name = "__sigaction14"; +#endif *func_addr = (uptr)dlsym(RTLD_NEXT, func_name); return real == wrapper; } @@ -32,5 +44,4 @@ } // namespace __interception - -#endif // __linux__ || __FreeBSD__ +#endif // __linux__ || __FreeBSD__ || __NetBSD__