mips332.c
604 Bytes
#include <stdlib.h>
#include <stdio.h>
/* inplace rewrite the elf header of a 32-bit MSB mips binary to be the
* linux-mips equivalent of -mips2 (mips-3 + mips32 flags set) to
* reduce the number of linker conflicts
*/
int
main(int argc, char* argv[]) {
while(argc > 1) {
FILE* fd;
unsigned char buf[40];
if (!(fd = fopen(argv[1], "r+"))) {
perror(argv[1]);
exit(1);
}
fread(buf, sizeof buf, 1, fd);
buf[36] = 0x20;
buf[37] = 0x00;
buf[38] = 0x01;
buf[39] = 0x01;
fseek(fd, 0, SEEK_SET);
fwrite(buf, sizeof buf, 1, fd);
fclose(fd);
argc--; argv++;
}
return 0;
}