Commit 48974f55 authored by Russ Cox's avatar Russ Cox

change 6l library directory flag to -L,

to match traditional c linkers.

R=r
DELTA=42  (8 added, 12 deleted, 22 changed)
OCL=28101
CL=28115
parent 5dc95206
...@@ -288,7 +288,7 @@ EXTERN vlong INITDAT; ...@@ -288,7 +288,7 @@ EXTERN vlong INITDAT;
EXTERN int32 INITRND; EXTERN int32 INITRND;
EXTERN vlong INITTEXT; EXTERN vlong INITTEXT;
EXTERN char* INITENTRY; /* entry point */ EXTERN char* INITENTRY; /* entry point */
EXTERN char* PKGDIR; EXTERN char* LIBDIR;
EXTERN Biobuf bso; EXTERN Biobuf bso;
EXTERN int32 bsssize; EXTERN int32 bsssize;
EXTERN int cbc; EXTERN int cbc;
......
...@@ -70,6 +70,13 @@ isobjfile(char *f) ...@@ -70,6 +70,13 @@ isobjfile(char *f)
return v; return v;
} }
void
usage(void)
{
fprint(2, "usage: 6l [-options] [-E entry] [-H head] [-L dir] [-T text] [-R rnd] [-o out] files...\n");
exits("usage");
}
void void
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
...@@ -87,7 +94,7 @@ main(int argc, char *argv[]) ...@@ -87,7 +94,7 @@ main(int argc, char *argv[])
INITDAT = -1; INITDAT = -1;
INITRND = -1; INITRND = -1;
INITENTRY = 0; INITENTRY = 0;
PKGDIR = nil; LIBDIR = nil;
ARGBEGIN { ARGBEGIN {
default: default:
...@@ -96,37 +103,26 @@ main(int argc, char *argv[]) ...@@ -96,37 +103,26 @@ main(int argc, char *argv[])
debug[c]++; debug[c]++;
break; break;
case 'o': /* output to (next arg) */ case 'o': /* output to (next arg) */
outfile = ARGF(); outfile = EARGF(usage());
break; break;
case 'E': case 'E':
a = ARGF(); INITENTRY = EARGF(usage());
if(a)
INITENTRY = a;
break; break;
case 'H': case 'H':
a = ARGF(); HEADTYPE = atolwhex(EARGF(usage()));
if(a) break;
HEADTYPE = atolwhex(a); case 'L':
LIBDIR = EARGF(usage());
break; break;
case 'T': case 'T':
a = ARGF(); INITTEXT = atolwhex(EARGF(usage()));
if(a)
INITTEXT = atolwhex(a);
break; break;
case 'D': case 'D':
a = ARGF(); INITDAT = atolwhex(EARGF(usage()));
if(a)
INITDAT = atolwhex(a);
break; break;
case 'R': case 'R':
a = ARGF(); INITRND = atolwhex(EARGF(usage()));
if(a)
INITRND = atolwhex(a);
break; break;
case 'P':
a = ARGF();
if(a)
PKGDIR = a;
break; break;
case 'x': /* produce export table */ case 'x': /* produce export table */
doexp = 1; doexp = 1;
...@@ -690,10 +686,10 @@ addlib(char *src, char *obj) ...@@ -690,10 +686,10 @@ addlib(char *src, char *obj)
} }
if(search) { if(search) {
// try dot, -P "pkgdir", and then goroot. // try dot, -L "libdir", and then goroot.
snprint(pname, sizeof pname, ".%s", name); snprint(pname, sizeof pname, "./%s", name);
if(access(pname, AEXIST) < 0 && PKGDIR != nil) if(access(pname, AEXIST) < 0 && LIBDIR != nil)
snprint(pname, sizeof pname, "%s/%s", PKGDIR, name); snprint(pname, sizeof pname, "%s/%s", LIBDIR, name);
if(access(pname, AEXIST) < 0) if(access(pname, AEXIST) < 0)
snprint(pname, sizeof pname, "%s/pkg/%s", goroot, name); snprint(pname, sizeof pname, "%s/pkg/%s", goroot, name);
strcpy(name, pname); strcpy(name, pname);
......
...@@ -282,12 +282,12 @@ asmlc(void) ...@@ -282,12 +282,12 @@ asmlc(void)
if(p->line == oldlc || p->as == ATEXT || p->as == ANOP) { if(p->line == oldlc || p->as == ATEXT || p->as == ANOP) {
if(p->as == ATEXT) if(p->as == ATEXT)
curtext = p; curtext = p;
if(debug['L']) if(debug['O'])
Bprint(&bso, "%6llux %P\n", Bprint(&bso, "%6llux %P\n",
p->pc, p); p->pc, p);
continue; continue;
} }
if(debug['L']) if(debug['O'])
Bprint(&bso, "\t\t%6ld", lcsize); Bprint(&bso, "\t\t%6ld", lcsize);
v = (p->pc - oldpc) / MINLC; v = (p->pc - oldpc) / MINLC;
while(v) { while(v) {
...@@ -295,7 +295,7 @@ asmlc(void) ...@@ -295,7 +295,7 @@ asmlc(void)
if(v < 127) if(v < 127)
s = v; s = v;
cput(s+128); /* 129-255 +pc */ cput(s+128); /* 129-255 +pc */
if(debug['L']) if(debug['O'])
Bprint(&bso, " pc+%ld*%d(%ld)", s, MINLC, s+128); Bprint(&bso, " pc+%ld*%d(%ld)", s, MINLC, s+128);
v -= s; v -= s;
lcsize++; lcsize++;
...@@ -309,7 +309,7 @@ asmlc(void) ...@@ -309,7 +309,7 @@ asmlc(void)
cput(s>>16); cput(s>>16);
cput(s>>8); cput(s>>8);
cput(s); cput(s);
if(debug['L']) { if(debug['O']) {
if(s > 0) if(s > 0)
Bprint(&bso, " lc+%ld(%d,%ld)\n", Bprint(&bso, " lc+%ld(%d,%ld)\n",
s, 0, s); s, 0, s);
...@@ -324,14 +324,14 @@ asmlc(void) ...@@ -324,14 +324,14 @@ asmlc(void)
} }
if(s > 0) { if(s > 0) {
cput(0+s); /* 1-64 +lc */ cput(0+s); /* 1-64 +lc */
if(debug['L']) { if(debug['O']) {
Bprint(&bso, " lc+%ld(%ld)\n", s, 0+s); Bprint(&bso, " lc+%ld(%ld)\n", s, 0+s);
Bprint(&bso, "%6llux %P\n", Bprint(&bso, "%6llux %P\n",
p->pc, p); p->pc, p);
} }
} else { } else {
cput(64-s); /* 65-128 -lc */ cput(64-s); /* 65-128 -lc */
if(debug['L']) { if(debug['O']) {
Bprint(&bso, " lc%ld(%ld)\n", s, 64-s); Bprint(&bso, " lc%ld(%ld)\n", s, 64-s);
Bprint(&bso, "%6llux %P\n", Bprint(&bso, "%6llux %P\n",
p->pc, p); p->pc, p);
...@@ -344,7 +344,7 @@ asmlc(void) ...@@ -344,7 +344,7 @@ asmlc(void)
cput(s); cput(s);
lcsize++; lcsize++;
} }
if(debug['v'] || debug['L']) if(debug['v'] || debug['O'])
Bprint(&bso, "lcsize = %ld\n", lcsize); Bprint(&bso, "lcsize = %ld\n", lcsize);
Bflush(&bso); Bflush(&bso);
} }
......
...@@ -13,7 +13,7 @@ GC=${GC:-${O}g} ...@@ -13,7 +13,7 @@ GC=${GC:-${O}g}
GL=${GL:-${O}l} GL=${GL:-${O}l}
export GC GL export GC GL
GC="$GC -I _obj" GC="$GC -I _obj"
GL="$GL -P _obj" GL="$GL -L _obj"
gofiles="" gofiles=""
loop=true loop=true
......
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