ref: d6c040cd74e1ec8c18df62508571040675c5950f
parent: f4ba2dfd7b806f4ddd2dd5dbba478aa33ebe0274
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Tue Sep 18 14:22:38 EDT 2012
5l -H7 (elf) support (import from sources)
--- a/sys/src/cmd/5l/asm.c
+++ b/sys/src/cmd/5l/asm.c
@@ -80,6 +80,7 @@
case 1:
case 2:
case 5:
+ case 7:
OFFSET = HEADR+textsize;
seek(cout, OFFSET, 0);
break;
@@ -124,6 +125,8 @@
OFFSET += rnd(datsize, 4096);
seek(cout, OFFSET, 0);
break;
+ case 7:
+ break;
}
if(!debug['s'])
asmsym();
@@ -211,6 +214,60 @@
lputl(0xe3300000); /* nop */
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();
--- a/sys/src/cmd/5l/obj.c
+++ b/sys/src/cmd/5l/obj.c
@@ -19,6 +19,7 @@
* -H4 is IXP1200 (raw)
* -H5 -T0xC0008010 -R1024 is ipaq
* -H6 -R4096 no header with segments padded to pages
+ * -H7 is elf
*/
static int
@@ -182,6 +183,15 @@
INITDAT = 0;
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)
--
⑨