This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [committed] Fix libsanitizer build against recent glibc (PR sanitizer/81066)
- From: Matthias Klose <doko at ubuntu dot com>
- To: Jakub Jelinek <jakub at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 7 Sep 2017 09:08:46 +0200
- Subject: Re: [committed] Fix libsanitizer build against recent glibc (PR sanitizer/81066)
- Authentication-results: sourceware.org; auth=none
- References: <20170714091416.GA2123@tucnak>
On 14.07.2017 11:14, Jakub Jelinek wrote:
> Hi!
>
> glibc recently changed a couple of headers. One change was
> that typedef struct sigaltstack { ... } stack_t; is now
> typedef struct { ... } stack_t;
> and the other change is that resolv.h now ignores the former (private glibc
> macro) __need_res_state macro and after
> struct __res_state { ... };
> typedef struct __res_state *res_state;
> also newly adds
> extern struct __res_state *__res_state(void) __attribute__ ((__const__));
> declaration even if that macro is defined.
>
> The following patch fixes both of these issues and should work even with
> older glibcs.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.
> Will backport to release branches soon.
This was backported to gcc-7 only. Ok to backport to the gcc-5 and gcc-6 branches?
Matthias
libsanitizer/
Backported from mainline
2017-07-14 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/81066
* sanitizer_common/sanitizer_linux.h: Cherry-pick upstream r307969.
* sanitizer_common/sanitizer_linux.cc: Likewise.
* sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc: Likewise.
* tsan/tsan_platform_linux.cc: Likewise.
Index: b/src/libsanitizer/sanitizer_common/sanitizer_linux.cc
===================================================================
--- a/src/libsanitizer/sanitizer_common/sanitizer_linux.cc
+++ b/src/libsanitizer/sanitizer_common/sanitizer_linux.cc
@@ -546,8 +546,7 @@ uptr internal_prctl(int option, uptr arg
}
#endif
-uptr internal_sigaltstack(const struct sigaltstack *ss,
- struct sigaltstack *oss) {
+uptr internal_sigaltstack(const void *ss, void *oss) {
return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss);
}
Index: b/src/libsanitizer/sanitizer_common/sanitizer_linux.h
===================================================================
--- a/src/libsanitizer/sanitizer_common/sanitizer_linux.h
+++ b/src/libsanitizer/sanitizer_common/sanitizer_linux.h
@@ -19,7 +19,6 @@
#include "sanitizer_platform_limits_posix.h"
struct link_map; // Opaque type returned by dlopen().
-struct sigaltstack;
namespace __sanitizer {
// Dirent structure for getdents(). Note that this structure is different from
@@ -28,8 +27,7 @@ struct linux_dirent;
// Syscall wrappers.
uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count);
-uptr internal_sigaltstack(const struct sigaltstack* ss,
- struct sigaltstack* oss);
+uptr internal_sigaltstack(const void* ss, void* oss);
uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
__sanitizer_sigset_t *oldset);
void internal_sigfillset(__sanitizer_sigset_t *set);
Index: b/src/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
===================================================================
--- a/src/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
+++ b/src/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
@@ -267,7 +267,7 @@ static int TracerThread(void* argument)
// Alternate stack for signal handling.
InternalScopedBuffer<char> handler_stack_memory(kHandlerStackSize);
- struct sigaltstack handler_stack;
+ stack_t handler_stack;
internal_memset(&handler_stack, 0, sizeof(handler_stack));
handler_stack.ss_sp = handler_stack_memory.data();
handler_stack.ss_size = kHandlerStackSize;
Index: b/src/libsanitizer/tsan/tsan_platform_linux.cc
===================================================================
--- a/src/libsanitizer/tsan/tsan_platform_linux.cc
+++ b/src/libsanitizer/tsan/tsan_platform_linux.cc
@@ -291,7 +291,7 @@ bool IsGlobalVar(uptr addr) {
int ExtractResolvFDs(void *state, int *fds, int nfd) {
#if SANITIZER_LINUX
int cnt = 0;
- __res_state *statp = (__res_state*)state;
+ struct __res_state *statp = (struct __res_state*)state;
for (int i = 0; i < MAXNS && cnt < nfd; i++) {
if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1)
fds[cnt++] = statp->_u._ext.nssocks[i];