Re: [PATCH] Cygwin: dumper: add Aarch64 support

Jon Turney <[email protected]> Thu, 16 Jul 2026 14:15:24 +0100
Newsgroups gmane.os.cygwin.patches
Message-ID <[email protected]>
On 09/07/2026 11:13, Aswin Kalies Ramkumar Mangayarkarasi wrote:
> Hi Everyone,
> This patch adds Aarch64 support to the core dumper utility. Previously, dumper.cc used "elf64-aarch64" as the BFD target name, which is not a valid BFD target vector which caused bfd_openw() to fail with "invalid bfd target" on Aarch64. This has been corrected to "elf64-littleaarch64", matching the aarch64_elf64_le_vec vector registered by BFD.
>   Additionally, bfd_set_arch_mach() was unconditionally called with bfd_arch_i386, which is only correct for the x86_64 build. This is now conditionalized so Aarch64 builds use bfd_arch_aarch64 / bfd_mach_aarch64 instead.

Thanks!

I applied (a slightly modified version of) this patch.

> Thanks and Regards,
> Aswin Kalies
> Inline Patch
> ---
>   winsup/utils/Makefile.am |  2 +-
>   winsup/utils/dumper.cc   | 20 ++++++++++++++------
>   2 files changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/winsup/utils/Makefile.am b/winsup/utils/Makefile.am
> index e44079a41..a4521f2ab 100644
> --- a/winsup/utils/Makefile.am
> +++ b/winsup/utils/Makefile.am
> @@ -79,7 +79,7 @@ LDADD = -lnetapi32
>   cygpath_CXXFLAGS = -fno-threadsafe-statics $(AM_CXXFLAGS)
>   cygpath_LDADD = $(LDADD) -luserenv -lntdll
>   dumper_CXXFLAGS = -I$(top_srcdir)/../include $(AM_CXXFLAGS)
> -dumper_LDADD = $(LDADD) -lpsapi -lntdll -lbfd @BFD_LIBS@
> +dumper_LDADD = $(LDADD) -lpsapi -lntdll -lbfd -lsframe @BFD_LIBS@

This should not be needed.

sframe is added to BFD_LIBS if it's present (Yes, this is terrible, but 
it seems to be the best we can do since libbfd doesn't have a pkgconfig 
file).

>   dumper_LDFLAGS = -Wl,--disable-high-entropy-va
>   ldd_LDADD = $(LDADD) -lpsapi -lntdll
>   mount_CXXFLAGS = -DFSTAB_ONLY $(AM_CXXFLAGS)
> diff --git a/winsup/utils/dumper.cc b/winsup/utils/dumper.cc
> index b3151e66d..830cf9ce1 100644
> --- a/winsup/utils/dumper.cc
> +++ b/winsup/utils/dumper.cc
> @@ -703,7 +703,7 @@ dumper::init_core_dump ()
>   #if defined(__x86_64__)
>     const char *target = "elf64-x86-64";
>   #elif defined(__aarch64__)
> -  const char *target = "elf64-aarch64";
> +  const char *target = "elf64-littleaarch64";
>   #else
>   #error unimplemented for this target
>   #endif
> @@ -721,11 +721,19 @@ dumper::init_core_dump ()
>         goto failed;
>       }
> 
> -  if (!bfd_set_arch_mach (core_bfd, bfd_arch_i386, 0 /* = default */))
> -    {
> -      bfd_perror ("setting bfd architecture");
> -      goto failed;
> -    }
> +#if defined(__x86_64__)
> +  if (!bfd_set_arch_mach(core_bfd, bfd_arch_i386, 0 /* = default */))
> +  {
> +   bfd_perror("setting bfd architecture");
> +   goto failed;
> +  }
> +#elif defined(__aarch64__)
> +  if (!bfd_set_arch_mach(core_bfd, bfd_arch_aarch64, bfd_mach_aarch64))
> +  {
> +   bfd_perror("setting bfd architecture");
> +   goto failed;
> +  }

I also added here a:

#else
#error unimplemented for this target

> +#endif
> 
>     return 1;
> 
> -