mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
9e9451247b
The --import-debug-info CLI flag and the ImporterOptions:: AdditionalDebugInfoPaths field it populated were a side-channel that loaded extra DWARF files outside the normal ELF dependency-resolution path. It bypassed the symbol-aware machinery and is no longer needed.
72 lines
2.3 KiB
C++
72 lines
2.3 KiB
C++
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "revng/Model/Binary.h"
|
|
#include "revng/Model/Importer/Binary/BinaryImporter.h"
|
|
#include "revng/Model/Importer/Binary/ImportBinaryAnalysis.h"
|
|
#include "revng/Model/Importer/Binary/Options.h"
|
|
#include "revng/Pipeline/RegisterAnalysis.h"
|
|
#include "revng/Pipes/ModelGlobal.h"
|
|
#include "revng/Support/ResourceFinder.h"
|
|
#include "revng/TupleTree/TupleTree.h"
|
|
|
|
using namespace revng::pipes;
|
|
|
|
llvm::Error ImportBinaryAnalysis::run(pipeline::ExecutionContext &Context,
|
|
const BinaryFileContainer &SourceBinary) {
|
|
if (not SourceBinary.exists())
|
|
return llvm::Error::success();
|
|
|
|
TupleTree<model::Binary> &Model = getWritableModelFromContext(Context);
|
|
|
|
const ImporterOptions &Options = importerOptions();
|
|
|
|
llvm::Task T(1, "Import binary");
|
|
T.advance("Import main binary", true);
|
|
|
|
model::BinaryIdentifierReference Reference;
|
|
if (Model->Binaries().size() > 0) {
|
|
// TODO: do this unconditionally once we drop the old pipeline
|
|
Reference = Model->getBinaryIdentifierReference(0);
|
|
}
|
|
|
|
if (llvm::Error Error = importBinary(Model,
|
|
*SourceBinary.path(),
|
|
Options,
|
|
Reference)) {
|
|
return Error;
|
|
}
|
|
|
|
return llvm::Error::success();
|
|
}
|
|
|
|
static pipeline::RegisterAnalysis<ImportBinaryAnalysis> E;
|
|
|
|
namespace revng::pypeline::analyses {
|
|
|
|
// TODO: have a configuration to list the "preferred" roots to use for import
|
|
llvm::Error ParseBinaryAnalysis::run(Model &Model,
|
|
const Request &Incoming,
|
|
llvm::StringRef Configuration,
|
|
const BinariesContainer &Binaries) {
|
|
const ImporterOptions &Options = importerOptions();
|
|
|
|
llvm::Task T(1, "Import binary");
|
|
T.advance("Import main binary", true);
|
|
|
|
for (size_t I = 0; I < Binaries.size(); I++) {
|
|
|
|
auto Reference = Model.get()->getBinaryIdentifierReference(I);
|
|
if (llvm::Error Error = importBinary(Model.get(),
|
|
Binaries.getFilePath(I),
|
|
Options,
|
|
Reference))
|
|
return Error;
|
|
}
|
|
|
|
return llvm::Error::success();
|
|
}
|
|
|
|
} // namespace revng::pypeline::analyses
|