Bintool contains separate functions for ELF and BIN files, which use a lot of duplicated code. Refactor this to reduce the duplication.