--- gdb-14.2/bfd/configure.ac.orig	2024-03-03 06:54:59.000000000 +0100
+++ gdb-14.2/bfd/configure.ac	2025-02-03 17:09:21.787146100 +0100
@@ -285,7 +285,7 @@
   # More hacks to build DLLs on Windows.
   *-*-cygwin*)
     SHARED_LDFLAGS="-no-undefined"
-    SHARED_LIBADD="-L`pwd`/../libiberty -liberty $SHARED_LIBADD -lcygwin -lkernel32"
+    SHARED_LIBADD="-L`pwd`/../libiberty -liberty $SHARED_LIBADD -lmsys-2.0 -lkernel32"
   ;;
   esac
 
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index d46de87f238..971efd086c0 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -900,11 +900,19 @@ windows_make_so (const char *name, LPVOID load_addr)
 	    }
 	}
     }
+#ifdef __MSYS__
+  /* Record msys-2.0.dll .text start/end.  */
+  size_t len = sizeof ("/msys-2.0.dll") - 1;
+  if (so->name.size () >= len
+      && strcasecmp (so->name.c_str () + so->name.size () - len,
+		     "/msys-2.0.dll") == 0)
+#else
   /* Record cygwin1.dll .text start/end.  */
   size_t len = sizeof ("/cygwin1.dll") - 1;
   if (so->name.size () >= len
       && strcasecmp (so->name.c_str () + so->name.size () - len,
 		     "/cygwin1.dll") == 0)
+#endif
     {
       asection *text = NULL;
 
--- gdb-14.2/gdb/windows-tdep.c.orig	2025-02-03 17:39:53.204129800 +0100
+++ gdb-14.2/gdb/windows-tdep.c	2025-02-03 18:32:18.712714400 +0100
@@ -38,7 +38,11 @@
 #include "libcoff.h"
 #include "solist.h"
 
+#ifdef __MSYS__
+#define CYGWIN_DLL_NAME "msys-2.0.dll"
+#else
 #define CYGWIN_DLL_NAME "cygwin1.dll"
+#endif
 
 /* Windows signal numbers differ between MinGW flavors and between
    those and Cygwin.  The below enumerations were gleaned from the
--- gdb-14.2/libctf/configure.ac.orig	2024-03-03 06:55:00.000000000 +0100
+++ gdb-14.2/libctf/configure.ac	2025-02-03 17:10:13.336687000 +0100
@@ -227,7 +227,7 @@
   # More hacks to build DLLs on Windows.
     *-*-cygwin*)
       SHARED_LDFLAGS="-no-undefined"
-      CTF_LIBADD="$CTF_LIBADD -lcygwin"
+      CTF_LIBADD="$CTF_LIBADD -lmsys-2.0"
       ;;
   esac
 fi
--- gdb-14.2/libtool.m4.orig	2023-10-08 09:51:14.000000000 +0200
+++ gdb-14.2/libtool.m4	2025-02-03 17:11:29.960518700 +0100
@@ -2263,7 +2263,7 @@
     case $host_os in
     cygwin*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/msys-/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
 m4_if([$1], [],[
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
       ;;
--- gdb-14.2/readline/readline/support/shobj-conf.orig	2023-02-02 05:45:53.000000000 +0100
+++ gdb-14.2/readline/readline/support/shobj-conf	2025-02-03 17:14:47.852169300 +0100
@@ -479,7 +479,7 @@
 cygwin*)
 	SHOBJ_LD='$(CC)'
 	SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a'
-	SHLIB_LIBPREF='cyg'
+	SHLIB_LIBPREF='msys-'
 	SHLIB_LIBSUFF='dll'
 	SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)'
 	SHLIB_LIBS='$(TERMCAP_LIB)'
