GTIRB
v2.2.0
GrammaTech Intermediate Representation for Binaries
Main Page
More Information
Frequently Asked Questions
Binary Representation with GTIRB
Using Serialized GTIRB Data
Advice on when to Place ICFG Edges
Standard AuxData Schemata
Contributing
Tutorial: Stack Stamping
GTIRB Tools
Disassembler (ddisasm)
Ghidra Plugin (gtirb-ghidra-plugin)
Pretty Printer (gtirb-pprinter)
API Components
API Implementations
C++ API
Python API
Java API
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Modules
Pages
data-symbols.py
Open an IR and print every symbol pointing to data.
1
#!/usr/bin/python
2
#
3
# An example program which opens an IR and prints information about all
4
# symbols pointing to data.
5
#
6
# To run this example, do the following.
7
#
8
# 1. Install the gtirb package from Pypi.
9
#
10
# 2. Run ddisasm to disassemble a binary to GTIRB.
11
#
12
# $ echo 'main(){puts("hello world");}'|gcc -x c - -o /tmp/hello
13
# $ ddisasm /tmp/hello --ir /tmp/hello.gtirb
14
#
15
# 3. Execute the following command to run the program on the
16
# serialized GTIRB data.
17
#
18
# $ ./doc/examples/data-symbols.py /tmp/hello.gtirb
19
import
sys
20
21
import
gtirb
22
23
if
len(sys.argv) < 2:
24
print(f
"Usage: {sys.argv[0]} /path/to/file.gtirb"
)
25
quit(1)
26
27
ir = gtirb.ir.IR.load_protobuf(sys.argv[1])
28
29
for
m
in
ir.modules:
30
for
s
in
m.symbols:
31
ref = s.referent
32
if
isinstance(ref, gtirb.block.DataBlock):
33
print(s.name)
Generated by
1.8.17