未验证 提交 f1337d90 编写于 作者: Q Qiao Pengcheng 提交者: GitHub

[LoongArch64] add the `coreclr/unwinder/loongarch64` from the #62979. (#63489)

* [LoongArch64] add the `coreclr/unwinder/loongarch64` from the #62979.

* [LoongArch64] replace the `__in` with `_In_`.

* [LoongArch64] update the version of the `LICENSE description`.

* [LoongArch64] update the macro-define for crossgen2.

* [LoongArch64] amend the comment notes.
Co-authored-by: Nqiaopengcheng <qiaopengcheng-hf@loongson.cn>
上级 135a9608
......@@ -1030,4 +1030,69 @@ RtlVirtualUnwind(
#endif
#ifdef TARGET_LOONGARCH64
#include "daccess.h"
#define UNW_FLAG_NHANDLER 0x0 /* any handler */
#define UNW_FLAG_EHANDLER 0x1 /* filter handler */
#define UNW_FLAG_UHANDLER 0x2 /* unwind handler */
// This function returns the RVA of the end of the function (exclusive, so one byte after the actual end)
// using the unwind info on LOONGARCH64. (see ExternalAPIs\Win9CoreSystem\inc\winnt.h)
FORCEINLINE
ULONG64
RtlpGetFunctionEndAddress (
_In_ PT_RUNTIME_FUNCTION FunctionEntry,
_In_ ULONG64 ImageBase
)
{
ULONG64 FunctionLength;
FunctionLength = FunctionEntry->UnwindData;
if ((FunctionLength & 3) != 0) {
FunctionLength = (FunctionLength >> 2) & 0x7ff;
} else {
memcpy(&FunctionLength, (void*)(ImageBase + FunctionLength), sizeof(UINT32));
FunctionLength &= 0x3ffff;
}
return FunctionEntry->BeginAddress + 4 * FunctionLength;
}
#define RUNTIME_FUNCTION__BeginAddress(FunctionEntry) ((FunctionEntry)->BeginAddress)
#define RUNTIME_FUNCTION__SetBeginAddress(FunctionEntry,address) ((FunctionEntry)->BeginAddress = (address))
#define RUNTIME_FUNCTION__EndAddress(FunctionEntry, ImageBase) (RtlpGetFunctionEndAddress(FunctionEntry, (ULONG64)(ImageBase)))
#define RUNTIME_FUNCTION__SetUnwindInfoAddress(prf,address) do { (prf)->UnwindData = (address); } while (0)
typedef struct _UNWIND_INFO {
// dummy
} UNWIND_INFO, *PUNWIND_INFO;
EXTERN_C
NTSYSAPI
PEXCEPTION_ROUTINE
NTAPI
RtlVirtualUnwind(
IN ULONG HandlerType,
IN ULONG64 ImageBase,
IN ULONG64 ControlPc,
IN PRUNTIME_FUNCTION FunctionEntry,
IN OUT PCONTEXT ContextRecord,
OUT PVOID *HandlerData,
OUT PULONG64 EstablisherFrame,
IN OUT PKNONVOLATILE_CONTEXT_POINTERS ContextPointers OPTIONAL
);
#ifndef IMAGE_REL_LOONGARCH64_PC
#define IMAGE_REL_LOONGARCH64_PC 0x0003
#endif
#ifndef IMAGE_REL_LOONGARCH64_JIR
#define IMAGE_REL_LOONGARCH64_JIR 0x0004
#endif
#endif // TARGET_LOONGARCH64
#endif // CLRNT_H_
......@@ -1025,6 +1025,12 @@ typedef IMAGE_RELOCATION UNALIGNED *PIMAGE_RELOCATION;
#define IMAGE_REL_IA64_GPREL32 0x001C
#define IMAGE_REL_IA64_ADDEND 0x001F
//
// LOONGARCH64 relocation types
//
#define IMAGE_REL_LOONGARCH64_PC 0x0003
#define IMAGE_REL_LOONGARCH64_JIR 0x0004
//
// CEF relocation types.
//
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
#ifndef __unwinder_loongarch64__
#define __unwinder_loongarch64__
#include "unwinder.h"
//---------------------------------------------------------------------------------------
//
// See the comment for the base class code:OOPStackUnwinder.
//
class OOPStackUnwinderLoongarch64 : public OOPStackUnwinder
{
public:
// Unwind the given CONTEXT to the caller CONTEXT. The CONTEXT will be overwritten.
BOOL Unwind(T_CONTEXT * pContext);
//
// Everything below comes from dbghelp.dll.
//
protected:
HRESULT UnwindPrologue(_In_ DWORD64 ImageBase,
_In_ DWORD64 ControlPc,
_In_ DWORD64 FrameBase,
_In_ _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionEntry,
__inout PT_CONTEXT ContextRecord);
HRESULT VirtualUnwind(_In_ DWORD64 ImageBase,
_In_ DWORD64 ControlPc,
_In_ _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionEntry,
__inout PT_CONTEXT ContextRecord,
_Out_ PDWORD64 EstablisherFrame);
DWORD64 LookupPrimaryUnwindInfo
(_In_ _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionEntry,
_In_ DWORD64 ImageBase,
_Out_ _PIMAGE_RUNTIME_FUNCTION_ENTRY PrimaryEntry);
_PIMAGE_RUNTIME_FUNCTION_ENTRY SameFunction
(_In_ _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionEntry,
_In_ DWORD64 ImageBase,
_In_ DWORD64 ControlPc,
_Out_ _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionReturnBuffer);
};
#endif // __unwinder_loongarch64__
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册