When we try to find the compat32 dynamic linker, strip out the arch-specific

string (sparc:v8plus -> sparc).
This commit is contained in:
christos 2023-08-29 20:39:17 +00:00
parent 02a0982161
commit 8dde7a0133
1 changed files with 7 additions and 5 deletions

View File

@ -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);
}