papermario/tools/patch_64bit_compile.py
AltoXorg b171712e0e
Match libultra iQue ver (#1111)
* match libultra ique pt 1

* add sgidefs.h to include/gcc

* recvmesg match + _getcount

* add elfpatch.py for those compiled with -mips3

* pt 2

* os/setthreadpri(.data) -> os/thread

* os thread matches

* os timer matches

* pt 4 (erm... 3?)

* vitbl

* os pi matches

* pt. uhmmmm, i've lost track...

* os pfs matches

* replace elfpatch.py

* pt. just forget it...

* outsource from ultralib ique branch

* .

* . 2

* final blow

* add egcs compiler to Jenkinsfile

* fix errors from CI

* minor changes as requested
2023-08-17 02:29:21 +09:00

24 lines
677 B
Python

#!/usr/bin/env python3
import argparse, struct, sys
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("file", help="file to patch")
args = parser.parse_args()
with open(args.file, "r+b") as f:
magic = struct.unpack(">I", f.read(4))[0]
if magic != 0x7F454C46:
print("Error: Not an ELF file")
sys.exit(1)
f.seek(36)
flags = struct.unpack(">I", f.read(4))[0]
if flags & 0xF0000000 == 0x20000000: # test for mips3
# patch it
flags |= 0x00000100 # set EF_MIPS_32BITMODE
f.seek(36)
f.write(struct.pack(">I", flags))