From 5fc30c371cdabb1a4e941ad8dc0f8ac631696f04 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 6 Sep 2022 10:03:40 +0200 Subject: Revert "pkg/csource: inline void* cast into generated code" This reverts commit 922294abb4c0bc72b24d8526d625110d73fa1b5a. The commit reported to cause old warnings on s390x: https://github.com/google/syzkaller/commit/922294abb4c0bc72b24d8526d625110d73fa1b5a#commitcomment-83096994 --- executor/common_fuchsia.h | 4 ++++ executor/common_linux.h | 4 ++++ pkg/csource/csource.go | 2 +- pkg/csource/generated.go | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/executor/common_fuchsia.h b/executor/common_fuchsia.h index 19bdd280c..cb29f715e 100644 --- a/executor/common_fuchsia.h +++ b/executor/common_fuchsia.h @@ -272,3 +272,7 @@ static int do_sandbox_none(void) return 0; } #endif + +// Ugly way to work around gcc's "error: function called through a non-compatible type". +// The macro is used in generated C code. +#define CAST(f) ({void* p = (void*)f; p; }) diff --git a/executor/common_linux.h b/executor/common_linux.h index 0cc94555f..bf8db5502 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -4857,6 +4857,10 @@ static void setup_802154() #if GOARCH_s390x #include +// Ugly way to work around gcc's "error: function called through a non-compatible type". +// Simply casting via (void*) inline does not work b/c gcc sees through a chain of casts. +// The macro is used in generated C code. +#define CAST(f) ({void* p = (void*)f; p; }) #endif #if SYZ_EXECUTOR || __NR_syz_fuse_handle_req diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go index cec1d7847..8671a57db 100644 --- a/pkg/csource/csource.go +++ b/pkg/csource/csource.go @@ -343,7 +343,7 @@ func (ctx *context) emitCallBody(w *bytes.Buffer, call prog.ExecCall, native boo if args != "" { args = args[1:] } - fmt.Fprintf(w, "((intptr_t(*)(%v))(void*)(%v))(", args, callName) + fmt.Fprintf(w, "((intptr_t(*)(%v))CAST(%v))(", args, callName) } for ai, arg := range call.Args { if native || ai > 0 { diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go index 9e413e508..874c8d72d 100644 --- a/pkg/csource/generated.go +++ b/pkg/csource/generated.go @@ -2312,6 +2312,7 @@ static int do_sandbox_none(void) return 0; } #endif +#define CAST(f) ({void* p = (void*)f; p; }) #elif GOOS_linux @@ -10413,6 +10414,7 @@ static void setup_802154() #if GOARCH_s390x #include +#define CAST(f) ({void* p = (void*)f; p; }) #endif #if SYZ_EXECUTOR || __NR_syz_fuse_handle_req -- cgit mrf-deployment