diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-09-13 13:13:44 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-09-13 13:13:44 +0200 |
commit | 9464a0c36318f8a801c07d6874bd0cea40f12504 (patch) | |
tree | f0178491c19d4f1ebc7b92eede86690998466480 /src/cmd/ld/lib.c | |
parent | ba9fda6068cfadd42db0b152fdca7e8b67aaf77d (diff) | |
parent | 5ff4c17907d5b19510a62e08fd8d3b11e62b431d (diff) | |
download | golang-9464a0c36318f8a801c07d6874bd0cea40f12504.tar.gz |
Merge commit 'upstream/60' into debian-sid
Diffstat (limited to 'src/cmd/ld/lib.c')
-rw-r--r-- | src/cmd/ld/lib.c | 76 |
1 files changed, 66 insertions, 10 deletions
diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c index 77a62f5de..5d1e6d61b 100644 --- a/src/cmd/ld/lib.c +++ b/src/cmd/ld/lib.c @@ -41,7 +41,7 @@ char symname[] = SYMDEF; char pkgname[] = "__.PKGDEF"; char* libdir[16]; int nlibdir = 0; -int cout = -1; +static int cout = -1; char* goroot; char* goarch; @@ -62,6 +62,7 @@ libinit(void) { fmtinstall('i', iconv); fmtinstall('Y', Yconv); + fmtinstall('Z', Zconv); mywhatsys(); // get goroot, goarch, goos if(strcmp(goarch, thestring) != 0) print("goarch is not known: %s\n", goarch); @@ -281,6 +282,8 @@ loadlib(void) // binaries, so leave it enabled on OS X (Mach-O) binaries. if(!havedynamic && HEADTYPE != Hdarwin) debug['d'] = 1; + + importcycles(); } /* @@ -938,15 +941,6 @@ addsection(Segment *seg, char *name, int rwx) } void -ewrite(int fd, void *buf, int n) -{ - if(write(fd, buf, n) < 0) { - diag("write error: %r"); - errorexit(); - } -} - -void pclntab(void) { vlong oldpc; @@ -1359,3 +1353,65 @@ Yconv(Fmt *fp) return 0; } + +vlong coutpos; + +void +cflush(void) +{ + int n; + + if(cbpmax < cbp) + cbpmax = cbp; + n = cbpmax - buf.cbuf; + if(n) { + if(write(cout, buf.cbuf, n) != n) { + diag("write error: %r"); + errorexit(); + } + coutpos += n; + } + cbp = buf.cbuf; + cbc = sizeof(buf.cbuf); + cbpmax = cbp; +} + +vlong +cpos(void) +{ + return coutpos + cbp - buf.cbuf; +} + +void +cseek(vlong p) +{ + vlong start; + int delta; + + if(cbpmax < cbp) + cbpmax = cbp; + start = coutpos; + if(start <= p && p <= start+(cbpmax - buf.cbuf)) { +//print("cseek %lld in [%lld,%lld] (%lld)\n", p, start, start+sizeof(buf.cbuf), cpos()); + delta = p - (start + cbp - buf.cbuf); + cbp += delta; + cbc -= delta; +//print("now at %lld\n", cpos()); + return; + } + + cflush(); + seek(cout, p, 0); + coutpos = p; +} + +void +cwrite(void *buf, int n) +{ + cflush(); + if(write(cout, buf, n) != n) { + diag("write error: %r"); + errorexit(); + } + coutpos += n; +} |