mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-29 05:50:04 +08:00
GP-3167: Fixed a bug that prevented the Mach-O loader from finding and
loading libraries that reside in a Universal Binary file
This commit is contained in:
@@ -164,23 +164,9 @@ public class MachoLoader extends AbstractLibrarySupportLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (FatArch architecture : architectures) {
|
for (FatArch architecture : architectures) {
|
||||||
|
ByteProvider bp = new ByteProviderWrapper(provider, architecture.getOffset(),
|
||||||
// Note: The creation of the byte provider that we pass to the importer deserves a
|
architecture.getSize());
|
||||||
// bit of explanation:
|
LoadSpec libLoadSpec = matchSupportedLoadSpec(loadSpec, bp);
|
||||||
//
|
|
||||||
// At this point in the process we have a FatArch, which provides access to the
|
|
||||||
// underlying bytes for the Macho in the form of an input stream. From that we could
|
|
||||||
// create a byte provider. That doesn't work however. Here's why:
|
|
||||||
//
|
|
||||||
// The underlying input stream in the FatArch has already been parsed and the first
|
|
||||||
// 4 (magic) bytes read. If we create a provider from that stream and pass it to
|
|
||||||
// the parent import method, we'll have a problem because that parent method will
|
|
||||||
// try to read those first 4 magic bytes again, which violates the contract of the
|
|
||||||
// input stream provider (you can't read the same bytes over again) and will throw
|
|
||||||
// an exception. To avoid that, just create the provider from the original file
|
|
||||||
// provider, and not from the FatArch input stream.
|
|
||||||
ByteProvider bp = new ByteProviderWrapper(provider, architecture.getOffset(), architecture.getSize());
|
|
||||||
LoadSpec libLoadSpec = matchSupportedLoadSpec(loadSpec, provider);
|
|
||||||
if (libLoadSpec != null) {
|
if (libLoadSpec != null) {
|
||||||
return bp;
|
return bp;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user