Hi, This patch adds minimal AArch64 stubs to `winsup/utils/ssp.c` to allow the ssp utility to compile as part of the Cygwin AArch64 target.
*
Architecture-specific conditionals are extended to cover aarch64
alongside existing i386 and x86_64 code paths.
*
Context register handling, single-step control, and register dumping
are stubbed out with placeholder logic.
*
No functional debugging or single-step support is implemented for AArch64.
*
These changes are intended solely to unblock the build and will require proper
AArch64-specific implementations in a follow-up change.
Thanks & regards
Thirumalai N
In-lined Patch:
diff --git a/winsup/utils/ssp.c b/winsup/utils/ssp.c
index 96a90a1d9..9ab9d1e05 100644
--- a/winsup/utils/ssp.c
+++ b/winsup/utils/ssp.c
@@ -41,13 +41,21 @@ static struct option longopts[] =
static char opts[] = "+cdehlstvV";
-#ifdef __x86_64__
+#if defined(__x86_64__)
#define KERNEL_ADDR 0x00007FF000000000
#define CONTEXT_SP Rsp
#define CONTEXT_IP Rip
typedef DWORD64 CONTEXT_REG;
#define CONTEXT_REG_FMT "%016llx"
#define ADDR_SSCANF_FMT "%lli"
+#elif defined(__aarch64__)
+// TODO
+#define KERNEL_ADDR 0x00007FF000000000
+#define CONTEXT_SP Sp
+#define CONTEXT_IP Pc
+typedef DWORD64 CONTEXT_REG;
+#define CONTEXT_REG_FMT "%016llx"
+#define ADDR_SSCANF_FMT "%lli"
#else
#error unimplemented for this target
#endif
@@ -200,10 +208,16 @@ set_step_threads (int threadId, int trace)
if (rv != -1)
{
thread_step_flags[tix] = trace;
+#if defined(__i386__) || defined(__x86_64__)
if (trace)
context.EFlags |= 0x100; /* TRAP (single step) flag */
else
context.EFlags &= ~0x100; /* TRAP (single step) flag */
+#elif defined(__aarch64__)
+ // TODO
+#else
+#error unimplemented for this target
+#endif
SetThreadContext (thread, &context);
}
}
@@ -215,7 +229,14 @@ set_steps ()
for (i=0; i<num_active_threads; i++)
{
GetThreadContext (active_threads[i], &context);
+#if defined(__i386__) || defined(__x86_64__)
s = context.EFlags & 0x0100;
+#elif defined(__aarch64__)
+ // TODO
+ s = 0;
+#else
+#error unimplemented for this target
+#endif
if (!s && thread_step_flags[i])
{
set_step_threads (active_thread_ids[i], 1);
@@ -252,11 +273,13 @@ dump_registers (HANDLE thread)
{
context.ContextFlags = CONTEXT_FULL;
GetThreadContext (thread, &context);
-#ifdef __x86_64__
+#if defined(__x86_64__)
printf ("eax %016llx ebx %016llx ecx %016llx edx %016llx eip\n",
context.Rax, context.Rbx, context.Rcx, context.Rdx);
printf ("esi %016llx edi %016llx ebp %016llx esp %016llx %016llx\n",
context.Rsi, context.Rdi, context.Rbp, context.Rsp, context.Rip);
+#elif defined(__aarch64__)
+ // TODO
#else
#error unimplemented for this target
#endif
@@ -542,19 +565,31 @@ run_program (char *cmdline)
{
if (pc == thread_return_address[tix])
{
+#if defined(__i386__) || defined(__x86_64__)
if (context.EFlags & 0x100)
{
context.EFlags &= ~0x100; /* TRAP (single step) flag */
SetThreadContext (hThread, &context);
}
+#elif defined(__aarch64__)
+ // TODO
+#else
+#error unimplemented for this target
+#endif
}
else if (stepping_enabled)
{
+#if defined(__i386__) || defined(__x86_64__)
if (!(context.EFlags & 0x100))
{
context.EFlags |= 0x100; /* TRAP (single step) flag */
SetThreadContext (hThread, &context);
}
+#elif defined(__aarch64__)
+ // TODO
+#else
+#error unimplemented for this target
+#endif
}
}
break;
@@ -935,7 +970,7 @@ main (int argc, char **argv)
if (dll_counts)
{
-#ifdef __x86_64__
+#if defined(__x86_64__) || defined(__aarch64__)
/* 1234567 123% 1234567 123% 1234567812345678 xxxxxxxxxxx */
printf (" Main-Thread Other-Thread BaseAddr DLL Name\n");
#else
--
Cygwin-ssp-add-AArch64-build-stubs.patch
Description: Cygwin-ssp-add-AArch64-build-stubs.patch
