1
0
mirror of https://github.com/golang/go synced 2024-11-25 12:47:56 -07:00

cmd/6l: Fixes for 64-bit Plan 9

Plan 9 versions for amd64 have 2 megabyte pages.
This also fixes the logic for 32-bit vs 64-bit Plan 9,
making 64-bit the default, and adds logic to generate
a symbols table.

R=golang-dev, rsc, rminnich, ality, 0intro
CC=golang-dev, john
https://golang.org/cl/6218046
This commit is contained in:
Akshat Kumar 2012-05-29 12:32:42 -04:00 committed by Russ Cox
parent fefae6eed1
commit 154c84cdac
4 changed files with 33 additions and 13 deletions

View File

@ -715,7 +715,8 @@ asmb(void)
ElfPhdr *ph, *pph;
ElfShdr *sh;
Section *sect;
int o;
Sym *sym;
int i, o;
if(debug['v'])
Bprint(&bso, "%5.2f asmb\n", cputime());
@ -763,6 +764,7 @@ asmb(void)
default:
diag("unknown header type %d", HEADTYPE);
case Hplan9x32:
case Hplan9x64:
case Helf:
break;
case Hdarwin:
@ -798,7 +800,7 @@ asmb(void)
Bflush(&bso);
switch(HEADTYPE) {
default:
case Hplan9x32:
case Hplan9x64:
case Helf:
debug['s'] = 1;
symo = HEADR+segtext.len+segdata.filelen;
@ -833,6 +835,19 @@ asmb(void)
dwarfemitdebugsections();
}
break;
case Hplan9x64:
asmplan9sym();
cflush();
sym = lookup("pclntab", 0);
if(sym != nil) {
lcsize = sym->np;
for(i=0; i < lcsize; i++)
cput(sym->p[i]);
cflush();
}
break;
case Hwindows:
if(debug['v'])
Bprint(&bso, "%5.2f dwarf\n", cputime());
@ -848,7 +863,7 @@ asmb(void)
cseek(0L);
switch(HEADTYPE) {
default:
case Hplan9x32: /* plan9 */
case Hplan9x64: /* plan9 */
magic = 4*26*26+7;
magic |= 0x00008000; /* fat header */
lputb(magic); /* magic */
@ -862,7 +877,7 @@ asmb(void)
lputb(lcsize); /* line offsets */
vputb(vl); /* va of entry */
break;
case Hplan9x64: /* plan9 */
case Hplan9x32: /* plan9 */
magic = 4*26*26+7;
lputb(magic); /* magic */
lputb(segtext.filelen); /* sizes */

View File

@ -58,8 +58,8 @@ Header headers[] = {
};
/*
* -Hplan9x32 -T4136 -R4096 is plan9 64-bit format
* -Hplan9 -T4128 -R4096 is plan9 32-bit format
* -Hplan9x32 -T4128 -R4096 is plan9 32-bit format
* -Hplan9 -T0x200028 -R0x200000 is plan9 64-bit format
* -Helf -T0x80110000 -R4096 is ELF32
* -Hdarwin -Tx -Rx is apple MH-exec
* -Hlinux -Tx -Rx is linux elf-exec
@ -164,7 +164,7 @@ main(int argc, char *argv[])
diag("unknown -H option");
errorexit();
case Hplan9x32: /* plan 9 */
HEADR = 32L+8L;
HEADR = 32L;
if(INITTEXT == -1)
INITTEXT = 4096+HEADR;
if(INITDAT == -1)
@ -173,13 +173,13 @@ main(int argc, char *argv[])
INITRND = 4096;
break;
case Hplan9x64: /* plan 9 */
HEADR = 32L;
HEADR = 32L + 8L;
if(INITTEXT == -1)
INITTEXT = 4096+32;
INITTEXT = 0x200000+HEADR;
if(INITDAT == -1)
INITDAT = 0;
if(INITRND == -1)
INITRND = 4096;
INITRND = 0x200000;
break;
case Helf: /* elf32 executable */
HEADR = rnd(52L+3*32L, 16);

View File

@ -1058,7 +1058,7 @@ address(void)
segdata.filelen = 0;
if(HEADTYPE == Hwindows)
segdata.fileoff = segtext.fileoff + rnd(segtext.len, PEFILEALIGN);
if(HEADTYPE == Hplan9x32)
if(HEADTYPE == Hplan9x64 || HEADTYPE == Hplan9x32)
segdata.fileoff = segtext.fileoff + segtext.filelen;
data = nil;
noptr = nil;

View File

@ -125,7 +125,7 @@ asmelfsym(void)
static void
putplan9sym(Sym *x, char *s, int t, vlong addr, vlong size, int ver, Sym *go)
{
int i;
int i, l;
USED(go);
USED(ver);
@ -144,6 +144,11 @@ putplan9sym(Sym *x, char *s, int t, vlong addr, vlong size, int ver, Sym *go)
case 'z':
case 'Z':
case 'm':
l = 4;
if(HEADTYPE == Hplan9x64 && !debug['8']) {
lputb(addr>>32);
l = 8;
}
lputb(addr);
cput(t+0x80); /* 0x80 is variable length */
@ -164,7 +169,7 @@ putplan9sym(Sym *x, char *s, int t, vlong addr, vlong size, int ver, Sym *go)
cput(s[i]);
cput(0);
}
symsize += 4 + 1 + i + 1;
symsize += l + 1 + i + 1;
break;
default:
return;