Commit 9baaa6f7 authored by Lucio De Re's avatar Lucio De Re Committed by Russ Cox

8l, ld: Initial adjustments for Plan 9 native compilation of 8l

These changes are not particularly invasive and have been tested
as broadly as possible.

8l/l.h:
  -	#pragma varargck: added some, removed duplicates.

ld/dwarf.c:
  -	As Plan 9 has no NULL, changed all occurrences to nil.
  -	Added USED(size); where necessary.
  -	Added (void) argument in definition of finddebugruntimepath().
  -	Plan 9 compiler was complaining about multiple
        assignments, repeaired by breaking up the commands.
  -	Correction: havedynamic = 1; restored.

ld/go.c:
  -	Needed USED(file); in two functions.
  -	Removed unused assignments flagged by the Plan 9 compiler.

ld/lib.c:
  -	Replaced unlink() with remove() which seems available everywhere.
  -	Removed USED(c4); and USED(magic) no longer required.
  -	Removed code flagged as unused by the Plan 9 compiler.
  -	Added attributes to a number of format strings.

R=rsc
CC=golang-dev
https://golang.org/cl/4435047
parent ab8ed7f8
...@@ -260,11 +260,15 @@ EXTERN union ...@@ -260,11 +260,15 @@ EXTERN union
#define cbuf u.obuf #define cbuf u.obuf
#define xbuf u.ibuf #define xbuf u.ibuf
#pragma varargck type "A" uint #pragma varargck type "A" int
#pragma varargck type "D" Adr* #pragma varargck type "D" Adr*
#pragma varargck type "I" int
#pragma varargck type "I" uchar*
#pragma varargck type "P" Prog* #pragma varargck type "P" Prog*
#pragma varargck type "R" int #pragma varargck type "R" int
#pragma varargck type "S" char* #pragma varargck type "S" char*
#pragma varargck type "Y" Sym*
#pragma varargck type "i" char*
EXTERN int32 HEADR; EXTERN int32 HEADR;
EXTERN int32 HEADTYPE; EXTERN int32 HEADTYPE;
...@@ -383,11 +387,6 @@ void deadcode(void); ...@@ -383,11 +387,6 @@ void deadcode(void);
#define WPUT(a) wputl(a) #define WPUT(a) wputl(a)
#define VPUT(a) vputl(a) #define VPUT(a) vputl(a)
#pragma varargck type "D" Adr*
#pragma varargck type "P" Prog*
#pragma varargck type "R" int
#pragma varargck type "A" int
/* Used by ../ld/dwarf.c */ /* Used by ../ld/dwarf.c */
enum enum
{ {
......
...@@ -1348,7 +1348,7 @@ synthesizemaptypes(DWDie *die) ...@@ -1348,7 +1348,7 @@ synthesizemaptypes(DWDie *die)
valtype = defptrto(valtype); valtype = defptrto(valtype);
newrefattr(fld, DW_AT_type, valtype); newrefattr(fld, DW_AT_type, valtype);
newmemberoffsetattr(fld, hashsize + datavo); newmemberoffsetattr(fld, hashsize + datavo);
newattr(dwhe, DW_AT_byte_size, DW_CLS_CONSTANT, hashsize + datsize, NULL); newattr(dwhe, DW_AT_byte_size, DW_CLS_CONSTANT, hashsize + datsize, nil);
// Construct hash_subtable<hash_entry<K,V>> // Construct hash_subtable<hash_entry<K,V>>
dwhs = newdie(&dwtypes, DW_ABRV_STRUCTTYPE, dwhs = newdie(&dwtypes, DW_ABRV_STRUCTTYPE,
...@@ -1359,7 +1359,7 @@ synthesizemaptypes(DWDie *die) ...@@ -1359,7 +1359,7 @@ synthesizemaptypes(DWDie *die)
substitutetype(dwhs, "end", defptrto(dwhe)); substitutetype(dwhs, "end", defptrto(dwhe));
substitutetype(dwhs, "entry", dwhe); // todo: []hash_entry with dynamic size substitutetype(dwhs, "entry", dwhe); // todo: []hash_entry with dynamic size
newattr(dwhs, DW_AT_byte_size, DW_CLS_CONSTANT, newattr(dwhs, DW_AT_byte_size, DW_CLS_CONSTANT,
getattr(hash_subtable, DW_AT_byte_size)->value, NULL); getattr(hash_subtable, DW_AT_byte_size)->value, nil);
// Construct hash<K,V> // Construct hash<K,V>
dwh = newdie(&dwtypes, DW_ABRV_STRUCTTYPE, dwh = newdie(&dwtypes, DW_ABRV_STRUCTTYPE,
...@@ -1369,7 +1369,7 @@ synthesizemaptypes(DWDie *die) ...@@ -1369,7 +1369,7 @@ synthesizemaptypes(DWDie *die)
copychildren(dwh, hash); copychildren(dwh, hash);
substitutetype(dwh, "st", defptrto(dwhs)); substitutetype(dwh, "st", defptrto(dwhs));
newattr(dwh, DW_AT_byte_size, DW_CLS_CONSTANT, newattr(dwh, DW_AT_byte_size, DW_CLS_CONSTANT,
getattr(hash, DW_AT_byte_size)->value, NULL); getattr(hash, DW_AT_byte_size)->value, nil);
newrefattr(die, DW_AT_type, defptrto(dwh)); newrefattr(die, DW_AT_type, defptrto(dwh));
} }
...@@ -1401,30 +1401,30 @@ synthesizechantypes(DWDie *die) ...@@ -1401,30 +1401,30 @@ synthesizechantypes(DWDie *die)
// sudog<T> // sudog<T>
dws = newdie(&dwtypes, DW_ABRV_STRUCTTYPE, dws = newdie(&dwtypes, DW_ABRV_STRUCTTYPE,
mkinternaltypename("sudog", mkinternaltypename("sudog",
getattr(elemtype, DW_AT_name)->data, NULL)); getattr(elemtype, DW_AT_name)->data, nil));
copychildren(dws, sudog); copychildren(dws, sudog);
substitutetype(dws, "elem", elemtype); substitutetype(dws, "elem", elemtype);
newattr(dws, DW_AT_byte_size, DW_CLS_CONSTANT, newattr(dws, DW_AT_byte_size, DW_CLS_CONSTANT,
sudogsize + (elemsize > 8 ? elemsize - 8 : 0), NULL); sudogsize + (elemsize > 8 ? elemsize - 8 : 0), nil);
// waitq<T> // waitq<T>
dww = newdie(&dwtypes, DW_ABRV_STRUCTTYPE, dww = newdie(&dwtypes, DW_ABRV_STRUCTTYPE,
mkinternaltypename("waitq", getattr(elemtype, DW_AT_name)->data, NULL)); mkinternaltypename("waitq", getattr(elemtype, DW_AT_name)->data, nil));
copychildren(dww, waitq); copychildren(dww, waitq);
substitutetype(dww, "first", defptrto(dws)); substitutetype(dww, "first", defptrto(dws));
substitutetype(dww, "last", defptrto(dws)); substitutetype(dww, "last", defptrto(dws));
newattr(dww, DW_AT_byte_size, DW_CLS_CONSTANT, newattr(dww, DW_AT_byte_size, DW_CLS_CONSTANT,
getattr(waitq, DW_AT_byte_size)->value, NULL); getattr(waitq, DW_AT_byte_size)->value, nil);
// hchan<T> // hchan<T>
dwh = newdie(&dwtypes, DW_ABRV_STRUCTTYPE, dwh = newdie(&dwtypes, DW_ABRV_STRUCTTYPE,
mkinternaltypename("hchan", getattr(elemtype, DW_AT_name)->data, NULL)); mkinternaltypename("hchan", getattr(elemtype, DW_AT_name)->data, nil));
copychildren(dwh, hchan); copychildren(dwh, hchan);
substitutetype(dwh, "recvq", dww); substitutetype(dwh, "recvq", dww);
substitutetype(dwh, "sendq", dww); substitutetype(dwh, "sendq", dww);
substitutetype(dwh, "free", defptrto(dws)); substitutetype(dwh, "free", defptrto(dws));
newattr(dwh, DW_AT_byte_size, DW_CLS_CONSTANT, newattr(dwh, DW_AT_byte_size, DW_CLS_CONSTANT,
getattr(hchan, DW_AT_byte_size)->value, NULL); getattr(hchan, DW_AT_byte_size)->value, nil);
newrefattr(die, DW_AT_type, defptrto(dwh)); newrefattr(die, DW_AT_type, defptrto(dwh));
} }
...@@ -1436,6 +1436,7 @@ defdwsymb(Sym* sym, char *s, int t, vlong v, vlong size, int ver, Sym *gotype) ...@@ -1436,6 +1436,7 @@ defdwsymb(Sym* sym, char *s, int t, vlong v, vlong size, int ver, Sym *gotype)
{ {
DWDie *dv, *dt; DWDie *dv, *dt;
USED(size);
if (strncmp(s, "go.string.", 10) == 0) if (strncmp(s, "go.string.", 10) == 0)
return; return;
...@@ -1592,7 +1593,7 @@ addhistfile(char *zentry) ...@@ -1592,7 +1593,7 @@ addhistfile(char *zentry)
// if the histfile stack contains ..../runtime/runtime_defs.go // if the histfile stack contains ..../runtime/runtime_defs.go
// use that to set gdbscript // use that to set gdbscript
static void static void
finddebugruntimepath() finddebugruntimepath(void)
{ {
int i, l; int i, l;
char *c; char *c;
...@@ -1841,7 +1842,8 @@ writelines(void) ...@@ -1841,7 +1842,8 @@ writelines(void)
char *n, *nn; char *n, *nn;
unitstart = -1; unitstart = -1;
epc = pc = 0; pc = 0;
epc = 0;
lc = 1; lc = 1;
llc = 1; llc = 1;
currfile = -1; currfile = -1;
...@@ -1903,7 +1905,8 @@ writelines(void) ...@@ -1903,7 +1905,8 @@ writelines(void)
// 4 zeros: the string termination + 3 fields. // 4 zeros: the string termination + 3 fields.
} }
epc = pc = s->text->pc; pc = s->text->pc;
epc = pc;
currfile = 1; currfile = 1;
lc = 1; lc = 1;
llc = 1; llc = 1;
...@@ -1992,7 +1995,7 @@ writelines(void) ...@@ -1992,7 +1995,7 @@ writelines(void)
newrefattr(dwvar, DW_AT_type, defgotype(a->gotype)); newrefattr(dwvar, DW_AT_type, defgotype(a->gotype));
// push dwvar down dwfunc->child to preserve order // push dwvar down dwfunc->child to preserve order
newattr(dwvar, DW_AT_internal_location, DW_CLS_CONSTANT, offs, NULL); newattr(dwvar, DW_AT_internal_location, DW_CLS_CONSTANT, offs, nil);
dwfunc->child = dwvar->link; // take dwvar out from the top of the list dwfunc->child = dwvar->link; // take dwvar out from the top of the list
for (dws = &dwfunc->child; *dws != nil; dws = &(*dws)->link) for (dws = &dwfunc->child; *dws != nil; dws = &(*dws)->link)
if (offs > getattr(*dws, DW_AT_internal_location)->value) if (offs > getattr(*dws, DW_AT_internal_location)->value)
...@@ -2345,7 +2348,11 @@ dwarfemitdebugsections(void) ...@@ -2345,7 +2348,11 @@ dwarfemitdebugsections(void)
infoo = cpos(); infoo = cpos();
writeinfo(); writeinfo();
gdbscripto = arangeso = pubtypeso = pubnameso = infoe = cpos(); infoe = cpos();
pubnameso = infoe;
pubtypeso = infoe;
arangeso = infoe;
gdbscripto = infoe;
if (fwdcount > 0) { if (fwdcount > 0) {
if (debug['v']) if (debug['v'])
......
...@@ -415,8 +415,8 @@ loaddynimport(char *file, char *pkg, char *p, int n) ...@@ -415,8 +415,8 @@ loaddynimport(char *file, char *pkg, char *p, int n)
char *pend, *next, *name, *def, *p0, *lib, *q; char *pend, *next, *name, *def, *p0, *lib, *q;
Sym *s; Sym *s;
USED(file);
pend = p + n; pend = p + n;
p0 = p;
for(; p<pend; p=next) { for(; p<pend; p=next) {
next = strchr(p, '\n'); next = strchr(p, '\n');
if(next == nil) if(next == nil)
...@@ -485,8 +485,8 @@ loaddynexport(char *file, char *pkg, char *p, int n) ...@@ -485,8 +485,8 @@ loaddynexport(char *file, char *pkg, char *p, int n)
char *pend, *next, *local, *elocal, *remote, *p0; char *pend, *next, *local, *elocal, *remote, *p0;
Sym *s; Sym *s;
USED(file);
pend = p + n; pend = p + n;
p0 = p;
for(; p<pend; p=next) { for(; p<pend; p=next) {
next = strchr(p, '\n'); next = strchr(p, '\n');
if(next == nil) if(next == nil)
......
...@@ -69,7 +69,7 @@ libinit(void) ...@@ -69,7 +69,7 @@ libinit(void)
// add goroot to the end of the libdir list. // add goroot to the end of the libdir list.
libdir[nlibdir++] = smprint("%s/pkg/%s_%s", goroot, goos, goarch); libdir[nlibdir++] = smprint("%s/pkg/%s_%s", goroot, goos, goarch);
unlink(outfile); remove(outfile);
cout = create(outfile, 1, 0775); cout = create(outfile, 1, 0775);
if(cout < 0) { if(cout < 0) {
diag("cannot create %s", outfile); diag("cannot create %s", outfile);
...@@ -398,9 +398,6 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn, int whence) ...@@ -398,9 +398,6 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn, int whence)
eof = Boffset(f) + len; eof = Boffset(f) + len;
pn = strdup(pn); pn = strdup(pn);
USED(c4);
USED(magic);
c1 = Bgetc(f); c1 = Bgetc(f);
c2 = Bgetc(f); c2 = Bgetc(f);
...@@ -410,7 +407,7 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn, int whence) ...@@ -410,7 +407,7 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn, int whence)
Bungetc(f); Bungetc(f);
Bungetc(f); Bungetc(f);
Bungetc(f); Bungetc(f);
magic = c1<<24 | c2<<16 | c3<<8 | c4; magic = c1<<24 | c2<<16 | c3<<8 | c4;
if(magic == 0x7f454c46) { // \x7F E L F if(magic == 0x7f454c46) { // \x7F E L F
ldelf(f, pkg, len, pn); ldelf(f, pkg, len, pn);
...@@ -498,7 +495,6 @@ _lookup(char *symb, int v, int creat) ...@@ -498,7 +495,6 @@ _lookup(char *symb, int v, int creat)
// not if(h < 0) h = ~h, because gcc 4.3 -O2 miscompiles it. // not if(h < 0) h = ~h, because gcc 4.3 -O2 miscompiles it.
h &= 0xffffff; h &= 0xffffff;
h %= NHASH; h %= NHASH;
c = symb[0];
for(s = hash[h]; s != S; s = s->hash) for(s = hash[h]; s != S; s = s->hash)
if(memcmp(s->name, symb, l) == 0) if(memcmp(s->name, symb, l) == 0)
return s; return s;
...@@ -523,7 +519,7 @@ _lookup(char *symb, int v, int creat) ...@@ -523,7 +519,7 @@ _lookup(char *symb, int v, int creat)
s->size = 0; s->size = 0;
hash[h] = s; hash[h] = s;
nsymbol++; nsymbol++;
s->allsym = allsym; s->allsym = allsym;
allsym = s; allsym = s;
return s; return s;
...@@ -550,7 +546,6 @@ copyhistfrog(char *buf, int nbuf) ...@@ -550,7 +546,6 @@ copyhistfrog(char *buf, int nbuf)
p = buf; p = buf;
ep = buf + nbuf; ep = buf + nbuf;
i = 0;
for(i=0; i<histfrogp; i++) { for(i=0; i<histfrogp; i++) {
p = seprint(p, ep, "%s", histfrog[i]->name+1); p = seprint(p, ep, "%s", histfrog[i]->name+1);
if(i+1<histfrogp && (p == buf || p[-1] != '/')) if(i+1<histfrogp && (p == buf || p[-1] != '/'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment