|| ELF Header ;jm;73;00;00;00 jump to start of first pass ;'i;'n;'0;'2;00 (0x40007d) input filename ;'o;'u;'t;'0;'2;00 (0x400082) output filename ;00;00;' ;'n;'o;'t;' ;'r;'e;'c;'o;'g;'n;'i;'z;'e;'d;\n;00;00;00;00;00;00 (0x400088) error message/where we read to ;00 (0x4000a0) stores which pass we're on (0 for first pass, 1 for second pass) ;00;00;00;00;00;00;00 ;00;00;00;00;00;00;00;00 (0x4000a8) used for output unused padding ;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00 ;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00 ;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00 ;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00 -- code starts here (0x4000f0) ;im;7d;00;40;00;00;00;00;00 pointer to input filename ;JA ;zA O_RDONLY ;IA ;im;02;00;00;00;00;00;00;00 open ;sy ;im;82;00;40;00;00;00;00;00 pointer to output filename ;JA ;im;41;02;00;00;00;00;00;00 O_WRONLY | O_CREAT | O_TRUNC ;IA ;im;ed;01;00;00;00;00;00;00 0o755 ;DA ;im;02;00;00;00;00;00;00;00 open ;sy -- second pass starts here -- begin by writing the elf header. the segment we're loading in includes the ELF header at address 0x400000, so we can just read it from there ;im;04;00;00;00;00;00;00;00 out fd ;JA ;im;00;00;40;00;00;00;00;00 pointer to ELF header ;IA ;im;78;00;00;00;00;00;00;00 length of ELF header ;DA ;im;01;00;00;00;00;00;00;00 write ;sy -- read command (0x400174) -- ;im;03;00;00;00;00;00;00;00 input file descriptor ;JA ;im;88;00;40;00;00;00;00;00 where to read to ;IA ;im;02;00;00;00;00;00;00;00 read 2 bytes ;DA ;zA read ;sy ;BA ;im;02;00;00;00;00;00;00;00 ;cm;jn;61;07;00;00 end of file look at first byte of command ;im;88;00;40;00;00;00;00;00 ;BA ;zA;lb ;