char thechar = '6';
char* thestring = "amd64";
char* paramspace = "FP";
+char* libdir[16]; // contains "." first, goroot last
+int nlibdir = 0;
/*
* -H2 -T4136 -R4096 is plan9 64-bit format
INITDAT = -1;
INITRND = -1;
INITENTRY = 0;
- LIBDIR = nil;
+ libdir[nlibdir++] = "."; // look in dot first
ARGBEGIN {
default:
HEADTYPE = atolwhex(EARGF(usage()));
break;
case 'L':
- LIBDIR = EARGF(usage());
+ if(nlibdir >= nelem(libdir)-1) {
+ print("too many -L's: %d\n", nlibdir);
+ usage();
+ }
+ libdir[nlibdir++] = EARGF(usage());
break;
case 'T':
INITTEXT = atolwhex(EARGF(usage()));
case 'R':
INITRND = atolwhex(EARGF(usage()));
break;
- break;
case 'x': /* produce export table */
doexp = 1;
if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1]))
if(strcmp(goarch, thestring) != 0)
print("goarch is not known: %s\n", goarch);
+ // put goroot in the libdir list.
+ libdir[nlibdir++] = smprint("%s/pkg/%s_%s", goroot, goos, goarch);
+
if(HEADTYPE == -1) {
HEADTYPE = 2;
if(strcmp(goos, "linux") == 0)
if(search) {
// try dot, -L "libdir", and then goroot.
- snprint(pname, sizeof pname, "./%s", name);
- if(access(pname, AEXIST) < 0 && LIBDIR != nil)
- snprint(pname, sizeof pname, "%s/%s", LIBDIR, name);
- if(access(pname, AEXIST) < 0)
- snprint(pname, sizeof pname, "%s/pkg/%s_%s/%s", goroot, goos, goarch, name);
+ for(i=0; i<nlibdir; i++) {
+ snprint(pname, sizeof pname, "%s/%s", libdir[i], name);
+ if(access(pname, AEXIST) >= 0)
+ break;
+ }
strcpy(name, pname);
}
cleanname(name);
char symname[] = SYMDEF;
char thechar = '8';
char *thestring = "386";
+char* libdir[16]; // contains "." first, goroot last
+int nlibdir = 0;
/*
* -H0 -T0x40004C -D0x10000000 is garbage unix
HEADTYPE = atolwhex(EARGF(usage()));
break;
case 'L':
- LIBDIR = EARGF(usage());
+ if(nlibdir >= nelem(libdir)-1) {
+ print("too many -L's: %d\n", nlibdir);
+ usage();
+ }
+ libdir[nlibdir++] = EARGF(usage());
break;
case 'T':
INITTEXT = atolwhex(EARGF(usage()));
if(search) {
// try dot, -L "libdir", and then goroot.
- snprint(pname, sizeof pname, "./%s", name);
- if(access(pname, AEXIST) < 0 && LIBDIR != nil)
- snprint(pname, sizeof pname, "%s/%s", LIBDIR, name);
- if(access(pname, AEXIST) < 0)
- snprint(pname, sizeof pname, "%s/pkg/%s_%s/%s", goroot, goos, goarch, name);
+ for(i=0; i<nlibdir; i++) {
+ snprint(pname, sizeof pname, "%s/%s", libdir[i], name);
+ if(access(pname, AEXIST) >= 0)
+ break;
+ }
strcpy(name, pname);
}
cleanname(name);