Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 9b2659c

Browse files
authored
Fix remote unwind (#17351)
The change that removed dependency on the external libunwind has broken remote unwinding. I have not realized that the unw_create_addr_space and other remote unwinding functions are just dummies. This change adds the remote unwind related sources to the libunwind compilation, enables remote unwinding support in the remote-unwind.cpp and also does some magic in the CMakeLists.txt to fix issues caused by the fact that the local and remote unwinding code was not expected to be compiled into the same binary. There was one general and one arm related function whose names needed to be different for local and remote unwind code. And there was one function that was the same for both local and remote case and so I had to ensure that it gets compiled in just once. Fortunately, all of these could still be achieved without changing the libunwind sources.
1 parent 369bda2 commit 9b2659c

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/pal/src/exception/remote-unwind.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4848
#include "pal.h"
4949
#include <dlfcn.h>
5050

51-
#define UNW_LOCAL_ONLY
5251
// Sub-headers included from the libunwind.h contain an empty struct
5352
// and clang issues a warning. Until the libunwind is fixed, disable
5453
// the warning.

src/pal/src/libunwind/src/CMakeLists.txt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ add_definitions(-DPACKAGE_STRING="")
1616
add_definitions(-DPACKAGE_BUGREPORT="")
1717

1818
add_definitions(-D_GNU_SOURCE)
19+
# Ensure that the remote and local unwind code can reside in the same binary without name clashing
20+
add_definitions("-Ddwarf_search_unwind_table_int=UNW_OBJ(dwarf_search_unwind_table_int)")
1921

2022
add_compile_options(-Wno-header-guard)
2123

2224
if(CLR_CMAKE_PLATFORM_ARCH_ARM)
25+
# Ensure that the remote and local unwind code can reside in the same binary without name clashing
26+
add_definitions("-Darm_search_unwind_table=UNW_OBJ(arm_search_unwind_table)")
2327
# Disable warning in asm: use of SP or PC in the list is deprecated
2428
add_compile_options(-Wno-inline-asm)
2529
# Disable warning due to labs function called on unsigned argument
@@ -28,6 +32,8 @@ if(CLR_CMAKE_PLATFORM_ARCH_ARM)
2832
add_compile_options(-Wno-format)
2933
# Disable warning for a bug in the libunwind source src/arm/Gtrace.c:529, but not in code that we exercise
3034
add_compile_options(-Wno-implicit-function-declaration)
35+
# Disable warning due to an unused function prel31_read
36+
add_compile_options(-Wno-unused-function)
3137
# We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension
3238
add_definitions(-Dasm=__asm__)
3339
# The arm sources include ex_tables.h from include/tdep-arm without going through a redirection
@@ -75,7 +81,9 @@ SET(libunwind_coredump_la_SOURCES
7581
# List of arch-independent files needed by generic library (libunwind-$ARCH):
7682
SET(libunwind_la_SOURCES_generic
7783
mi/Gdyn-extract.c mi/Gdyn-remote.c mi/Gfind_dynamic_proc_info.c
78-
mi/Gget_accessors.c
84+
# The Gget_accessors.c implements the same function as Lget_accessors.c, so
85+
# the source is excluded here to prevent name clash
86+
#mi/Gget_accessors.c
7987
mi/Gget_proc_info_by_ip.c mi/Gget_proc_name.c
8088
mi/Gput_dynamic_unwind_info.c mi/Gdestroy_addr_space.c
8189
mi/Gget_reg.c mi/Gset_reg.c
@@ -307,31 +315,33 @@ SET(libunwind_x86_64_la_SOURCES_x86_64
307315

308316
if(CLR_CMAKE_PLATFORM_ARCH_ARM64)
309317
SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_aarch64})
310-
SET(libunwind_aarch64_la_SOURCES ${libunwind_aarch64_la_SOURCES_aarch64})
318+
SET(libunwind_remote_la_SOURCES ${libunwind_aarch64_la_SOURCES_aarch64})
311319
SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES})
312320
list(APPEND libunwind_setjmp_la_SOURCES aarch64/siglongjmp.S)
313321
elseif(CLR_CMAKE_PLATFORM_ARCH_ARM)
314322
SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_arm})
315-
SET(libunwind_arm_la_SOURCES ${libunwind_arm_la_SOURCES_arm})
323+
SET(libunwind_remote_la_SOURCES ${libunwind_arm_la_SOURCES_arm})
316324
SET(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES})
317325
list(APPEND libunwind_setjmp_la_SOURCES arm/siglongjmp.S)
318326
elseif(CLR_CMAKE_PLATFORM_ARCH_I386)
319327
SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_x86} ${libunwind_x86_la_SOURCES_os})
320-
SET(libunwind_x86_la_SOURCES ${libunwind_x86_la_SOURCES_x86})
328+
SET(libunwind_remote_la_SOURCES ${libunwind_x86_la_SOURCES_x86})
321329
SET(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES})
322330
list(APPEND libunwind_setjmp_la_SOURCES x86/longjmp.S x86/siglongjmp.S)
323331
elseif(CLR_CMAKE_PLATFORM_ARCH_AMD64)
324332
SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_x86_64})
325-
SET(libunwind_x86_64_la_SOURCES ${libunwind_x86_64_la_SOURCES_x86_64})
333+
SET(libunwind_remote_la_SOURCES ${libunwind_x86_64_la_SOURCES_x86_64})
326334
SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES})
327335
list(APPEND libunwind_setjmp_la_SOURCES x86_64/longjmp.S x86_64/siglongjmp.SA)
328336
endif()
329337

330338
add_library(libunwind
331339
OBJECT
332340
${libunwind_la_SOURCES}
341+
${libunwind_remote_la_SOURCES}
333342
${libunwind_dwarf_local_la_SOURCES}
334343
${libunwind_dwarf_common_la_SOURCES}
344+
${libunwind_dwarf_generic_la_SOURCES}
335345
${libunwind_elf_la_SOURCES}
336346
)
337347

0 commit comments

Comments
 (0)