1
0
mirror of https://github.com/golang/go synced 2024-11-26 00:57:56 -07:00

mode elf tossing

SVN=121962
This commit is contained in:
Ken Thompson 2008-06-10 12:42:37 -07:00
parent 4ff63a4794
commit 36f21e00f5
2 changed files with 86 additions and 64 deletions

View File

@ -1154,10 +1154,10 @@ optoas(int op, Type *t)
case CASE(OEQ, TUINT32): case CASE(OEQ, TUINT32):
case CASE(OEQ, TINT64): case CASE(OEQ, TINT64):
case CASE(OEQ, TUINT64): case CASE(OEQ, TUINT64):
case CASE(OEQ, TFLOAT32):
case CASE(OEQ, TFLOAT64):
case CASE(OEQ, TPTR32): case CASE(OEQ, TPTR32):
case CASE(OEQ, TPTR64): case CASE(OEQ, TPTR64):
case CASE(OEQ, TFLOAT32):
case CASE(OEQ, TFLOAT64):
a = AJEQ; a = AJEQ;
break; break;
@ -1170,10 +1170,10 @@ optoas(int op, Type *t)
case CASE(ONE, TUINT32): case CASE(ONE, TUINT32):
case CASE(ONE, TINT64): case CASE(ONE, TINT64):
case CASE(ONE, TUINT64): case CASE(ONE, TUINT64):
case CASE(ONE, TFLOAT32):
case CASE(ONE, TFLOAT64):
case CASE(ONE, TPTR32): case CASE(ONE, TPTR32):
case CASE(ONE, TPTR64): case CASE(ONE, TPTR64):
case CASE(ONE, TFLOAT32):
case CASE(ONE, TFLOAT64):
a = AJNE; a = AJNE;
break; break;
@ -1181,8 +1181,6 @@ optoas(int op, Type *t)
case CASE(OLT, TINT16): case CASE(OLT, TINT16):
case CASE(OLT, TINT32): case CASE(OLT, TINT32):
case CASE(OLT, TINT64): case CASE(OLT, TINT64):
case CASE(OLT, TFLOAT32):
case CASE(OLT, TFLOAT64):
a = AJLT; a = AJLT;
break; break;
@ -1190,6 +1188,8 @@ optoas(int op, Type *t)
case CASE(OLT, TUINT16): case CASE(OLT, TUINT16):
case CASE(OLT, TUINT32): case CASE(OLT, TUINT32):
case CASE(OLT, TUINT64): case CASE(OLT, TUINT64):
case CASE(OGE, TFLOAT32):
case CASE(OGE, TFLOAT64):
a = AJCS; a = AJCS;
break; break;
@ -1197,8 +1197,6 @@ optoas(int op, Type *t)
case CASE(OLE, TINT16): case CASE(OLE, TINT16):
case CASE(OLE, TINT32): case CASE(OLE, TINT32):
case CASE(OLE, TINT64): case CASE(OLE, TINT64):
case CASE(OLE, TFLOAT32):
case CASE(OLE, TFLOAT64):
a = AJLE; a = AJLE;
break; break;
@ -1206,6 +1204,8 @@ optoas(int op, Type *t)
case CASE(OLE, TUINT16): case CASE(OLE, TUINT16):
case CASE(OLE, TUINT32): case CASE(OLE, TUINT32):
case CASE(OLE, TUINT64): case CASE(OLE, TUINT64):
case CASE(OGT, TFLOAT32):
case CASE(OGT, TFLOAT64):
a = AJLS; a = AJLS;
break; break;
@ -1213,8 +1213,6 @@ optoas(int op, Type *t)
case CASE(OGT, TINT16): case CASE(OGT, TINT16):
case CASE(OGT, TINT32): case CASE(OGT, TINT32):
case CASE(OGT, TINT64): case CASE(OGT, TINT64):
case CASE(OGT, TFLOAT32):
case CASE(OGT, TFLOAT64):
a = AJGT; a = AJGT;
break; break;
@ -1222,6 +1220,8 @@ optoas(int op, Type *t)
case CASE(OGT, TUINT16): case CASE(OGT, TUINT16):
case CASE(OGT, TUINT32): case CASE(OGT, TUINT32):
case CASE(OGT, TUINT64): case CASE(OGT, TUINT64):
case CASE(OLE, TFLOAT32):
case CASE(OLE, TFLOAT64):
a = AJHI; a = AJHI;
break; break;
@ -1229,8 +1229,6 @@ optoas(int op, Type *t)
case CASE(OGE, TINT16): case CASE(OGE, TINT16):
case CASE(OGE, TINT32): case CASE(OGE, TINT32):
case CASE(OGE, TINT64): case CASE(OGE, TINT64):
case CASE(OGE, TFLOAT32):
case CASE(OGE, TFLOAT64):
a = AJGE; a = AJGE;
break; break;
@ -1238,6 +1236,8 @@ optoas(int op, Type *t)
case CASE(OGE, TUINT16): case CASE(OGE, TUINT16):
case CASE(OGE, TUINT32): case CASE(OGE, TUINT32):
case CASE(OGE, TUINT64): case CASE(OGE, TUINT64):
case CASE(OLT, TFLOAT32):
case CASE(OLT, TFLOAT64):
a = AJCC; a = AJCC;
break; break;

