Hi Radek,

I'm not sure about one change here:

On Jul 10 10:10, Radek Barton via Cygwin-patches wrote:
> Hello.
> 
> Sending the same patch with more detailed commit message added.
> 
> Radek
> ---
> >From ebec7171c9fdf162e0d193f7ba3468766191cc8d 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 v2] 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 | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/winsup/utils/mingw/cygcheck.cc b/winsup/utils/mingw/cygcheck.cc
> index 89a08e560..6ec7bcf03 100644
> --- a/winsup/utils/mingw/cygcheck.cc
> +++ b/winsup/utils/mingw/cygcheck.cc
> @@ -654,13 +654,20 @@ 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;
> +    }
> +  int base_off = 112;

base_off is the offset of the NumberOfRvaAndSizes field in the extended
COFF header.  This is documented(*) as being at offset 108 in the PE32+
format, independent of the targeted CPU.  112 is the offset of the
.edata section address and size info in the PE32+ data directory entries.

So I have a problem with changing the offest here.  Can you please check
again if that's really correct?  If so, the documentation(*) needs an
update.

(*) https://learn.microsoft.com/en-us/windows/win32/debug/pe-format


Thanks,
Corinna

Reply via email to