diff options
Diffstat (limited to 'utils/6l/asm.c')
| -rw-r--r-- | utils/6l/asm.c | 79 |
1 files changed, 17 insertions, 62 deletions
diff --git a/utils/6l/asm.c b/utils/6l/asm.c index c4d46633..a4afaa2a 100644 --- a/utils/6l/asm.c +++ b/utils/6l/asm.c @@ -2,7 +2,7 @@ #define Dbufslop 100 -#define PADDR(a) ((ulong)(a) & ~0x80000000) +#define PADDR(a) ((a) & ~0xfffffffff0000000ull) vlong entryvalue(void) @@ -28,15 +28,15 @@ entryvalue(void) return s->value; } -void -wputl(ushort w) +/* these need to take long arguments to be compatible with elf.c */void +wputl(long w) { cput(w); cput(w>>8); } void -wput(ushort w) +wput(long w) { cput(w>>8); cput(w); @@ -68,6 +68,13 @@ lputl(long l) } void +llputl(vlong v) +{ + lputl(v); + lputl(v>>32); +} + +void strnput(char *s, int n) { for(; *s && n > 0; s++){ @@ -133,6 +140,7 @@ asmb(void) diag("unknown header type %ld", HEADTYPE); case 2: case 5: + case 6: seek(cout, HEADR+textsize, 0); break; } @@ -166,6 +174,7 @@ asmb(void) default: case 2: case 5: + case 6: seek(cout, HEADR+textsize+datsize, 0); break; } @@ -210,65 +219,11 @@ asmb(void) lput(lcsize); /* line offsets */ llput(vl); /* va of entry */ break; - case 3: /* plan9 */ - magic = 4*26*26+7; - if(dlm) - magic |= 0x80000000; - lput(magic); /* magic */ - lput(textsize); /* sizes */ - lput(datsize); - lput(bsssize); - lput(symsize); /* nsyms */ - lput(entryvalue()); /* va of entry */ - lput(spsize); /* sp offsets */ - lput(lcsize); /* line offsets */ - break; case 5: - strnput("\177ELF", 4); /* e_ident */ - cput(1); /* class = 32 bit */ - cput(1); /* data = LSB */ - cput(1); /* version = CURRENT */ - strnput("", 9); - wputl(2); /* type = EXEC */ - wputl(62); /* machine = AMD64 */ - lputl(1L); /* version = CURRENT */ - lputl(PADDR(entryvalue())); /* entry vaddr */ - lputl(52L); /* offset to first phdr */ - lputl(0L); /* offset to first shdr */ - lputl(0L); /* processor specific flags */ - wputl(52); /* Ehdr size */ - wputl(32); /* Phdr size */ - wputl(3); /* # of Phdrs */ - wputl(0); /* Shdr size */ - wputl(0); /* # of Shdrs */ - wputl(0); /* Shdr string size */ - - lputl(1L); /* text - type = PT_LOAD */ - lputl(HEADR); /* file offset */ - lputl(INITTEXT); /* vaddr */ - lputl(PADDR(INITTEXT)); /* paddr */ - lputl(textsize); /* file size */ - lputl(textsize); /* memory size */ - lputl(0x05L); /* protections = RX */ - lputl(INITRND); /* alignment */ - - lputl(1L); /* data - type = PT_LOAD */ - lputl(HEADR+textsize); /* file offset */ - lputl(INITDAT); /* vaddr */ - lputl(PADDR(INITDAT)); /* paddr */ - lputl(datsize); /* file size */ - lputl(datsize+bsssize); /* memory size */ - lputl(0x06L); /* protections = RW */ - lputl(INITRND); /* alignment */ - - lputl(0L); /* data - type = PT_NULL */ - lputl(HEADR+textsize+datsize); /* file offset */ - lputl(0L); - lputl(0L); - lputl(symsize); /* symbol table size */ - lputl(lcsize); /* line number size */ - lputl(0x04L); /* protections = R */ - lputl(0x04L); /* alignment */ + elf32(debug['8']? I386: AMD64, ELFDATA2LSB, 0, nil); + break; + case 6: + elf64(AMD64, ELFDATA2LSB, 0, nil); break; } cflush(); |
