From 0f240969b4cd25fa8befd332cd2cf6601eee83b9 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Wed, 2 Jan 2019 00:13:51 +0100 Subject: [PATCH] MakeImports: skip wrong-architecture libraries --- PEFTools/MakeImport.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/PEFTools/MakeImport.cc b/PEFTools/MakeImport.cc index 80ef1be6fa..fc059f9846 100755 --- a/PEFTools/MakeImport.cc +++ b/PEFTools/MakeImport.cc @@ -212,7 +212,7 @@ void MakeImportLibrary(char *pefptr, size_t pefsize, fs::path dest, fs::path tmp } } -void MakeImportLibraryMulti(fs::path path, fs::path libname) +bool MakeImportLibraryMulti(fs::path path, fs::path libname) { ResourceFile resFile(path.string()); assert(resFile.read()); @@ -226,7 +226,7 @@ void MakeImportLibraryMulti(fs::path path, fs::path libname) if(data.size() < 8 || std::string(data.begin(), data.begin()+8) != "Joy!peff") { std::cerr << "Not a PEF shared library. Ignoring.\n"; - return; + return false; } if(resFile.resources.resources.find(ResRef("cfrg",0)) == resFile.resources.resources.end()) @@ -257,6 +257,14 @@ void MakeImportLibraryMulti(fs::path path, fs::path libname) member = (CFragResourceMember*) (((char*)member) + member->memberSize); } + if(!std::any_of(members.begin(), members.end(), [](const auto& member) { + return member.architecture == 'pwpc' || member.architecture == '\?\?\?\?'; + })) + { + std::cerr << "Does not contain a PowerPC variant. Ignoring.\n"; + return false; + } + fs::path tmpdir = libname.parent_path() / fs::unique_path("makeimport-tmp-%%%%-%%%%-%%%%-%%%%"); fs::create_directory(tmpdir); try @@ -331,6 +339,8 @@ void MakeImportLibraryMulti(fs::path path, fs::path libname) throw; } fs::remove_all(tmpdir); + + return true; } int main (int argc, char * const argv[])