From: Marc-André Lureau Date: Mon, 25 Sep 2023 11:36:04 +0000 (+0400) Subject: win32: avoid discarding the exception handler X-Git-Tag: v8.2.0-rc0~93^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=75b773d84c89220463a14a6883d2b2a8e49e5b68;p=thirdparty%2Fqemu.git win32: avoid discarding the exception handler In all likelihood, the compiler with lto doesn't see the function being used, from assembly macro __try1. Help it by marking the function has being used. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1904 Fixes: commit d89f30b4df ("win32: wrap socket close() with an exception handler") Signed-off-by: Marc-André Lureau Reviewed-by: Thomas Huth --- diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 7f1bbbf05f4..1109482a000 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -206,4 +206,10 @@ #define QEMU_ANNOTATE(x) #endif +#if __has_attribute(used) +# define QEMU_USED __attribute__((used)) +#else +# define QEMU_USED +#endif + #endif /* COMPILER_H */ diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 19a0ea7fbe6..55b0189dc30 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -479,7 +479,7 @@ int qemu_bind_wrap(int sockfd, const struct sockaddr *addr, return ret; } -EXCEPTION_DISPOSITION +QEMU_USED EXCEPTION_DISPOSITION win32_close_exception_handler(struct _EXCEPTION_RECORD *exception_record, void *registration, struct _CONTEXT *context, void *dispatcher)