blob: 0bcce8410bbaf3681c5db7c000ad80e73a3de4d3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// 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 <https://www.gnu.org/licenses/>.
#include "helpers.hh"
// Dyninst headers
#include <CFG.h>
#include <CodeObject.h>
#include <iostream>
#include <set>
#include <vector>
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 <Dyninst::ParseAPI::Function*> functions;
block->getFuncs (functions);
std::set <Dyninst::Address> seen;
for (auto* const fun : functions)
for (auto const& return_block : fun->returnBlocks ())
{
std::set <Dyninst::ParseAPI::Block*> 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;
}
|