1
0
Files
irix-657m-src/stand/arcs/IP32prom/tools/force_mips2.c
2022-09-29 17:59:04 +03:00

31 lines
584 B
C

#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <stddef.h>
#include <elf.h>
/*
* Hack to force the type of a .o file to -mips2
*/
int main(int argc, char** argv){
int fd;
long flags;
off_t offset = offsetof(Elf32_Ehdr,e_flags);
if (argc!=2)
return 1;
fd = open(argv[1],O_RDWR);
if (fd<0)
return 1;
lseek(fd,offset,SEEK_SET);
if (read(fd,&flags,sizeof(flags)!=sizeof(flags)))
return 1;
lseek(fd,offset,SEEK_SET);
flags = (flags & ~EF_MIPS_ARCH) | EF_MIPS_ARCH_2;
write(fd,&flags,sizeof(flags));
close(fd);
return 0;
}