Commit 8ce584c2 authored by Shenghou Ma's avatar Shenghou Ma

liblink: rewrite '\\' in paths to '/' on windows

At least three Go tests rely on that (log, runtime/{pprof,debug}).

Fixes #6972.
Fixes #6974.
Fixes #6975.

R=alex.brainman, mattn.jp, rsc
CC=golang-dev
https://golang.org/cl/43150043
parent ae9e4db0
...@@ -104,8 +104,10 @@ ...@@ -104,8 +104,10 @@
static void writesym(Link*, Biobuf*, LSym*); static void writesym(Link*, Biobuf*, LSym*);
static void wrint(Biobuf*, int64); static void wrint(Biobuf*, int64);
static void wrstring(Biobuf*, char*); static void wrstring(Biobuf*, char*);
static void wrpath(Link *, Biobuf*, char*);
static void wrdata(Biobuf*, void*, int); static void wrdata(Biobuf*, void*, int);
static void wrsym(Biobuf*, LSym*); static void wrsym(Biobuf*, LSym*);
static void wrpathsym(Link *ctxt, Biobuf *b, LSym *s);
static void readsym(Link*, Biobuf*, char*, char*); static void readsym(Link*, Biobuf*, char*, char*);
static int64 rdint(Biobuf*); static int64 rdint(Biobuf*);
...@@ -165,7 +167,7 @@ linkwriteobj(Link *ctxt, Biobuf *b) ...@@ -165,7 +167,7 @@ linkwriteobj(Link *ctxt, Biobuf *b)
if(p->as == ctxt->arch->AGLOBL) { if(p->as == ctxt->arch->AGLOBL) {
s = p->from.sym; s = p->from.sym;
if(s->size) print("duplicate %P\n", p); if(s->size) print("duplicate %P\n", p);
if(data == nil) if(data == nil)
data = s; data = s;
else else
...@@ -359,7 +361,7 @@ writesym(Link *ctxt, Biobuf *b, LSym *s) ...@@ -359,7 +361,7 @@ writesym(Link *ctxt, Biobuf *b, LSym *s)
wrint(b, pc->funcdataoff[i]); wrint(b, pc->funcdataoff[i]);
wrint(b, pc->nfile); wrint(b, pc->nfile);
for(i=0; i<pc->nfile; i++) for(i=0; i<pc->nfile; i++)
wrsym(b, pc->file[i]); wrpathsym(ctxt, b, pc->file[i]);
} }
} }
...@@ -385,6 +387,23 @@ wrstring(Biobuf *b, char *s) ...@@ -385,6 +387,23 @@ wrstring(Biobuf *b, char *s)
wrdata(b, s, strlen(s)); wrdata(b, s, strlen(s));
} }
// wrpath writes a path just like a string, but on windows, it
// translates '\\' to '/' in the process.
static void
wrpath(Link *ctxt, Biobuf *b, char *p)
{
int i, n;
if (!ctxt->windows || strchr(p, '\\') == nil) {
wrstring(b, p);
return;
} else {
n = strlen(p);
wrint(b, n);
for (i = 0; i < n; i++)
Bputc(b, p[i] == '\\' ? '/' : p[i]);
}
}
static void static void
wrdata(Biobuf *b, void *v, int n) wrdata(Biobuf *b, void *v, int n)
{ {
...@@ -392,6 +411,18 @@ wrdata(Biobuf *b, void *v, int n) ...@@ -392,6 +411,18 @@ wrdata(Biobuf *b, void *v, int n)
Bwrite(b, v, n); Bwrite(b, v, n);
} }
static void
wrpathsym(Link *ctxt, Biobuf *b, LSym *s)
{
if(s == nil) {
wrint(b, 0);
wrint(b, 0);
return;
}
wrpath(ctxt, b, s->name);
wrint(b, s->version);
}
static void static void
wrsym(Biobuf *b, LSym *s) wrsym(Biobuf *b, LSym *s)
{ {
......
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