Skip to content

Commit 5610f6f

Browse files
committed
Reapply upstream patches
1 parent 555322a commit 5610f6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2240
-91
lines changed

src/native/external/libunwind.cmake

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ set(libunwind_elfxx_la_SOURCES
156156
)
157157

158158
# The list of files that go into libunwind and libunwind-loongarch64:
159-
SET(libunwind_la_SOURCES_loongarch_common
159+
set(libunwind_la_SOURCES_loongarch_common
160160
${libunwind_la_SOURCES_common}
161161
loongarch64/is_fpreg.c
162162
loongarch64/regname.c
163163
)
164164

165165
# The list of files that go into libunwind:
166-
SET(libunwind_la_SOURCES_loongarch
166+
set(libunwind_la_SOURCES_loongarch
167167
${libunwind_la_SOURCES_loongarch_common}
168168
${libunwind_la_SOURCES_local}
169169
loongarch64/Lget_proc_info.c loongarch64/Linit.c loongarch64/Lis_signal_frame.c
@@ -174,7 +174,7 @@ SET(libunwind_la_SOURCES_loongarch
174174
loongarch64/Lcreate_addr_space.c loongarch64/Lglobal.c loongarch64/Linit_remote.c loongarch64/Lresume.c
175175
)
176176

177-
SET(libunwind_loongarch_la_SOURCES_loongarch
177+
set(libunwind_loongarch_la_SOURCES_loongarch
178178
${libunwind_la_SOURCES_loongarch_common}
179179
${libunwind_la_SOURCES_generic}
180180
loongarch64/Gcreate_addr_space.c loongarch64/Gget_proc_info.c loongarch64/Gget_save_loc.c
@@ -346,9 +346,9 @@ if(CLR_CMAKE_HOST_UNIX)
346346
set(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES})
347347
list(APPEND libunwind_setjmp_la_SOURCES arm/siglongjmp.S)
348348
elseif(CLR_CMAKE_HOST_ARCH_ARMV6)
349-
SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_arm})
350-
SET(libunwind_remote_la_SOURCES ${libunwind_arm_la_SOURCES_arm})
351-
SET(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES})
349+
set(libunwind_la_SOURCES ${libunwind_la_SOURCES_arm})
350+
set(libunwind_remote_la_SOURCES ${libunwind_arm_la_SOURCES_arm})
351+
set(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES})
352352
list(APPEND libunwind_setjmp_la_SOURCES arm/siglongjmp.S)
353353
elseif(CLR_CMAKE_HOST_ARCH_I386)
354354
set(libunwind_la_SOURCES ${libunwind_la_SOURCES_x86} ${libunwind_x86_la_SOURCES_os})
@@ -361,13 +361,13 @@ if(CLR_CMAKE_HOST_UNIX)
361361
set(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES})
362362
list(APPEND libunwind_setjmp_la_SOURCES x86_64/longjmp.S x86_64/siglongjmp.SA)
363363
elseif(CLR_CMAKE_HOST_ARCH_S390X)
364-
SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_s390x})
365-
SET(libunwind_remote_la_SOURCES ${libunwind_s390x_la_SOURCES_s390x})
366-
SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES})
364+
set(libunwind_la_SOURCES ${libunwind_la_SOURCES_s390x})
365+
set(libunwind_remote_la_SOURCES ${libunwind_s390x_la_SOURCES_s390x})
366+
set(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES})
367367
elseif(CLR_CMAKE_HOST_ARCH_LOONGARCH64)
368-
SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_loongarch})
369-
SET(libunwind_remote_la_SOURCES ${libunwind_loongarch_la_SOURCES_loongarch})
370-
SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES})
368+
set(libunwind_la_SOURCES ${libunwind_la_SOURCES_loongarch})
369+
set(libunwind_remote_la_SOURCES ${libunwind_loongarch_la_SOURCES_loongarch})
370+
set(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES})
371371
list(APPEND libunwind_setjmp_la_SOURCES loongarch64/siglongjmp.S)
372372
endif()
373373

@@ -400,9 +400,9 @@ else(CLR_CMAKE_HOST_UNIX)
400400
set(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES})
401401
list(APPEND libunwind_setjmp_la_SOURCES arm/siglongjmp.S)
402402
elseif(CLR_CMAKE_TARGET_ARCH_ARMV6)
403-
SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_arm})
404-
SET(libunwind_remote_la_SOURCES ${libunwind_arm_la_SOURCES_arm})
405-
SET(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES})
403+
set(libunwind_la_SOURCES ${libunwind_la_SOURCES_arm})
404+
set(libunwind_remote_la_SOURCES ${libunwind_arm_la_SOURCES_arm})
405+
set(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES})
406406
list(APPEND libunwind_setjmp_la_SOURCES arm/siglongjmp.S)
407407
elseif(CLR_CMAKE_TARGET_ARCH_I386)
408408
set(libunwind_la_SOURCES ${libunwind_la_SOURCES_x86} ${libunwind_x86_la_SOURCES_os})

