// Patch's jump destinations searcher // Copyright (C) 2025 Nguyễn Gia Phong // // This file is part of taosc. // // Taosc is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Taosc is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with taosc. If not, see . #include "helpers.hh" // Dyninst headers #include #include #include #include #include int main (int argc, char** argv) { Dyninst::ParseAPI::SymtabCodeSource cs {parse_args (argc, argv)}; Dyninst::ParseAPI::CodeObject co {&cs}; co.parse (); // parsed functions have same lifetime as co while (!std::cin.eof ()) { Dyninst::Address address; std::cin >> std::hex >> address; if (std::cin.fail ()) break; std::cout << std::hex << address; auto* const block = find_block (cs, co, address); if (block->containingFuncs () < 1) die_for (address, "no function found containing instruction at"); std::vector functions; block->getFuncs (functions); std::set seen; for (auto* const fun : functions) for (auto const& return_block : fun->returnBlocks ()) { std::set post_dominates; fun->getImmediatePostDominates (return_block, post_dominates); for (auto* const pd : post_dominates) if (seen.insert (pd->start ()).second) std::cout << ' ' << std::hex << pd->start (); } std::cout << '\n'; } if (std::cin.eof ()) return 0; std::cerr << "invalid input\n"; return -1; }