未验证 提交 e4eefcba 编写于 作者: U Ulrich Weigand 提交者: GitHub

Build support for s390x: libunwind (#53286)

* Merge https://github.com/libunwind/libunwind/pull/245

* Add s390x support to local CMake files
上级 5d6278a6
......@@ -28,6 +28,8 @@ if(CLR_CMAKE_HOST_UNIX)
set(arch arm)
elseif(CLR_CMAKE_HOST_ARCH_I386)
set(arch x86)
elseif(CLR_CMAKE_HOST_ARCH_S390X)
set(arch s390x)
endif ()
# Disable warning due to incorrect format specifier in debugging printf via the Debug macro
......@@ -105,6 +107,10 @@ if(CLR_CMAKE_HOST_WIN32)
set(TARGET_ARM 1)
set(arch arm)
add_definitions(-D__arm__)
elseif(CLR_CMAKE_TARGET_ARCH_S390X)
set(TARGET_S390X 1)
set(arch s390x)
add_definitions(-D__s390x__)
else ()
message(FATAL_ERROR "Unrecognized TARGET")
endif ()
......
......@@ -164,16 +164,16 @@ dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val)
if (DWARF_IS_NULL_LOC (loc))
return -UNW_EBADREG;
/* GPRs may be saved in FPRs */
if (DWARF_IS_FP_LOC (loc))
return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), (unw_fpreg_t*)val,
0, c->as_arg);
if (DWARF_IS_REG_LOC (loc))
return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val,
0, c->as_arg);
if (DWARF_IS_MEM_LOC (loc))
return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val,
0, c->as_arg);
/* GPRs may be saved in FPRs */
if (DWARF_IS_FP_LOC (loc))
return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), (unw_fpreg_t*)val,
0, c->as_arg);
assert(DWARF_IS_VAL_LOC (loc));
*val = DWARF_GET_LOC (loc);
return 0;
......@@ -188,13 +188,13 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val)
if (DWARF_IS_NULL_LOC (loc))
return -UNW_EBADREG;
if (DWARF_IS_REG_LOC (loc))
return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val,
1, c->as_arg);
/* GPRs may be saved in FPRs */
if (DWARF_IS_FP_LOC (loc))
return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), (unw_fpreg_t*) &val,
1, c->as_arg);
if (DWARF_IS_REG_LOC (loc))
return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val,
1, c->as_arg);
assert(DWARF_IS_MEM_LOC (loc));
return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val,
......
......@@ -15,6 +15,8 @@
# include "tdep-ppc32/dwarf-config.h"
#elif defined __powerpc64__
# include "tdep-ppc64/dwarf-config.h"
#elif defined __s390x__
# include "tdep-s390x/dwarf-config.h"
#elif defined __sh__
# include "tdep-sh/dwarf-config.h"
#elif defined __i386__
......
......@@ -4,3 +4,4 @@ https://github.com/libunwind/libunwind/commit/9165d2a150d707d3037c2045f2cdc0fabd
Remove upstream CMakelist.txt & src/CMakelist.txt, keep .NET Core custom version
Keep .NET Core oop directory
Apply https://github.com/libunwind/libunwind/pull/186
Apply https://github.com/libunwind/libunwind/pull/245
......@@ -276,6 +276,35 @@ SET(libunwind_x86_64_la_SOURCES_x86_64
x86_64/Gstash_frame.c x86_64/Gstep.c x86_64/Gtrace.c
)
# The list of files that go both into libunwind and libunwind-s390x:
SET(libunwind_la_SOURCES_s390x_common
${libunwind_la_SOURCES_common}
s390x/is_fpreg.c s390x/regname.c
)
# The list of files that go into libunwind:
SET(libunwind_la_SOURCES_s390x
${libunwind_la_SOURCES_s390x_common}
${libunwind_la_SOURCES_local}
s390x/setcontext.S s390x/getcontext.S
s390x/Lapply_reg_state.c s390x/Lreg_states_iterate.c
s390x/Lcreate_addr_space.c s390x/Lget_save_loc.c s390x/Lglobal.c
s390x/Linit.c s390x/Linit_local.c s390x/Linit_remote.c
s390x/Lget_proc_info.c s390x/Lregs.c s390x/Lresume.c
s390x/Lis_signal_frame.c s390x/Lstep.c
)
# The list of files that go into libunwind-s390x:
SET(libunwind_s390x_la_SOURCES_s390x
${libunwind_la_SOURCES_s390x_common}
${libunwind_la_SOURCES_generic}
s390x/Gapply_reg_state.c s390x/Greg_states_iterate.c
s390x/Gcreate_addr_space.c s390x/Gget_save_loc.c s390x/Gglobal.c
s390x/Ginit.c s390x/Ginit_local.c s390x/Ginit_remote.c
s390x/Gget_proc_info.c s390x/Gregs.c s390x/Gresume.c
s390x/Gis_signal_frame.c s390x/Gstep.c
)
if(CLR_CMAKE_HOST_UNIX)
if(CLR_CMAKE_HOST_ARCH_ARM64)
SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_aarch64})
......@@ -297,6 +326,10 @@ if(CLR_CMAKE_HOST_UNIX)
SET(libunwind_remote_la_SOURCES ${libunwind_x86_64_la_SOURCES_x86_64})
SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES})
list(APPEND libunwind_setjmp_la_SOURCES x86_64/longjmp.S x86_64/siglongjmp.SA)
elseif(CLR_CMAKE_HOST_ARCH_S390X)
SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_s390x})
SET(libunwind_remote_la_SOURCES ${libunwind_s390x_la_SOURCES_s390x})
SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES})
endif()
if(CLR_CMAKE_HOST_OSX)
......@@ -340,6 +373,10 @@ else(CLR_CMAKE_HOST_UNIX)
SET(libunwind_remote_la_SOURCES ${libunwind_x86_64_la_SOURCES_x86_64})
SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES})
list(APPEND libunwind_setjmp_la_SOURCES x86_64/longjmp.S x86_64/siglongjmp.SA)
elseif(CLR_CMAKE_TARGET_ARCH_S390X)
SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_s390x})
SET(libunwind_remote_la_SOURCES ${libunwind_s390x_la_SOURCES_s390x})
SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES})
endif()
set_source_files_properties(${CLR_DIR}/pal/src/exception/remote-unwind.cpp PROPERTIES COMPILE_FLAGS /TP INCLUDE_DIRECTORIES ${CLR_DIR}/inc)
......
......@@ -68,7 +68,7 @@ s390x_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg)
sp = c->sigcontext_sp;
ip = c->sigcontext_pc;
__asm__ __volatile__ (
"lgr 15, %[sp]\n"
"lgr %%r15, %[sp]\n"
"br %[ip]\n"
: : [sp] "r" (sp), [ip] "r" (ip)
);
......@@ -86,7 +86,7 @@ s390x_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg)
sp = c->sigcontext_sp;
ip = c->sigcontext_pc;
__asm__ __volatile__ (
"lgr 15, %[sp]\n"
"lgr %%r15, %[sp]\n"
"br %[ip]\n"
: : [sp] "r" (sp), [ip] "r" (ip)
);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册