{simple,shoddy,smart} minsize-oriented linker
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
625 B

  1. #!/usr/bin/env python3
  2. import argparse
  3. import sys
  4. def main(argv):
  5. parser = argparse.ArgumentParser()
  6. # TODO: output null -> in-place!
  7. parser.add_argument('input', type=argparse.FileType('rb'), \
  8. help="input file to truncate")
  9. parser.add_argument('output', type=argparse.FileType('wb'), \
  10. help="output file")
  11. args = parser.parse_args()
  12. data = args.input.read()
  13. i = 0
  14. while data[-i - 1] == 0:
  15. i = i + 1
  16. args.output.write(data[0:len(data)-i])
  17. if __name__ == '__main__':
  18. rv = main(sys.argv)
  19. exit(0 if rv is None else rv)