This repository has been archived by the owner on Jul 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
/
run.ld
executable file
·65 lines (58 loc) · 1.88 KB
/
run.ld
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
set -e
eval $(go env)
export GOROOT
go install
rm -f c2go
dst=$GOROOT # !!!
rm -rf $dst/src/cmd/internal/ld* $dst/src/cmd/new?l
for i in 6 5 8 9
do
rm -rf $dst/src/cmd/internal/ld
c2go -c c2go.ld.cfg -dst $dst -I $GOROOT/include -I $GOROOT/src/cmd/ld -I $GOROOT/src/cmd/${i}l $GOROOT/src/liblink/*.c $GOROOT/src/cmd/ld/*.c $GOROOT/src/cmd/${i}l/*.c
mv $dst/src/cmd/internal/ld $dst/src/cmd/internal/ld.$i
done
mv $dst/src/cmd/internal/ld.6 $dst/src/cmd/internal/ld
rm -rf $dst/src/cmd/internal/ld.?
for i in add/new6l/*.go; do
base=$(echo $i | sed 's;add/;;')
cat $i | grep -v 'build ignore' >$dst/src/cmd/$base
done
for i in add/ld/*.go; do
base=$(echo $i | sed 's;.*/;;')
cat $i | grep -v 'build ignore' >$dst/src/cmd/internal/ld/$base
done
gofmt -w $dst/src/cmd/internal/ld $dst/src/cmd/new?l # check for syntax errors, mainly
rm -rf /tmp/c2gomain
mv $dst/src/main /tmp/c2gomain
export GOPATH=""
rm $dst/src/cmd/internal/ld/bio.go
echo 'X ,s/main\./obj./g
X ,s/obj\.Argv0/os.Args[0]/g
X ,s/obj\.Exits\(".+"\)/Exit(2)/g
X ,s/gc\.Zconv/Zconv/g
X ,s/BGETC/Bgetc/g
X ,s/\*Endian/binary.ByteOrder/g
X ,s/\&le([^a-zA-Z0-9_]|\n)/binary.LittleEndian\1/g
X ,s/\&be([^a-zA-Z0-9_]|\n)/binary.BigEndian\1/g
X ,s/ be\./ binary.BigEndian./g
X ,s/ le\./ binary.LittleEndian./g
X ,s/\.e64/.Uint64/g
X ,s/\.e32/.Uint32/g
X ,s/\.e16/.Uint16/g
X ,s/obj\.Werrstr/err = fmt.Errorf/g
X ,s/(err = fmt.Errorf.*)\n( +)return -1\n/\1\n\2return err\n/g
X ,s/argv\[argc\] = (.*)\n +argc\+\+\n/argv = append(argv, \1)\n/g
X/'"'"'/w
q' | sam -d $(find $dst/src/cmd/{internal/ld,new?l} -type f -a -name '*.go')
goimports -w $dst/src/cmd/new?l $dst/src/cmd/internal/ld
wc $(find $dst/src/cmd/{internal/ld,new?l} -type f -a -name '*.go')
go install -gcflags -e cmd/internal/ld cmd/new{5,6,8,9}l
go tool 6g ~/hellocgo.go
go tool new6l helloworld.6
./6.out
for i in 5l 6l 8l 9l
do
cp $(which new$i) $(toolstash -n $i)
done
exit 0