Skip to content

Commit 1579cec

Browse files
author
Peter Goodman
authored
Add a flag to search for additional semantics paths (#450)
1 parent 3b2f44f commit 1579cec

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

remill/BC/Util.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959

6060
DECLARE_string(arch);
6161

62+
DEFINE_string(semantics_search_paths, "", "Colon-separated list of search paths to use when searching for semantics files.");
63+
6264
namespace {
6365
#ifdef WIN32
6466
extern "C" std::uint32_t GetProcessId(std::uint32_t handle);
@@ -484,11 +486,22 @@ std::string FindHostSemanticsBitcodeFile(void) {
484486

485487
// Find the path to the semantics bitcode file.
486488
std::string FindSemanticsBitcodeFile(const std::string &arch) {
489+
if (!FLAGS_semantics_search_paths.empty()) {
490+
std::stringstream pp;
491+
pp << FLAGS_semantics_search_paths;
492+
for (std::string sem_dir; std::getline(pp, sem_dir, ':'); ) {
493+
std::stringstream ss;
494+
ss << sem_dir << "/" << arch << ".bc";
495+
if (auto sem_path = ss.str(); FileExists(sem_path)) {
496+
return sem_path;
497+
}
498+
}
499+
}
500+
487501
for (auto sem_dir : gSemanticsSearchPaths) {
488502
std::stringstream ss;
489503
ss << sem_dir << "/" << arch << ".bc";
490-
auto sem_path = ss.str();
491-
if (FileExists(sem_path)) {
504+
if (auto sem_path = ss.str(); FileExists(sem_path)) {
492505
return sem_path;
493506
}
494507
}

0 commit comments

Comments
 (0)