From: Eli Bendersky Date: Fri, 16 Sep 2011 13:59:52 +0000 (+0300) Subject: started adding command-line options to readelf X-Git-Tag: v0.10~120 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=40eb170eb2107610c3c73d40fa38645610f17bb5;p=pyelftools.git started adding command-line options to readelf --- diff --git a/scripts/readelf.py b/scripts/readelf.py index c7f0a8f..91b3637 100755 --- a/scripts/readelf.py +++ b/scripts/readelf.py @@ -291,9 +291,28 @@ class ReadElf(object): def main(): - optparser = OptionParser() + optparser = OptionParser( + add_help_option=False, # -h is a real option of readelf + prog='readelf.py') + optparser.add_option('-H', '--help', + action='store_true', dest='help', + help='Display this information') + optparser.add_option('-h', '--file-header', + action='store_true', dest='show_file_header') + optparser.add_option('-l', '--program-headers', '--segments', + action='store_true', dest='show_program_headers') + optparser.add_option('-S', '--section-headers', '--sections', + action='store_true', dest='show_section_headers') + optparser.add_option('-e', '--headers', + action='store_true', dest='show_all_headers') + optparser.add_option('-s', '--symbols', '--syms', + action='store_true', dest='show_symbols') options, args = optparser.parse_args() + if options.help or len(args) == 0: + optparser.print_help() + sys.exit(0) + with open(args[0], 'rb') as file: try: readelf = ReadElf(file, sys.stdout)