Created
December 17, 2019 17:21
-
-
Save Jongy/30de14fa02474924c70856e030b9b33c to your computer and use it in GitHub Desktop.
Simple Python implementation of "modinfo"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import subprocess | |
import tempfile | |
def get_modinfo(module): | |
with tempfile.NamedTemporaryFile("r") as tf: | |
subprocess.check_call(["objcopy", "-O", "binary", "--only-section=.modinfo", module, tf.name]) | |
modinfo = tf.read() | |
return filter(lambda item: len(item) == 2, [item.split('=', 1) for item in modinfo.split('\0')]) | |
def main(argv): | |
if len(argv) != 2: | |
print("usage: {} module".format(argv[0])) | |
modinfo = get_modinfo(argv[1]) | |
for item in modinfo: | |
type_, value = item | |
print(type_, "=", value) | |
if __name__ == "__main__": | |
main(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment