5l -H7 (elf) support (import from sources)

This commit is contained in:
cinap_lenrek 2012-09-18 18:22:38 +02:00
parent 3ba213a9d7
commit a5756259cf
2 changed files with 67 additions and 0 deletions

View file

@ -80,6 +80,7 @@ asmb(void)
case 1:
case 2:
case 5:
case 7:
OFFSET = HEADR+textsize;
seek(cout, OFFSET, 0);
break;
@ -124,6 +125,8 @@ asmb(void)
OFFSET += rnd(datsize, 4096);
seek(cout, OFFSET, 0);
break;
case 7:
break;
}
if(!debug['s'])
asmsym();
@ -212,6 +215,60 @@ asmb(void)
lputl(0xe3300000); /* nop */
lputl(0xe3300000); /* nop */
break;
case 7: /* elf */
strnput("\177ELF", 4); /* e_ident */
cput(1); /* class = 32 bit */
cput(2); /* data = MSB */
cput(1); /* version = CURRENT */
strnput("", 9);
lput((2L<<16)|40); /* type = EXEC; machine = ARM */
lput(1L); /* version = CURRENT */
lput(entryvalue()); /* entry vaddr */
lput(52L); /* offset to first phdr */
debug['S'] = 1; /* no symbol table */
if(debug['S']){
lput(HEADR+textsize+datsize+symsize); /* offset to first shdr */
lput(0L); /* flags = PPC */
lput((52L<<16)|32L); /* Ehdr & Phdr sizes*/
lput((4L<<16)|40L); /* # Phdrs & Shdr size */
lput((4L<<16)|2L); /* # Shdrs & shdr string size */
}
else{
lput(0L);
lput(0L); /* flags = PPC */
lput((52L<<16)|32L); /* Ehdr & Phdr sizes*/
lput((4L<<16)|0L); /* # Phdrs & Shdr size */
lput((4L<<16)|0L); /* # Shdrs & shdr string size */
}
lput(1L); /* text - type = PT_LOAD */
lput(HEADR); /* file offset */
lput(INITTEXT); /* vaddr */
lput(INITTEXT); /* paddr */
lput(textsize); /* file size */
lput(textsize); /* memory size */
lput(0x05L); /* protections = RX */
lput(0); /* alignment */
lput(1L); /* data - type = PT_LOAD */
lput(HEADR+textsize); /* file offset */
lput(INITDAT); /* vaddr */
lput(INITDAT); /* paddr */
lput(datsize); /* file size */
lput(datsize+bsssize); /* memory size */
lput(0x07L); /* protections = RWX */
lput(0); /* alignment */
lput(0L); /* data - type = PT_NULL */
lput(HEADR+textsize+datsize); /* file offset */
lput(0L); /* vaddr */
lput(0L); /* paddr */
lput(symsize); /* symbol table size */
lput(lcsize); /* line number size */
lput(0x04L); /* protections = R */
lput(0x04L); /* alignment code?? */
break;
}
cflush();
}

View file

@ -19,6 +19,7 @@ char *thestring = "arm";
* -H4 is IXP1200 (raw)
* -H5 -T0xC0008010 -R1024 is ipaq
* -H6 -R4096 no header with segments padded to pages
* -H7 is elf
*/
static int
@ -183,6 +184,15 @@ main(int argc, char *argv[])
if(INITRND == -1)
INITRND = 1024;
break;
case 7: /* elf executable */
HEADR = rnd(52L+3*32L, 16);
if(INITTEXT == -1)
INITTEXT = 4096+HEADR;
if(INITDAT == -1)
INITDAT = 0;
if(INITRND == -1)
INITRND = 4;
break;
}
if(INITDAT != 0 && INITRND != 0)
print("warning: -D0x%lux is ignored because of -R0x%lux\n",