diff --git a/docs/writeup.txt b/docs/writeup.txt index a1c79bc..a2070a6 100644 --- a/docs/writeup.txt +++ b/docs/writeup.txt @@ -44,3 +44,6 @@ Plugin is per compilation unit -> structs with same name can habe different definitions in different CUs (disallow this for now) -> anonymous structs can not really be matched between CUs without type hash (disallow this for now) -> later, use hash(type) to match structs between CUs to randomize as one + +Symbols must be object symbols because untyped/function symbols cause objtool issues in kernel build + -> can not find starting instruction of function diff --git a/pinpoint/final/on_finish_unit.cpp b/pinpoint/final/on_finish_unit.cpp index 6d632a7..4c28adf 100644 --- a/pinpoint/final/on_finish_unit.cpp +++ b/pinpoint/final/on_finish_unit.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -153,9 +154,24 @@ void on_finish_unit(void* plugin_data, void* user_data) { out << "SPSLR " << get_src_file() << " " << cu_uid << std::endl; - // Dump all target structs + // Construct set of all targets that are used by at least 1 ipin or dpin + + std::unordered_set used_targets; + + for (const DataPin& dpin : DataPin::all()) { + for (const DataPin::Component& c : dpin.components) + used_targets.insert(c.target); + } + + for (const auto& [uid, ipin] : s2_pins()) + used_targets.insert(ipin.target); + + // Dump all USED target structs for (const auto& [uid, target] : TargetType::all()) { + if (used_targets.find(uid) == used_targets.end()) + continue; + // target out << "target " << target.name() << " " << uid << " " << target.size() << " " << target.fields().size() << std::endl;