summaryrefslogtreecommitdiff
path: root/src/cmd/ld/go.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-08-24 10:19:31 -0700
committerRuss Cox <rsc@golang.org>2009-08-24 10:19:31 -0700
commit4ead6a4a87b849c928e29195cbfebd21bf93e24d (patch)
treef29cc5fac4cf8f7a01c729e7f293d818f8accd20 /src/cmd/ld/go.c
parentf3eb11652695b542d3ed22150389ccc0a8b882a6 (diff)
downloadgolang-4ead6a4a87b849c928e29195cbfebd21bf93e24d.tar.gz
linker work
* use //ffi comments in package import data to generate relocation entries and library loads. * call initffi in rt0.s if present R=r DELTA=117 (91 added, 3 deleted, 23 changed) OCL=33739 CL=33750
Diffstat (limited to 'src/cmd/ld/go.c')
-rw-r--r--src/cmd/ld/go.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/cmd/ld/go.c b/src/cmd/ld/go.c
index 0ced9a1ac..4bad52413 100644
--- a/src/cmd/ld/go.c
+++ b/src/cmd/ld/go.c
@@ -190,6 +190,7 @@ parsepkgdata(char *file, char **pp, char *ep, char **prefixp, char **namep, char
char *p, *prefix, *name, *def, *edef, *meth;
int n;
+again:
// skip white space
p = *pp;
while(p < ep && (*p == ' ' || *p == '\t' || *p == '\n'))
@@ -211,8 +212,46 @@ parsepkgdata(char *file, char **pp, char *ep, char **prefixp, char **namep, char
p += 5;
else if(strncmp(p, "const ", 6) == 0)
p += 6;
- else{
- fprint(2, "%s: confused in pkg data near <<%.20s>>\n", argv0, p);
+ else if(strncmp(p, "//ffi ", 6) == 0) {
+ Sym *s;
+ char type, *lib;
+
+ p += 6;
+ if(*p == 0 || *(p+1) != ' ')
+ goto err;
+ type = *p;
+ p += 2;
+ name = p;
+ p = strchr(name, ' ');
+ if(p == nil)
+ goto err;
+ while(*p == ' ')
+ p++;
+ def = p;
+ p = strchr(def, ' ');
+ if(p == nil)
+ goto err;
+ while(*p == ' ')
+ p++;
+ lib = p;
+ p = strchr(lib, '\n');
+ if(p == nil)
+ goto err;
+
+ // successful parse: now can edit the line
+ *strchr(name, ' ') = 0;
+ *strchr(def, ' ') = 0;
+ *strchr(lib, '\n') = 0;
+ *pp = p+1;
+
+ s = lookup(name, 0);
+ s->ffitype = type;
+ s->ffilib = lib;
+ s->ffiname = def;
+ goto again;
+ } else {
+ err:
+ fprint(2, "%s: confused in pkg data near <<%.20s>>\n", argv0, prefix);
nerrors++;
return -1;
}