Commit 5aea3374 authored by Shenghou Ma's avatar Shenghou Ma

ld: allow more -L options

        Dynamically allocate the libdir array, so we won't need to bother it again.
        Enhances CL 5727043.

R=rsc
CC=golang-dev
https://golang.org/cl/5731043
parent 6474eda4
......@@ -39,8 +39,9 @@ int iconv(Fmt*);
char symname[] = SYMDEF;
char pkgname[] = "__.PKGDEF";
char* libdir[16];
char** libdir;
int nlibdir = 0;
static int maxlibdir = 0;
static int cout = -1;
char* goroot;
......@@ -51,10 +52,20 @@ char* theline;
void
Lflag(char *arg)
{
if(nlibdir >= nelem(libdir)-1) {
char **p;
if(nlibdir >= maxlibdir) {
if (maxlibdir == 0)
maxlibdir = 8;
else
maxlibdir *= 2;
p = realloc(libdir, maxlibdir);
if (p == nil) {
print("too many -L's: %d\n", nlibdir);
usage();
}
libdir = p;
}
libdir[nlibdir++] = arg;
}
......@@ -69,7 +80,7 @@ libinit(void)
print("goarch is not known: %s\n", goarch);
// add goroot to the end of the libdir list.
libdir[nlibdir++] = smprint("%s/pkg/%s_%s", goroot, goos, goarch);
Lflag(smprint("%s/pkg/%s_%s", goroot, goos, goarch));
// Unix doesn't like it when we write to a running (or, sometimes,
// recently run) binary, so remove the output file before writing it.
......
......@@ -103,7 +103,7 @@ struct Section
};
extern char symname[];
extern char *libdir[];
extern char **libdir;
extern int nlibdir;
EXTERN char* INITENTRY;
......
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