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

Function print_notes

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

Source from the content-addressed store, hash-verified

378
379@exceptions_handler(Exception)
380def print_notes(binary):
381 print("== Notes ==\n")
382
383 format_str = "{:<19} {}"
384 format_hex = "{:<19} 0x{:<28x}"
385 format_dec = "{:<19} {:<30d}"
386
387 notes = binary.notes
388 for idx, note in enumerate(notes):
389 description = note.description
390 description_str = " ".join(map(lambda e : "{:02x}".format(e), description[:16]))
391 if len(description) > 16:
392 description_str += " ..."
393
394 print("Note #{:d}".format(idx))
395
396 type_str = note.type_core if note.is_core else note.type
397 type_str = str(type_str).split(".")[-1]
398
399 print(format_str.format("Name:", note.name))
400 print(format_str.format("Type:", type_str))
401 print(format_str.format("Description:", description_str))
402
403 note_details = note.details
404
405 if isinstance(note_details, lief.ELF.AndroidIdent):
406 print(format_dec.format("SDK Version:", note_details.sdk_version))
407 print(format_str.format("NDK Version:", note_details.ndk_version))
408 print(format_str.format("NDK build number:", note_details.ndk_build_number))
409
410 if isinstance(note_details, lief.ELF.NoteAbi):
411 version = note_details.version
412 version_str = "{:d}.{:d}.{:d}".format(version[0], version[1], version[2])
413
414 print(format_str.format("ABI:", note_details.abi))
415 print(format_str.format("Version:", version_str))
416
417 if note.type == ELF.Note.TYPE.GNU_GOLD_VERSION:
418 print(format_str.format("Version:", "".join(map(chr, note.description))))
419
420 if note.is_core:
421 print(note_details)
422
423
424 print("\n")
425
426
427@exceptions_handler(Exception)

Callers 1

mainFunction · 0.85

Calls 3

mapClass · 0.85
printFunction · 0.50
formatMethod · 0.45

Tested by

no test coverage detected