1
Fork 0
oelf/crates/goblin-pyo3/test.py

42 lines
804 B
Python
Raw Normal View History

2023-12-08 15:41:25 +00:00
import goblin
g = goblin.Object("mylib.dylib")
print(g.header)
print(g.name)
print("symbols")
2023-12-08 22:27:18 +00:00
globsym = None
start = -1
end = 9999999999
for sym in g.symbols():
if "META" in sym.name and sym.is_global:
if globsym is None:
globsym = sym
start = sym.meta.n_value
2023-12-08 15:41:25 +00:00
for sym in g.symbols():
2023-12-08 22:27:18 +00:00
if sym.meta.n_value > start and sym.meta.n_value < end:
print(f"sym after the found one: {sym}")
end = sym.meta.n_value
print(f"found symbol {globsym.name} from {start} to {end}, size: {end-start}")
print(globsym)
2023-12-08 15:41:25 +00:00
print("libs")
print(g.libs)
print("rpaths")
print(g.rpaths)
print("exports")
print(len(g.exports()))
print("imports")
print(len(g.imports()))
2023-12-08 16:28:36 +00:00
print("sections")
2023-12-08 22:27:18 +00:00
for idx, section in enumerate(g.sections()):
print(f"{idx+1}. {section}")