View File

@ -120,10 +120,10 @@ void
asmb(void) asmb(void)
{ {
Prog *p; Prog *p;
long v, magic, w; long v, magic;
int a; int a;
uchar *op1; uchar *op1;
vlong vl, va; vlong vl, va, fo, w;
if(debug['v']) if(debug['v'])
Bprint(&bso, "%5.2f asmb\n", cputime()); Bprint(&bso, "%5.2f asmb\n", cputime());
@ -166,6 +166,8 @@ asmb(void)
cbc -= a; cbc -= a;
} }
cflush(); cflush();
switch(HEADTYPE) { switch(HEADTYPE) {
default: default:
diag("unknown header type %ld", HEADTYPE); diag("unknown header type %ld", HEADTYPE);
@ -183,9 +185,10 @@ asmb(void)
} }
cflush(); cflush();
break; break;
case 7: case 7:
v = rnd(HEADR+textsize, INITRND); v = rnd(HEADR+textsize, INITRND);
seek(cout, v, 0); myseek(cout, v);
break; break;
} }
@ -402,23 +405,31 @@ debug['s'] = 1;
wputl(5); /* # of Shdrs */ wputl(5); /* # of Shdrs */
wputl(4); /* Shdr with strings */ wputl(4); /* Shdr with strings */
fo = 0;
va = INITRND;
w = HEADR+textsize;
linuxphdr(1, /* text - type = PT_LOAD */ linuxphdr(1, /* text - type = PT_LOAD */
1L+4L, /* text - flags = PF_X+PF_R */ 1L+4L, /* text - flags = PF_X+PF_R */
HEADR, /* file offset */ 0, /* file offset */
INITTEXT, /* vaddr */ va, /* vaddr */
INITTEXT, /* paddr */ va, /* paddr */
textsize, /* file size */ w, /* file size */
textsize, /* memory size */ w, /* memory size */
INITRND); /* alignment */ INITRND); /* alignment */
v = rnd(HEADR+textsize, INITRND); fo = rnd(fo+w, INITRND);
va = rnd(va+w, INITRND);
w = datsize;
linuxphdr(1, /* data - type = PT_LOAD */ linuxphdr(1, /* data - type = PT_LOAD */
1L+2L+4L, /* data - flags = PF_X+PF_W+PF_R */ 2L+4L, /* data - flags = PF_W+PF_R */
v, /* file offset */ fo, /* file offset */
INITDAT, /* vaddr */ va, /* vaddr */
INITDAT, /* paddr */ va, /* paddr */
datsize, /* file size */ w, /* file size */
datsize+bsssize, /* memory size */ w+bsssize, /* memory size */
INITRND); /* alignment */ INITRND); /* alignment */
linuxphdr(0x6474e551, /* gok - type = gok */ linuxphdr(0x6474e551, /* gok - type = gok */
@ -441,69 +452,80 @@ debug['s'] = 1;
0, /* align */ 0, /* align */
0); /* entsize */ 0); /* entsize */
stroffset = 1; stroffset = 1;
v = HEADR; fo = 0;
va = INITRND;
w = HEADR+textsize;
linuxshdr(".text", /* name */ linuxshdr(".text", /* name */
1, /* type */ 1, /* type */
6, /* flags */ 6, /* flags */
INITTEXT, /* addr */ va, /* addr */
v, /* off */ fo, /* off */
textsize, /* size */ w, /* size */
0, /* link */ 0, /* link */
0, /* info */ 0, /* info */
4, /* align */ 8, /* align */
0); /* entsize */ 0); /* entsize */
v += textsize; fo = rnd(fo+w, INITRND);
va = rnd(va+w, INITRND);
w = datsize;
linuxshdr(".data", /* name */ linuxshdr(".data", /* name */
1, /* type */ 1, /* type */
3, /* flags */ 3, /* flags */
INITDAT, /* addr */ va, /* addr */
v, /* off */ fo, /* off */
datsize, /* size */ w, /* size */
0, /* link */ 0, /* link */
0, /* info */ 0, /* info */
4, /* align */ 8, /* align */
0); /* entsize */ 0); /* entsize */
v += datsize; fo += w;
va += w;
w = bsssize;
linuxshdr(".bss", /* name */ linuxshdr(".bss", /* name */
8, /* type */ 8, /* type */
3, /* flags */ 3, /* flags */
INITDAT, /* addr */ va, /* addr */
v, /* off */ fo, /* off */
bsssize, /* size */ w, /* size */
0, /* link */ 0, /* link */
0, /* info */ 0, /* info */
4, /* align */ 8, /* align */
0); /* entsize */ 0); /* entsize */
v += 0; fo = HEADR+textsize+datsize;
va = stroffset + w = stroffset +
strlen(".shstrtab")+1 + strlen(".shstrtab")+1;
strlen(".gosymtab")+1; // strlen(".gosymtab")+1;
linuxshdr(".shstrtab", /* name */ linuxshdr(".shstrtab", /* name */
3, /* type */ 3, /* type */
0, /* flags */ 0, /* flags */
0, /* addr */ 0, /* addr */
v, /* off */ fo, /* off */
va, /* size */ w, /* size */
0, /* link */ 0, /* link */
0, /* info */ 0, /* info */
4, /* align */ 8, /* align */
0); /* entsize */ 0); /* entsize */
v += va; //fo += w;
linuxshdr(".gosymtab", /* name */ //
2, /* type */ // linuxshdr(".gosymtab", /* name */
0, /* flags */ // 2, /* type */
0, /* addr */ // 0, /* flags */
v, /* off */ // 0, /* addr */
0, /* size */ // fo, /* off */
0, /* link */ // 0, /* size */
0, /* info */ // 0, /* link */
4, /* align */ // 0, /* info */
0); /* entsize */ // 8, /* align */
// 0); /* entsize */
break; break;
} }
cflush(); cflush();
@ -775,7 +797,7 @@ linuxheadr(void)
a += 64; /* .data seg */ a += 64; /* .data seg */
a += 64; /* .bss sect */ a += 64; /* .bss sect */
a += 64; /* .shstrtab sect - strings for headers */ a += 64; /* .shstrtab sect - strings for headers */
a += 64; /* .gosymtab sect */ // a += 64; /* .gosymtab sect */
return a; return a;
} }
@ -831,6 +853,6 @@ linuxstrtable(void)
strnput(name, strlen(name)+1); strnput(name, strlen(name)+1);
name = ".shstrtab"; name = ".shstrtab";
strnput(name, strlen(name)+1); strnput(name, strlen(name)+1);
name = ".gosymtab"; // name = ".gosymtab";
strnput(name, strlen(name)+1); // strnput(name, strlen(name)+1);
} }