Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit fa2d4b3

Browse files
AiethelPeter Goodman
andauthored
Update dyninst frontend (#701)
* cmake: Set c++ standard to c++17. * dyninst: Properly set is_referenced_by_data if bb is target of data reference. * dyninst: Always set some value to is_reference_by_data field. Co-authored-by: Peter Goodman <[email protected]>
1 parent d9bbd1e commit fa2d4b3

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

tools/mcsema_disass/dyninst/CFGWriter.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ void CFGWriter::Write() {
356356
}
357357

358358
module.set_name(FLAGS_binary);
359+
ComputeBBAttributes();
359360
}
360361

361362
void CFGWriter::WriteExternalVariables() {
@@ -1200,3 +1201,23 @@ bool CFGWriter::IsExternal(Address addr) const {
12001201
return ctx.external_vars.find(addr) != ctx.external_vars.end() ||
12011202
ctx.external_funcs.find(addr) != ctx.external_funcs.end();
12021203
}
1204+
1205+
// Set `is_referenced_by_data`. This is independent from the
1206+
// actual xref resolution and is done as last step.
1207+
// TODO(lukas): We may need mark offset tables entries as well.
1208+
void CFGWriter::ComputeBBAttributes() {
1209+
std::unordered_map<uint64_t, mcsema::Block *> bbs;
1210+
for (auto &cfg_fn : *module.mutable_funcs()) {
1211+
for (auto &cfg_bb : *cfg_fn.mutable_blocks()) {
1212+
bbs.emplace(cfg_bb.ea(), &cfg_bb);
1213+
cfg_bb.set_is_referenced_by_data(false);
1214+
}
1215+
}
1216+
1217+
for (auto &[ea, cfg_dref] : ctx.data_xrefs) {
1218+
auto it = bbs.find(cfg_dref->target_ea());
1219+
if (it == bbs.end())
1220+
continue;
1221+
it->second->set_is_referenced_by_data(true);
1222+
}
1223+
}

tools/mcsema_disass/dyninst/CFGWriter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ class CFGWriter {
9696
void CheckDisplacement(Dyninst::InstructionAPI::Expression *,
9797
mcsema::Instruction *);
9898
bool IsExternal(Dyninst::Address addr) const;
99+
void ComputeBBAttributes();
100+
99101

100102
mcsema::Module &module;
101103

tools/mcsema_disass/dyninst/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
if (NOT UNIX)
1717
message (ERROR "The Dyninst frontend currently does not support this OS")
1818
else ()
19-
add_compile_options(-frtti -std=c++14)
2019
set (CMAKE_CXX_FLAGS "-frtti")
21-
set (CMAKE_CXX_FLAGS "-std=c++14")
20+
set (CMAKE_CXX_STANDARD 17)
2221
endif ()
2322

2423
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

0 commit comments

Comments
 (0)