Commit f54d73b8 authored by Ian Lance Taylor's avatar Ian Lance Taylor

Rename dynld to dynimport throughout.

Cgo users will need to rerun cgo.

R=rsc
CC=golang-dev
https://golang.org/cl/692041
parent a1723941
...@@ -374,6 +374,17 @@ outcode(void) ...@@ -374,6 +374,17 @@ outcode(void)
} }
Bprint(&outbuf, "%s\n", thestring); Bprint(&outbuf, "%s\n", thestring);
if(ndynimp > 0) {
int i;
Bprint(&outbuf, "\n");
Bprint(&outbuf, "$$ // exports\n\n");
Bprint(&outbuf, "$$ // local types\n\n");
Bprint(&outbuf, "$$ // dynimport\n", thestring);
for(i=0; i<ndynimp; i++)
Bprint(&outbuf, "dynimport %s %s %s\n", dynimp[i].local, dynimp[i].remote, dynimp[i].path);
Bprint(&outbuf, "$$\n\n");
}
Bprint(&outbuf, "!\n"); Bprint(&outbuf, "!\n");
outhist(&outbuf); outhist(&outbuf);
......
...@@ -260,12 +260,12 @@ doelf(void) ...@@ -260,12 +260,12 @@ doelf(void)
dynamic = s; dynamic = s;
/* /*
* relocation entries for dynld symbols * relocation entries for dynimp symbols
*/ */
nsym = 1; // sym 0 is reserved nsym = 1; // sym 0 is reserved
for(h=0; h<NHASH; h++) { for(h=0; h<NHASH; h++) {
for(s=hash[h]; s!=S; s=s->link) { for(s=hash[h]; s!=S; s=s->link) {
if(!s->reachable || (s->type != SDATA && s->type != SBSS) || s->dynldname == nil) if(!s->reachable || (s->type != SDATA && s->type != SBSS) || s->dynimpname == nil)
continue; continue;
#if 0 #if 0
d = lookup(".rel", 0); d = lookup(".rel", 0);
...@@ -274,7 +274,7 @@ doelf(void) ...@@ -274,7 +274,7 @@ doelf(void)
nsym++; nsym++;
d = lookup(".dynsym", 0); d = lookup(".dynsym", 0);
adduint32(d, addstring(lookup(".dynstr", 0), s->dynldname)); adduint32(d, addstring(lookup(".dynstr", 0), s->dynimpname));
adduint32(d, 0); /* value */ adduint32(d, 0); /* value */
adduint32(d, 0); /* size of object */ adduint32(d, 0); /* size of object */
t = STB_GLOBAL << 4; t = STB_GLOBAL << 4;
...@@ -283,8 +283,8 @@ doelf(void) ...@@ -283,8 +283,8 @@ doelf(void)
adduint8(d, 0); /* reserved */ adduint8(d, 0); /* reserved */
adduint16(d, SHN_UNDEF); /* section where symbol is defined */ adduint16(d, SHN_UNDEF); /* section where symbol is defined */
if(needlib(s->dynldlib)) if(needlib(s->dynimplib))
elfwritedynent(dynamic, DT_NEEDED, addstring(dynstr, s->dynldlib)); elfwritedynent(dynamic, DT_NEEDED, addstring(dynstr, s->dynimplib));
#endif #endif
} }
} }
......
...@@ -138,8 +138,8 @@ struct Sym ...@@ -138,8 +138,8 @@ struct Sym
Prog* data; Prog* data;
Sym* gotype; Sym* gotype;
char* file; char* file;
char* dynldname; char* dynimpname;
char* dynldlib; char* dynimplib;
}; };
#define SIGNINTERN (1729*325*1729) #define SIGNINTERN (1729*325*1729)
......
...@@ -232,15 +232,15 @@ outcode(void) ...@@ -232,15 +232,15 @@ outcode(void)
Binit(&b, f, OWRITE); Binit(&b, f, OWRITE);
Bprint(&b, "%s\n", thestring); Bprint(&b, "%s\n", thestring);
if(ndynld > 0) { if(ndynimp > 0) {
int i; int i;
Bprint(&b, "\n"); Bprint(&b, "\n");
Bprint(&b, "$$ // exports\n\n"); Bprint(&b, "$$ // exports\n\n");
Bprint(&b, "$$ // local types\n\n"); Bprint(&b, "$$ // local types\n\n");
Bprint(&b, "$$ // dynld\n", thestring); Bprint(&b, "$$ // dynimport\n", thestring);
for(i=0; i<ndynld; i++) for(i=0; i<ndynimp; i++)
Bprint(&b, "dynld %s %s %s\n", dynld[i].local, dynld[i].remote, dynld[i].path); Bprint(&b, "dynimport %s %s %s\n", dynimp[i].local, dynimp[i].remote, dynimp[i].path);
Bprint(&b, "$$\n\n"); Bprint(&b, "$$\n\n");
} }
Bprint(&b, "!\n"); Bprint(&b, "!\n");
......
...@@ -346,12 +346,12 @@ doelf(void) ...@@ -346,12 +346,12 @@ doelf(void)
dynamic = s; dynamic = s;
/* /*
* relocation entries for dynld symbols * relocation entries for dynimport symbols
*/ */
nsym = 1; // sym 0 is reserved nsym = 1; // sym 0 is reserved
for(h=0; h<NHASH; h++) { for(h=0; h<NHASH; h++) {
for(s=hash[h]; s!=S; s=s->link) { for(s=hash[h]; s!=S; s=s->link) {
if(!s->reachable || (s->type != SDATA && s->type != SBSS) || s->dynldname == nil) if(!s->reachable || (s->type != SDATA && s->type != SBSS) || s->dynimpname == nil)
continue; continue;
d = lookup(".rela", 0); d = lookup(".rela", 0);
...@@ -361,7 +361,7 @@ doelf(void) ...@@ -361,7 +361,7 @@ doelf(void)
nsym++; nsym++;
d = lookup(".dynsym", 0); d = lookup(".dynsym", 0);
adduint32(d, addstring(lookup(".dynstr", 0), s->dynldname)); adduint32(d, addstring(lookup(".dynstr", 0), s->dynimpname));
t = STB_GLOBAL << 4; t = STB_GLOBAL << 4;
t |= STT_OBJECT; // works for func too, empirically t |= STT_OBJECT; // works for func too, empirically
adduint8(d, t); adduint8(d, t);
...@@ -370,8 +370,8 @@ doelf(void) ...@@ -370,8 +370,8 @@ doelf(void)
adduint64(d, 0); /* value */ adduint64(d, 0); /* value */
adduint64(d, 0); /* size of object */ adduint64(d, 0); /* size of object */
if(needlib(s->dynldlib)) if(needlib(s->dynimplib))
elfwritedynent(dynamic, DT_NEEDED, addstring(dynstr, s->dynldlib)); elfwritedynent(dynamic, DT_NEEDED, addstring(dynstr, s->dynimplib));
} }
} }
......
...@@ -131,8 +131,8 @@ struct Sym ...@@ -131,8 +131,8 @@ struct Sym
Prog* data; Prog* data;
Sym* gotype; Sym* gotype;
char* file; char* file;
char* dynldname; char* dynimpname;
char* dynldlib; char* dynimplib;
}; };
struct Optab struct Optab
{ {
......
...@@ -231,15 +231,15 @@ outcode(void) ...@@ -231,15 +231,15 @@ outcode(void)
Binit(&b, f, OWRITE); Binit(&b, f, OWRITE);
Bprint(&b, "%s\n", thestring); Bprint(&b, "%s\n", thestring);
if(ndynld > 0) { if(ndynimp > 0) {
int i; int i;
Bprint(&b, "\n"); Bprint(&b, "\n");
Bprint(&b, "$$ // exports\n\n"); Bprint(&b, "$$ // exports\n\n");
Bprint(&b, "$$ // local types\n\n"); Bprint(&b, "$$ // local types\n\n");
Bprint(&b, "$$ // dynld\n", thestring); Bprint(&b, "$$ // dynimport\n", thestring);
for(i=0; i<ndynld; i++) for(i=0; i<ndynimp; i++)
Bprint(&b, "dynld %s %s %s\n", dynld[i].local, dynld[i].remote, dynld[i].path); Bprint(&b, "dynimport %s %s %s\n", dynimp[i].local, dynimp[i].remote, dynimp[i].path);
Bprint(&b, "$$\n\n"); Bprint(&b, "$$\n\n");
} }
Bprint(&b, "!\n"); Bprint(&b, "!\n");
......
...@@ -337,12 +337,12 @@ doelf(void) ...@@ -337,12 +337,12 @@ doelf(void)
dynamic = s; dynamic = s;
/* /*
* relocation entries for dynld symbols * relocation entries for dynimport symbols
*/ */
nsym = 1; // sym 0 is reserved nsym = 1; // sym 0 is reserved
for(h=0; h<NHASH; h++) { for(h=0; h<NHASH; h++) {
for(s=hash[h]; s!=S; s=s->link) { for(s=hash[h]; s!=S; s=s->link) {
if(!s->reachable || (s->type != SDATA && s->type != SBSS) || s->dynldname == nil) if(!s->reachable || (s->type != SDATA && s->type != SBSS) || s->dynimpname == nil)
continue; continue;
d = lookup(".rel", 0); d = lookup(".rel", 0);
...@@ -351,7 +351,7 @@ doelf(void) ...@@ -351,7 +351,7 @@ doelf(void)
nsym++; nsym++;
d = lookup(".dynsym", 0); d = lookup(".dynsym", 0);
adduint32(d, addstring(lookup(".dynstr", 0), s->dynldname)); adduint32(d, addstring(lookup(".dynstr", 0), s->dynimpname));
adduint32(d, 0); /* value */ adduint32(d, 0); /* value */
adduint32(d, 0); /* size of object */ adduint32(d, 0); /* size of object */
t = STB_GLOBAL << 4; t = STB_GLOBAL << 4;
...@@ -360,8 +360,8 @@ doelf(void) ...@@ -360,8 +360,8 @@ doelf(void)
adduint8(d, 0); /* reserved */ adduint8(d, 0); /* reserved */
adduint16(d, SHN_UNDEF); /* section where symbol is defined */ adduint16(d, SHN_UNDEF); /* section where symbol is defined */
if(needlib(s->dynldlib)) if(needlib(s->dynimplib))
elfwritedynent(dynamic, DT_NEEDED, addstring(dynstr, s->dynldlib)); elfwritedynent(dynamic, DT_NEEDED, addstring(dynstr, s->dynimplib));
} }
} }
......
...@@ -131,8 +131,8 @@ struct Sym ...@@ -131,8 +131,8 @@ struct Sym
Prog* data; Prog* data;
Sym* gotype; Sym* gotype;
char* file; char* file;
char* dynldname; char* dynimpname;
char* dynldlib; char* dynimplib;
}; };
struct Optab struct Optab
{ {
......
...@@ -56,7 +56,7 @@ typedef struct Hist Hist; ...@@ -56,7 +56,7 @@ typedef struct Hist Hist;
typedef struct Term Term; typedef struct Term Term;
typedef struct Init Init; typedef struct Init Init;
typedef struct Bits Bits; typedef struct Bits Bits;
typedef struct Dynld Dynld; typedef struct Dynimp Dynimp;
#define NHUNK 50000L #define NHUNK 50000L
#define BUFSIZ 8192 #define BUFSIZ 8192
...@@ -444,15 +444,15 @@ struct Funct ...@@ -444,15 +444,15 @@ struct Funct
Sym* castfr[NTYPE]; Sym* castfr[NTYPE];
}; };
struct Dynld struct Dynimp
{ {
char* local; char* local;
char* remote; char* remote;
char* path; char* path;
}; };
EXTERN Dynld *dynld; EXTERN Dynimp *dynimp;
EXTERN int ndynld; EXTERN int ndynimp;
EXTERN struct EXTERN struct
{ {
...@@ -760,7 +760,7 @@ void pragpack(void); ...@@ -760,7 +760,7 @@ void pragpack(void);
void pragfpround(void); void pragfpround(void);
void pragtextflag(void); void pragtextflag(void);
void pragincomplete(void); void pragincomplete(void);
void pragdynld(void); void pragdynimport(void);
/* /*
* calls to machine depend part * calls to machine depend part
......
...@@ -533,11 +533,11 @@ out: ...@@ -533,11 +533,11 @@ out:
} }
void void
pragdynld(void) pragdynimport(void)
{ {
Sym *local, *remote; Sym *local, *remote;
char *path; char *path;
Dynld *f; Dynimp *f;
local = getsym(); local = getsym();
if(local == nil) if(local == nil)
...@@ -551,16 +551,16 @@ pragdynld(void) ...@@ -551,16 +551,16 @@ pragdynld(void)
if(path == nil) if(path == nil)
goto err; goto err;
if(ndynld%32 == 0) if(ndynimp%32 == 0)
dynld = realloc(dynld, (ndynld+32)*sizeof dynld[0]); dynimp = realloc(dynimp, (ndynimp+32)*sizeof dynimp[0]);
f = &dynld[ndynld++]; f = &dynimp[ndynimp++];
f->local = local->name; f->local = local->name;
f->remote = remote->name; f->remote = remote->name;
f->path = path; f->path = path;
goto out; goto out;
err: err:
yyerror("usage: #pragma dynld local remote \"path\""); yyerror("usage: #pragma dynimport local remote \"path\"");
out: out:
while(getnsc() != '\n') while(getnsc() != '\n')
......
...@@ -47,7 +47,7 @@ pragvararg(void) ...@@ -47,7 +47,7 @@ pragvararg(void)
} }
void void
pragdynld(void) pragdynimport(void)
{ {
while(getnsc() != '\n') while(getnsc() != '\n')
; ;
......
...@@ -739,8 +739,8 @@ macprag(void) ...@@ -739,8 +739,8 @@ macprag(void)
pragincomplete(); pragincomplete();
return; return;
} }
if(s && strcmp(s->name, "dynld") == 0) { if(s && strcmp(s->name, "dynimport") == 0) {
pragdynld(); pragdynimport();
return; return;
} }
while(getnsc() != '\n') while(getnsc() != '\n')
......
...@@ -50,7 +50,7 @@ func (p *Prog) writeDefs() { ...@@ -50,7 +50,7 @@ func (p *Prog) writeDefs() {
fmt.Fprintf(fc, cProlog, pkgroot, pkgroot, pkgroot, pkgroot) fmt.Fprintf(fc, cProlog, pkgroot, pkgroot, pkgroot, pkgroot)
for name, def := range p.Vardef { for name, def := range p.Vardef {
fmt.Fprintf(fc, "#pragma dynld ·_C_%s %s \"%s.so\"\n", name, name, path) fmt.Fprintf(fc, "#pragma dynimport ·_C_%s %s \"%s.so\"\n", name, name, path)
fmt.Fprintf(fgo2, "var _C_%s ", name) fmt.Fprintf(fgo2, "var _C_%s ", name)
printer.Fprint(fgo2, &ast.StarExpr{X: def.Go}) printer.Fprint(fgo2, &ast.StarExpr{X: def.Go})
fmt.Fprintf(fgo2, "\n") fmt.Fprintf(fgo2, "\n")
...@@ -129,7 +129,7 @@ func (p *Prog) writeDefs() { ...@@ -129,7 +129,7 @@ func (p *Prog) writeDefs() {
// C wrapper calls into gcc, passing a pointer to the argument frame. // C wrapper calls into gcc, passing a pointer to the argument frame.
// Also emit #pragma to get a pointer to the gcc wrapper. // Also emit #pragma to get a pointer to the gcc wrapper.
fmt.Fprintf(fc, "#pragma dynld _cgo_%s _cgo_%s \"%s.so\"\n", name, name, path) fmt.Fprintf(fc, "#pragma dynimport _cgo_%s _cgo_%s \"%s.so\"\n", name, name, path)
fmt.Fprintf(fc, "void (*_cgo_%s)(void*);\n", name) fmt.Fprintf(fc, "void (*_cgo_%s)(void*);\n", name)
fmt.Fprintf(fc, "\n") fmt.Fprintf(fc, "\n")
fmt.Fprintf(fc, "void\n") fmt.Fprintf(fc, "void\n")
...@@ -273,10 +273,10 @@ const cProlog = ` ...@@ -273,10 +273,10 @@ const cProlog = `
#include "runtime.h" #include "runtime.h"
#include "cgocall.h" #include "cgocall.h"
#pragma dynld initcgo initcgo "%s/libcgo.so" #pragma dynimport initcgo initcgo "%s/libcgo.so"
#pragma dynld libcgo_thread_start libcgo_thread_start "%s/libcgo.so" #pragma dynimport libcgo_thread_start libcgo_thread_start "%s/libcgo.so"
#pragma dynld _cgo_malloc _cgo_malloc "%s/libcgo.so" #pragma dynimport _cgo_malloc _cgo_malloc "%s/libcgo.so"
#pragma dynld _cgo_free free "%s/libcgo.so" #pragma dynimport _cgo_free free "%s/libcgo.so"
void void
·_C_GoString(int8 *p, String s) ·_C_GoString(int8 *p, String s)
......
...@@ -66,7 +66,7 @@ ilookup(char *name) ...@@ -66,7 +66,7 @@ ilookup(char *name)
} }
static void loadpkgdata(char*, char*, char*, int); static void loadpkgdata(char*, char*, char*, int);
static void loaddynld(char*, char*, int); static void loaddynimport(char*, char*, int);
static int parsemethod(char**, char*, char**); static int parsemethod(char**, char*, char**);
static int parsepkgdata(char*, char*, char**, char*, char**, char**, char**); static int parsepkgdata(char*, char*, char**, char*, char**, char**, char**);
...@@ -141,22 +141,22 @@ ldpkg(Biobuf *f, char *pkg, int64 len, char *filename) ...@@ -141,22 +141,22 @@ ldpkg(Biobuf *f, char *pkg, int64 len, char *filename)
loadpkgdata(filename, pkg, p0, p1 - p0); loadpkgdata(filename, pkg, p0, p1 - p0);
// look for dynld section // look for dynimport section
p0 = strstr(p1, "\n$$ // dynld"); p0 = strstr(p1, "\n$$ // dynimport");
if(p0 != nil) { if(p0 != nil) {
p0 = strchr(p0+1, '\n'); p0 = strchr(p0+1, '\n');
if(p0 == nil) { if(p0 == nil) {
fprint(2, "%s: found $$ // dynld but no newline in %s\n", argv0, filename); fprint(2, "%s: found $$ // dynimport but no newline in %s\n", argv0, filename);
return; return;
} }
p1 = strstr(p0, "\n$$"); p1 = strstr(p0, "\n$$");
if(p1 == nil) if(p1 == nil)
p1 = strstr(p0, "\n!\n"); p1 = strstr(p0, "\n!\n");
if(p1 == nil) { if(p1 == nil) {
fprint(2, "%s: cannot find end of // dynld section in %s\n", argv0, filename); fprint(2, "%s: cannot find end of // dynimport section in %s\n", argv0, filename);
return; return;
} }
loaddynld(filename, p0 + 1, p1 - p0); loaddynimport(filename, p0 + 1, p1 - p0);
} }
} }
...@@ -337,7 +337,7 @@ parsemethod(char **pp, char *ep, char **methp) ...@@ -337,7 +337,7 @@ parsemethod(char **pp, char *ep, char **methp)
} }
static void static void
loaddynld(char *file, char *p, int n) loaddynimport(char *file, char *p, int n)
{ {
char *next, *name, *def, *p0, *lib; char *next, *name, *def, *p0, *lib;
Sym *s; Sym *s;
...@@ -352,9 +352,9 @@ loaddynld(char *file, char *p, int n) ...@@ -352,9 +352,9 @@ loaddynld(char *file, char *p, int n)
else else
*next++ = '\0'; *next++ = '\0';
p0 = p; p0 = p;
if(strncmp(p, "dynld ", 6) != 0) if(strncmp(p, "dynimport ", 10) != 0)
goto err; goto err;
p += 6; p += 10;
name = p; name = p;
p = strchr(name, ' '); p = strchr(name, ' ');
if(p == nil) if(p == nil)
...@@ -374,13 +374,13 @@ loaddynld(char *file, char *p, int n) ...@@ -374,13 +374,13 @@ loaddynld(char *file, char *p, int n)
*strchr(def, ' ') = 0; *strchr(def, ' ') = 0;
s = lookup(name, 0); s = lookup(name, 0);
s->dynldlib = lib; s->dynimplib = lib;
s->dynldname = def; s->dynimpname = def;
} }
return; return;
err: err:
fprint(2, "%s: invalid dynld line: %s\n", argv0, p0); fprint(2, "%s: invalid dynimport line: %s\n", argv0, p0);
nerrors++; nerrors++;
} }
......
...@@ -281,7 +281,7 @@ domacho(void) ...@@ -281,7 +281,7 @@ domacho(void)
nsym = 0; nsym = 0;
for(h=0; h<NHASH; h++) { for(h=0; h<NHASH; h++) {
for(s=hash[h]; s!=S; s=s->link) { for(s=hash[h]; s!=S; s=s->link) {
if(!s->reachable || (s->type != SDATA && s->type != SBSS) || s->dynldname == nil) if(!s->reachable || (s->type != SDATA && s->type != SBSS) || s->dynimpname == nil)
continue; continue;
if(debug['d']) { if(debug['d']) {
diag("cannot use dynamic loading and -d"); diag("cannot use dynamic loading and -d");
...@@ -292,9 +292,9 @@ domacho(void) ...@@ -292,9 +292,9 @@ domacho(void)
/* symbol table entry - darwin still puts _ prefixes on all C symbols */ /* symbol table entry - darwin still puts _ prefixes on all C symbols */
x = nstrtab; x = nstrtab;
p = grow(&strtab, &nstrtab, &mstrtab, 1+strlen(s->dynldname)+1); p = grow(&strtab, &nstrtab, &mstrtab, 1+strlen(s->dynimpname)+1);
*p++ = '_'; *p++ = '_';
strcpy(p, s->dynldname); strcpy(p, s->dynimpname);
dat = grow(&linkdata, &nlinkdata, &mlinkdata, 8+ptrsize); dat = grow(&linkdata, &nlinkdata, &mlinkdata, 8+ptrsize);
dat[0] = x; dat[0] = x;
...@@ -303,7 +303,7 @@ domacho(void) ...@@ -303,7 +303,7 @@ domacho(void)
dat[3] = x>>24; dat[3] = x>>24;
dat[4] = 0x01; // type: N_EXT - external symbol dat[4] = 0x01; // type: N_EXT - external symbol
if(needlib(s->dynldlib)) { if(needlib(s->dynimplib)) {
if(ndylib%32 == 0) { if(ndylib%32 == 0) {
dylib = realloc(dylib, (ndylib+32)*sizeof dylib[0]); dylib = realloc(dylib, (ndylib+32)*sizeof dylib[0]);
if(dylib == nil) { if(dylib == nil) {
...@@ -311,7 +311,7 @@ domacho(void) ...@@ -311,7 +311,7 @@ domacho(void)
errorexit(); errorexit();
} }
} }
dylib[ndylib++] = s->dynldlib; dylib[ndylib++] = s->dynimplib;
} }
nsym++; nsym++;
} }
......
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