add plan 9 ar, which understands our symbol tables

SVN=124761
This commit is contained in:
Rob Pike 2008-06-25 20:58:35 -07:00
parent e90ae879d6
commit 250a091922
6 changed files with 1309 additions and 1 deletions

24
src/cmd/ar/Makefile Normal file
View File

@ -0,0 +1,24 @@
# Copyright 2009 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
CFLAGS=-I$(GOROOT)/include
BIN=$(HOME)/bin
O=o
# The directory is ar because the source is portable and general.
# We call the binary 6ar to avoid confusion and because this binary
# is linked only with amd64 and x86 support.
TARG=6ar
OFILES=\
ar.$O\
$(TARG): $(OFILES)
cc -o $(TARG) -L$(GOROOT)/lib $(OFILES) -lmach_amd64 -lbio -l9
clean:
rm -f $(OFILES) $(TARG)
install: $(TARG)
cp $(TARG) $(BIN)/$(TARG)

1246
src/cmd/ar/ar.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
for i in 6l 6a 6c 6g gc cc db
for i in 6l 6a 6c 6g gc cc ar db
do
cd $i
make clean

View File

@ -41,6 +41,11 @@ cd 6g
make install
cd ..
echo; echo; echo %%%% making ar %%%%; echo
cd ar
make install
cd ..
echo; echo; echo %%%% making db %%%%; echo
cd db
make install

View File

@ -32,6 +32,7 @@ O=o
LIB=libmach_amd64.a
OFILES=\
executable.$O\
fakeobj.$O\
map.$O\
obj.$O\
swap.$O\

View File

@ -113,7 +113,9 @@ objtype(Biobuf *bp, char **name)
{
int i;
char buf[MAXIS];
int c;
Retry:
if(Bread(bp, buf, MAXIS) < MAXIS)
return -1;
Bseek(bp, -MAXIS, 1);
@ -124,6 +126,36 @@ objtype(Biobuf *bp, char **name)
return i;
}
}
/*
* Maybe there's an import block we need to skip
*/
for(i = 0; i < MAXIS; i++) {
if(isalpha(buf[i]) || isdigit(buf[i]))
continue;
if(i == 0 || buf[i] != '\n')
return -1;
break;
}
/*
* Found one. Skip until "\n!\n"
*/
while((c = Bgetc(bp)) != Beof) {
if(c != '\n')
continue;
c = Bgetc(bp);
if(c != '!'){
Bungetc(bp);
continue;
}
c = Bgetc(bp);
if(c != '\n'){
Bungetc(bp);
continue;
}
goto Retry;
}
return -1;
}