src/native/external/libunwind/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ elseif ('$ENV{TARGET}' STREQUAL 's390x-linux-gnu')
3030
set(arch s390x)
3131
add_definitions(-D__s390x__)
3232
add_definitions(-D__linux__)
33+
elseif ('$ENV{TARGET}' STREQUAL 'loongarch64-linux-gnu')
34+
set(TARGET_LOONGARCH64 1)
35+
set(arch loongarch64)
36+
add_definitions(-D__loongarch64)
37+
add_definitions(-D__linux__)
3338
else ()
3439
message(FATAL_ERROR "Unrecognize value in environment variable TARGET")
3540
endif ()

src/native/external/libunwind/configure.cmake

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/* libunwind - a platform-independent unwind library
2+
Copyright (C) 2001-2004 Hewlett-Packard Co
3+
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
4+
Copyright (C) 2021 Loongson Technology Corporation Limited
5+
6+
This file is part of libunwind.
7+
8+
Permission is hereby granted, free of charge, to any person obtaining
9+
a copy of this software and associated documentation files (the
10+
"Software"), to deal in the Software without restriction, including
11+
without limitation the rights to use, copy, modify, merge, publish,
12+
distribute, sublicense, and/or sell copies of the Software, and to
13+
permit persons to whom the Software is furnished to do so, subject to
14+
the following conditions:
15+
16+
The above copyright notice and this permission notice shall be
17+
included in all copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
26+
27+
#ifndef LIBUNWIND_H
28+
#define LIBUNWIND_H
29+
30+
#if defined(__cplusplus) || defined(c_plusplus)
31+
extern "C" {
32+
#endif
33+
34+
#include <inttypes.h>
35+
#include <ucontext.h>
36+
37+
#define UNW_TARGET loongarch64
38+
#define UNW_TARGET_LOONGARCH64 1
39+
40+
#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */
41+
42+
/* This needs to be big enough to accommodate "struct cursor", while
43+
leaving some slack for future expansion. Changing this value will
44+
require recompiling all users of this library. Stack allocation is
45+
relatively cheap and unwind-state copying is relatively rare, so we
46+
want to err on making it rather too big than too small. */
47+
48+
/* FIXME for LoongArch64. Too big? What do other things use for similar tasks? */
49+
#define UNW_TDEP_CURSOR_LEN 4096
50+
51+
typedef uint64_t unw_word_t;
52+
typedef int64_t unw_sword_t;
53+
54+
typedef long double unw_tdep_fpreg_t;
55+
56+
typedef enum
57+
{
58+
UNW_LOONGARCH64_R0,
59+
UNW_LOONGARCH64_R1,
60+
UNW_LOONGARCH64_R2,
61+
UNW_LOONGARCH64_R3,
62+
UNW_LOONGARCH64_R4,
63+
UNW_LOONGARCH64_R5,
64+
UNW_LOONGARCH64_R6,
65+
UNW_LOONGARCH64_R7,
66+
UNW_LOONGARCH64_R8,
67+
UNW_LOONGARCH64_R9,
68+
UNW_LOONGARCH64_R10,
69+
UNW_LOONGARCH64_R11,
70+
UNW_LOONGARCH64_R12,
71+
UNW_LOONGARCH64_R13,
72+
UNW_LOONGARCH64_R14,
73+
UNW_LOONGARCH64_R15,
74+
UNW_LOONGARCH64_R16,
75+
UNW_LOONGARCH64_R17,
76+
UNW_LOONGARCH64_R18,
77+
UNW_LOONGARCH64_R19,
78+
UNW_LOONGARCH64_R20,
79+
UNW_LOONGARCH64_R21,
80+
UNW_LOONGARCH64_R22,
81+
UNW_LOONGARCH64_R23,
82+
UNW_LOONGARCH64_R24,
83+
UNW_LOONGARCH64_R25,
84+
UNW_LOONGARCH64_R26,
85+
UNW_LOONGARCH64_R27,
86+
UNW_LOONGARCH64_R28,
87+
UNW_LOONGARCH64_R29,
88+
UNW_LOONGARCH64_R30,
89+
UNW_LOONGARCH64_R31,
90+
91+
UNW_LOONGARCH64_PC = 32,
92+
93+
/* FIXME: Other registers! */
94+
95+
/* For LoongArch64, the CFA is the value of SP (r3) at the call site in the
96+
previous frame. */
97+
UNW_LOONGARCH64_CFA,
98+
99+
UNW_TDEP_LAST_REG = UNW_LOONGARCH64_PC,
100+
101+
UNW_TDEP_IP = UNW_LOONGARCH64_R1,
102+
UNW_TDEP_SP = UNW_LOONGARCH64_R3,
103+
UNW_TDEP_EH = UNW_LOONGARCH64_R0 /* FIXME. */
104+
}
105+
loongarch64_regnum_t;
106+
107+
#define UNW_TDEP_NUM_EH_REGS 4
108+
109+
typedef struct unw_tdep_save_loc
110+
{
111+
/* Additional target-dependent info on a save location. */
112+
char unused;
113+
}
114+
unw_tdep_save_loc_t;
115+
116+
/* On LoongArch64, we can directly use ucontext_t as the unwind context. */
117+
typedef ucontext_t unw_tdep_context_t;
118+
119+
typedef struct
120+
{
121+
/* no loongarch64-specific auxiliary proc-info */
122+
char unused;
123+
}
124+
unw_tdep_proc_info_t;
125+
126+
#include "libunwind-dynamic.h"
127+
#include "libunwind-common.h"
128+
129+
#define unw_tdep_getcontext UNW_ARCH_OBJ(getcontext)
130+
extern int unw_tdep_getcontext (ucontext_t *uc);
131+
132+
#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
133+
extern int unw_tdep_is_fpreg (int);
134+
135+
#if defined(__cplusplus) || defined(c_plusplus)
136+
}
137+
#endif
138+
139+
#endif /* LIBUNWIND_H */
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/* libunwind - a platform-independent unwind library
2+
Copyright (C) 2008 CodeSourcery
3+
Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
4+
Copyright (C) 2021 Loongson Technology Corporation Limited
5+
6+
This file is part of libunwind.
7+
8+
Permission is hereby granted, free of charge, to any person obtaining
9+
a copy of this software and associated documentation files (the
10+
"Software"), to deal in the Software without restriction, including
11+
without limitation the rights to use, copy, modify, merge, publish,
12+
distribute, sublicense, and/or sell copies of the Software, and to
13+
permit persons to whom the Software is furnished to do so, subject to
14+
the following conditions:
15+
16+
The above copyright notice and this permission notice shall be
17+
included in all copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
26+
27+
#ifndef dwarf_config_h
28+
#define dwarf_config_h
29+
30+
/* This is FIRST_PSEUDO_REGISTER in GCC, since DWARF_FRAME_REGISTERS is not
31+
explicitly defined.
32+
Number of hardware registers. We have:
33+
- 32 integer registers
34+
- 32 floating point registers
35+
- 8 condition code registers
36+
- 2 fake registers:
37+
- ARG_POINTER_REGNUM
38+
- FRAME_POINTER_REGNUM */
39+
#define DWARF_NUM_PRESERVED_REGS 74
40+
41+
#define dwarf_to_unw_regnum(reg) (((reg) < 32) ? (reg) : 0)
42+
43+
/* Not big-endian. */
44+
#define dwarf_is_big_endian(addr_space) 0
45+
46+
/* Convert a pointer to a dwarf_cursor structure to a pointer to
47+
unw_cursor_t. */
48+
#define dwarf_to_cursor(c) ((unw_cursor_t *) (c))
49+
50+
typedef struct dwarf_loc
51+
{
52+
unw_word_t val;
53+
#ifndef UNW_LOCAL_ONLY
54+
unw_word_t type; /* see DWARF_LOC_TYPE_* macros. */
55+
#endif
56+
}
57+
dwarf_loc_t;
58+
59+
#endif /* dwarf_config_h */
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* libunwind - a platform-independent unwind library
2+
Copyright (C) 2008 CodeSourcery
3+
Copyright (C) 2021 Loongson Technology Corporation Limited
4+
5+
This file is part of libunwind.
6+
7+
Permission is hereby granted, free of charge, to any person obtaining
8+
a copy of this software and associated documentation files (the
9+
"Software"), to deal in the Software without restriction, including
10+
without limitation the rights to use, copy, modify, merge, publish,
11+
distribute, sublicense, and/or sell copies of the Software, and to
12+
permit persons to whom the Software is furnished to do so, subject to
13+
the following conditions:
14+
15+
The above copyright notice and this permission notice shall be
16+
included in all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
25+
26+
/* Use glibc's jump-buffer indices; NPTL peeks at SP: */
27+
28+
/* https://github.com/loongson/glibc/blob/loongarch_2_33/sysdeps/loongarch/setjmp.S
29+
https://github.com/loongson/glibc/blob/loongarch_2_33/sysdeps/unix/sysv/linux/loongarch/lp64/jmp_buf-macros.h */
30+
31+
#define JB_SP 1
32+
#define JB_RP 0
33+
#define JB_MASK_SAVED (168>>3)
34+
#define JB_MASK (176>>3)

0 commit comments

Comments
 (0)