summaryrefslogtreecommitdiff
path: root/src/cmd/5l/obj.c
diff options
context:
space:
mode:
authorKai Backman <kaib@golang.org>2009-06-08 20:20:35 -0700
committerKai Backman <kaib@golang.org>2009-06-08 20:20:35 -0700
commitf58bbb8edf21b7142fb8b7aebd0f3a130cb12cd0 (patch)
tree9ba7eaaca16fc8f81b9af01095e8a62feccd0b32 /src/cmd/5l/obj.c
parentd4893db2ffe8dae867dd8e037a8597e8a123c021 (diff)
downloadgolang-f58bbb8edf21b7142fb8b7aebd0f3a130cb12cd0.tar.gz
initial morestack support for 5l. still disabled, doesn't work.
R=rsc APPROVED=rsc DELTA=245 (167 added, 63 deleted, 15 changed) OCL=30039 CL=30081
Diffstat (limited to 'src/cmd/5l/obj.c')
-rw-r--r--src/cmd/5l/obj.c65
1 files changed, 63 insertions, 2 deletions
diff --git a/src/cmd/5l/obj.c b/src/cmd/5l/obj.c
index 30f60e07d..3295348c2 100644
--- a/src/cmd/5l/obj.c
+++ b/src/cmd/5l/obj.c
@@ -278,6 +278,11 @@ main(int argc, char *argv[])
sprint(a, "%s/pkg/%s_%s/runtime.a", goroot, goos, goarch);
objfile(a);
}
+ // TODO(kaib): add these go specific extensions
+// definetypestrings();
+// definetypesigs();
+// deadcode();
+
firstp = firstp->link;
if(firstp == P)
goto out;
@@ -764,8 +769,10 @@ ldobj(Biobuf *f, int32 len, char *pn)
uint32 sig;
static int files;
static char **filen;
- char **nfilen,*name;
- vlong eof;
+ char **nfilen, *line, *name;
+ int n, c1, c2, c3;
+ int32 eof;
+ int32 start, import0, import1;
eof = Boffset(f) + len;
@@ -779,6 +786,48 @@ ldobj(Biobuf *f, int32 len, char *pn)
di = S;
+ goto newloop;
+
+ /* check the header */
+ start = Boffset(f);
+ line = Brdline(f, '\n');
+ if(line == nil) {
+ if(Blinelen(f) > 0) {
+ diag("%s: malformed object file", pn);
+ return;
+ }
+ goto eof;
+ }
+ n = Blinelen(f) - 1;
+ if(n != strlen(thestring) || strncmp(line, thestring, n) != 0) {
+ if(line)
+ line[n] = '\0';
+ diag("file not %s [%s]\n", thestring, line);
+ // TODO(kaib): Make not finding the header an error again
+// return;
+ Bseek(f, start, 0);
+ goto newloop;
+ }
+
+ /* skip over exports and other info -- ends with \n!\n */
+ import0 = Boffset(f);
+ c1 = '\n'; // the last line ended in \n
+ c2 = Bgetc(f);
+ c3 = Bgetc(f);
+ while(c1 != '\n' || c2 != '!' || c3 != '\n') {
+ c1 = c2;
+ c2 = c3;
+ c3 = Bgetc(f);
+ if(c3 == Beof)
+ goto eof;
+ }
+ import1 = Boffset(f);
+
+ Bseek(f, import0, 0);
+ // TODO(kaib): add in this go specific extension
+// ldpkg(f, import1 - import0 - 2, pn); // -2 for !\n
+ Bseek(f, import1, 0);
+
newloop:
memset(h, 0, sizeof(h));
version++;
@@ -1509,6 +1558,18 @@ puntfp(Prog *p)
// print("%s: generating ARM code (contains floating point ops %d)\n", curtext->from.sym->name, p->line);
}
+Prog*
+appendp(Prog *q)
+{
+ Prog *p;
+
+ p = prg();
+ p->link = q->link;
+ q->link = p;
+ p->line = q->line;
+ return p;
+}
+
void
undefsym(Sym *s)
{