From e605b9ba0a11d79b23bb94bce26fcc21f92aa332 Mon Sep 17 00:00:00 2001 From: Adeel Mujahid <3840695+am11@users.noreply.github.com> Date: Fri, 28 Apr 2023 02:49:19 +0300 Subject: [PATCH] Add better fix for UnhandledExceptionHandlerUnix --- src/coreclr/vm/exceptionhandling.cpp | 2 +- src/native/corehost/apphost/static/CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/coreclr/vm/exceptionhandling.cpp b/src/coreclr/vm/exceptionhandling.cpp index 0a4ca9cfa7883..02c7398a9c994 100644 --- a/src/coreclr/vm/exceptionhandling.cpp +++ b/src/coreclr/vm/exceptionhandling.cpp @@ -5857,7 +5857,7 @@ struct _Unwind_Exception; // This is a personality routine for TheUMEntryPrestub and UMThunkStub Unix asm stubs. // An exception propagating through these stubs is an unhandled exception. // This function dumps managed stack trace and terminates the current process. -EXTERN_C __attribute__((visibility("default"))) _Unwind_Reason_Code +EXTERN_C _Unwind_Reason_Code UnhandledExceptionHandlerUnix( IN int version, IN _Unwind_Action action, diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index cb77f959463cf..db5d751a3fc6f 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -227,6 +227,10 @@ if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive) endif(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) +if(CLR_CMAKE_TARGET_LINUX AND CLR_CMAKE_TARGET_ARCH_RISCV64) + add_linker_flag(-Wl,-z,notext) +endif() + if(CLR_CMAKE_TARGET_APPLE) # These options are used to force every object to be included even if it's unused. set(START_WHOLE_ARCHIVE -force_load)