MCPcopy Create free account
hub / github.com/lief-project/LIEF / print_sections

Function print_sections

api/python/examples/elf_reader.py:100–120  ·  view source on GitHub ↗
(binary)

Source from the content-addressed store, hash-verified

98
99@exceptions_handler(Exception)
100def print_sections(binary):
101 sections = binary.sections
102 if len(sections) > 0:
103 print("== Sections ==\n")
104 f_title = "|{:<30} | {:<12}| {:<17}| {:<12}| {:<10}| {:<8}| {:<8}|"
105 f_value = "|{:<30} | {:<12}| 0x{:<14x} | 0x{:<10x}| 0x{:<8x}| {:<8.2f}| {:<10}"
106 print(f_title.format("Name", "Type", "Virtual address", "File offset", "Size", "Entropy", "Segment(s)"))
107
108 for section in sections:
109 segments_str = " - ".join([str(s.type).split(".")[-1] for s in section.segments])
110 print(f_value.format(
111 section.name,
112 str(section.type).split(".")[-1],
113 section.virtual_address,
114 section.file_offset,
115 section.size,
116 abs(section.entropy),
117 segments_str))
118 print("")
119 else:
120 print("No sections")
121
122@exceptions_handler(Exception)
123def print_segments(binary):

Callers 1

mainFunction · 0.70

Calls 2

printFunction · 0.50
formatMethod · 0.45

Tested by

no test coverage detected