summaryrefslogtreecommitdiff
path: root/sys/src/cmd/5l
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-09-18 18:22:38 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2012-09-18 18:22:38 +0200
commita5756259cf994e08b7bbac2a9591adab02f63d2b (patch)
tree5d79dc2f9a4b03c32a616672b5c7d3b9e4934b0b /sys/src/cmd/5l
parent3ba213a9d79bfe52f9a8aa6834c67eac665de136 (diff)
5l -H7 (elf) support (import from sources)
Diffstat (limited to 'sys/src/cmd/5l')
-rw-r--r--sys/src/cmd/5l/asm.c57
-rw-r--r--sys/src/cmd/5l/obj.c10
2 files changed, 67 insertions, 0 deletions
diff --git a/sys/src/cmd/5l/asm.c b/sys/src/cmd/5l/asm.c
index 1316dd909..dcc9a987b 100644
--- a/sys/src/cmd/5l/asm.c
+++ b/sys/src/cmd/5l/asm.c
@@ -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();
}
diff --git a/sys/src/cmd/5l/obj.c b/sys/src/cmd/5l/obj.c
index 162012842..55886c7dc 100644
--- a/sys/src/cmd/5l/obj.c
+++ b/sys/src/cmd/5l/obj.c
@@ -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",