Hello.

Hmm. It's quite a while since I've been writing this and honestly I no longer 
remember why I though the offset should be different for AArch64. Now, looking 
into the documentation and the surrounding source code, I'd say 108 is a 
correct value. Furthermore, I've tried `cygcheck -s -v` with both and 112 was 
crashing while 108 seemed to work.

Thank you for noticing this.

Radek

---
>From a27cdd462d1067e8bffe7dade7c3d2088ed7866f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Radek=20Barto=C5=88?= <radek.bar...@microsoft.com>
Date: Mon, 9 Jun 2025 13:08:35 +0200
Subject: [PATCH v3] Cygwin: cygcheck: port to AArch64
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This patch ports `winsup/utils/mingw/cygcheck.cc` to AArch64:
 - Adds arch=aarch64 to packages API URL.
 - Ports dll_info function.

Signed-off-by: Radek BartoĊˆ <radek.bar...@microsoft.com>
---
 winsup/utils/mingw/cygcheck.cc | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/winsup/utils/mingw/cygcheck.cc b/winsup/utils/mingw/cygcheck.cc
index 89a08e560..d17909bfc 100644
--- a/winsup/utils/mingw/cygcheck.cc
+++ b/winsup/utils/mingw/cygcheck.cc
@@ -654,16 +654,22 @@ dll_info (const char *path, HANDLE fh, int lvl, int 
recurse)
   WORD arch = get_word (fh, pe_header_offset + 4);
   if (GetLastError () != NO_ERROR)
     display_error ("get_word");
-#ifdef __x86_64__
+#if defined(__x86_64__)
   if (arch != IMAGE_FILE_MACHINE_AMD64)
     {
       puts (verbose ? " (not x86_64 dll)" : "\n");
       return;
     }
-  int base_off = 108;
+#elif defined (__aarch64__)
+  if (arch != IMAGE_FILE_MACHINE_ARM64)
+    {
+      puts (verbose ? " (not aarch64 dll)" : "\n");
+      return;
+    }
 #else
 #error unimplemented for this target
 #endif
+  int base_off = 108;
   int opthdr_ofs = pe_header_offset + 4 + 20;
   unsigned short v[6];
 
@@ -2108,8 +2114,10 @@ static const char safe_chars[] = "$-_.!*'(),";
 static const char grep_base_url[] =
        "http://cygwin.com/cgi-bin2/package-grep.cgi?text=1&grep=";;
 
-#ifdef __x86_64__
+#if defined(__x86_64__)
 #define ARCH_STR  "&arch=x86_64"
+#elif defined(__aarch64__)
+#define ARCH_STR  "&arch=aarch64"
 #else
 #error unimplemented for this target
 #endif
-- 
2.50.1.vfs.0.0

Attachment: v3-0001-Cygwin-cygcheck-port-to-AArch64.patch
Description: v3-0001-Cygwin-cygcheck-port-to-AArch64.patch

Reply via email to