Mac dump_syms: work around NXFindBestFatArch bug

On macOS 13 x86_64 machines, NXFindBestFatArch does not correctly find
arm64e slices. This is filed as FB11955188.

I was hoping manually masking the subtype with CPU_SUBTYPE_MASK would
be sufficient to work around but no luck. So let's just fall through
to doing an exact* match if NXFindBestFatArch fails.

* "Exact" meaning with CPU_SUBTYPE_MASK now masked off. But
libmacho/arch.c calls that exact too, so I'm just going to go with it.

Bug: 1400770
Change-Id: Id497946d3c719285c5d7508e589e4a466da1ceca
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/4178621
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Leonard Grey 2023-01-18 16:15:04 -05:00
parent 934d6b2a5d
commit dd0ca9d70a

View file

@ -268,7 +268,8 @@ SuperFatArch* DumpSymbols::FindBestMatchForArchitecture(
return &object_files_[i];
}
assert(best_match == NULL);
return NULL;
// Fall through since NXFindBestFatArch can't find arm slices on x86_64
// macOS 13. See FB11955188.
}
// Check for an exact match with cpu_type and cpu_subtype.
@ -276,7 +277,8 @@ SuperFatArch* DumpSymbols::FindBestMatchForArchitecture(
it != object_files_.end();
++it) {
if (static_cast<cpu_type_t>(it->cputype) == cpu_type &&
static_cast<cpu_subtype_t>(it->cpusubtype) == cpu_subtype)
(static_cast<cpu_subtype_t>(it->cpusubtype) & ~CPU_SUBTYPE_MASK) ==
(cpu_subtype & ~CPU_SUBTYPE_MASK))
return &*it;
}
@ -285,8 +287,11 @@ SuperFatArch* DumpSymbols::FindBestMatchForArchitecture(
// NXFindBestFatArch, located at
// http://web.mit.edu/darwin/src/modules/cctools/libmacho/arch.c.
fprintf(stderr, "Failed to find an exact match for an object file with cpu "
"type: %d and cpu subtype: %d. Furthermore, at least one object file is "
"larger than 2**32.\n", cpu_type, cpu_subtype);
"type: %d and cpu subtype: %d.\n", cpu_type, cpu_subtype);
if (!can_convert_to_fat_arch) {
fprintf(stderr, "Furthermore, at least one object file is larger "
"than 2**32.\n");
}
return NULL;
}