From 8dde7a0133af6937a5e606a16b242f84b5d04422 Mon Sep 17 00:00:00 2001 From: christos Date: Tue, 29 Aug 2023 20:39:17 +0000 Subject: [PATCH] When we try to find the compat32 dynamic linker, strip out the arch-specific string (sparc:v8plus -> sparc). --- external/gpl3/gdb/dist/gdb/solib.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/external/gpl3/gdb/dist/gdb/solib.c b/external/gpl3/gdb/dist/gdb/solib.c index ea3a9c4d6258..1c1a1b875d56 100644 --- a/external/gpl3/gdb/dist/gdb/solib.c +++ b/external/gpl3/gdb/dist/gdb/solib.c @@ -476,18 +476,20 @@ solib_bfd_open (const char *pathname) b = gdbarch_bfd_arch_info (target_gdbarch ()); if (!b->compatible (b, bfd_get_arch_info (abfd.get ()))) { - char buf[SO_NAME_MAX_PATH_SIZE]; const char *slash = strrchr(pathname, '/'); if (slash) { + char buf[SO_NAME_MAX_PATH_SIZE], arch[128], *colon; struct stat st; - snprintf(buf, sizeof(buf), "%.*s/%s/%s", - (int)(slash - pathname), pathname, b->printable_name, slash + 1); + strlcpy(arch, b->printable_name, sizeof(arch)); + if ((colon = strchr(arch, ':')) != NULL) + *colon = '\0'; + snprintf(buf, sizeof(buf), "%.*s/%s/%s", + (int)(slash - pathname), pathname, arch, slash + 1); if (stat(buf, &st) == 0) return solib_bfd_open(buf); - snprintf(buf, sizeof(buf), "%s-%s", - pathname, b->printable_name); + snprintf(buf, sizeof(buf), "%s-%s", pathname, arch); if (stat(buf, &st) == 0) return solib_bfd_open(buf); }