summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-05-09 17:29:17 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-05-09 17:33:36 +0200
commitebe3297c835b99429a6660c946a6c7f7f09ebec2 (patch)
tree7ba6eb1db84611c6abec60336b5a98291044a580
parent7f6c861fd63d6aeb47a15d18d98529c99898ab42 (diff)
libwg-go: ensure local Go instance is patched
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--app/tools/libwg-go/Makefile2
-rw-r--r--app/tools/libwg-go/goruntime-boottime-over-monotonic.diff103
2 files changed, 105 insertions, 0 deletions
diff --git a/app/tools/libwg-go/Makefile b/app/tools/libwg-go/Makefile
index 8c97b9d0..3daad830 100644
--- a/app/tools/libwg-go/Makefile
+++ b/app/tools/libwg-go/Makefile
@@ -44,6 +44,7 @@ $(GOROOT)/bin/go:
rm -rf "$(GOROOT)"
mkdir -p "$(GOROOT)"
curl "$(GOBUILDTARBALL)" | tar -C "$(GOROOT)" --strip-components=1 -xzf - || { rm -rf "$(GOROOT)"; exit 1; }
+ patch -p1 -f -N -r- -d"$(GOROOT)" < goruntime-boottime-over-monotonic.diff || { rm -rf "$(GOROOT)"; exit 1; }
$(DESTDIR)/libwg-go.so: $(GOROOT)/bin/go
endif
@@ -54,6 +55,7 @@ $(DESTDIR)/libwg-go.so: $(FILES) api-android.go jni.c
find . -type d -empty -delete
mkdir -p $(subst ../wireguard-go/,./,$(dir $(FILES)))
$(foreach FILE,$(FILES),ln -sfrt $(subst ../wireguard-go/,./,$(dir $(FILE))) $(FILE);)
+ patch -p1 -f -R -s --dry-run -d"$$(go env GOROOT)" < goruntime-boottime-over-monotonic.diff
go get -v -d
go build -v -o $(DESTDIR)/libwg-go.so -buildmode c-shared
go version > .gobuildversion
diff --git a/app/tools/libwg-go/goruntime-boottime-over-monotonic.diff b/app/tools/libwg-go/goruntime-boottime-over-monotonic.diff
new file mode 100644
index 00000000..8789d886
--- /dev/null
+++ b/app/tools/libwg-go/goruntime-boottime-over-monotonic.diff
@@ -0,0 +1,103 @@
+diff -ru b/src/runtime/sys_linux_386.s a/src/runtime/sys_linux_386.s
+--- b/src/runtime/sys_linux_386.s 2018-04-30 22:26:39.000000000 +0200
++++ a/src/runtime/sys_linux_386.s 2018-05-09 17:09:42.319531743 +0200
+@@ -287,13 +287,13 @@
+
+ LEAL 8(SP), BX // &ts (struct timespec)
+ MOVL BX, 4(SP)
+- MOVL $1, 0(SP) // CLOCK_MONOTONIC
++ MOVL $7, 0(SP) // CLOCK_BOOTTIME
+ CALL AX
+ JMP finish
+
+ fallback:
+ MOVL $SYS_clock_gettime, AX
+- MOVL $1, BX // CLOCK_MONOTONIC
++ MOVL $7, BX // CLOCK_BOOTTIME
+ LEAL 8(SP), CX
+ INVOKE_SYSCALL
+
+diff -ru b/src/runtime/sys_linux_amd64.s a/src/runtime/sys_linux_amd64.s
+--- b/src/runtime/sys_linux_amd64.s 2018-04-30 22:26:39.000000000 +0200
++++ a/src/runtime/sys_linux_amd64.s 2018-05-09 17:09:42.319531743 +0200
+@@ -258,7 +258,7 @@
+ MOVQ runtime·__vdso_clock_gettime_sym(SB), AX
+ CMPQ AX, $0
+ JEQ fallback
+- MOVL $1, DI // CLOCK_MONOTONIC
++ MOVL $7, DI // CLOCK_BOOTTIME
+ LEAQ 0(SP), SI
+ CALL AX
+ MOVQ 0(SP), AX // sec
+diff -ru b/src/runtime/sys_linux_arm64.s a/src/runtime/sys_linux_arm64.s
+--- b/src/runtime/sys_linux_arm64.s 2018-04-30 22:26:39.000000000 +0200
++++ a/src/runtime/sys_linux_arm64.s 2018-05-09 17:12:47.844591628 +0200
+@@ -201,7 +201,7 @@
+ RET
+
+ TEXT runtime·nanotime(SB),NOSPLIT,$24-8
+- MOVW $1, R0 // CLOCK_MONOTONIC
++ MOVW $7, R0 // CLOCK_BOOTTIME
+ MOVD RSP, R1
+ MOVD $SYS_clock_gettime, R8
+ SVC
+diff -ru b/src/runtime/sys_linux_arm.s a/src/runtime/sys_linux_arm.s
+--- b/src/runtime/sys_linux_arm.s 2018-04-30 22:26:39.000000000 +0200
++++ a/src/runtime/sys_linux_arm.s 2018-05-09 17:13:18.983281049 +0200
+@@ -235,7 +235,7 @@
+
+ // int64 nanotime(void)
+ TEXT runtime·nanotime(SB),NOSPLIT,$32
+- MOVW $1, R0 // CLOCK_MONOTONIC
++ MOVW $7, R0 // CLOCK_BOOTTIME
+ MOVW $8(R13), R1 // timespec
+ MOVW $SYS_clock_gettime, R7
+ SWI $0
+diff -ru b/src/runtime/sys_linux_mips64x.s a/src/runtime/sys_linux_mips64x.s
+--- b/src/runtime/sys_linux_mips64x.s 2018-04-30 22:26:39.000000000 +0200
++++ a/src/runtime/sys_linux_mips64x.s 2018-05-09 17:09:42.321531721 +0200
+@@ -197,7 +197,7 @@
+ RET
+
+ TEXT runtime·nanotime(SB),NOSPLIT,$16
+- MOVW $1, R4 // CLOCK_MONOTONIC
++ MOVW $7, R4 // CLOCK_BOOTTIME
+ MOVV $0(R29), R5
+ MOVV $SYS_clock_gettime, R2
+ SYSCALL
+diff -ru b/src/runtime/sys_linux_mipsx.s a/src/runtime/sys_linux_mipsx.s
+--- b/src/runtime/sys_linux_mipsx.s 2018-04-30 22:26:39.000000000 +0200
++++ a/src/runtime/sys_linux_mipsx.s 2018-05-09 17:09:42.321531721 +0200
+@@ -202,7 +202,7 @@
+ RET
+
+ TEXT runtime·nanotime(SB),NOSPLIT,$8-8
+- MOVW $1, R4 // CLOCK_MONOTONIC
++ MOVW $7, R4 // CLOCK_BOOTTIME
+ MOVW $4(R29), R5
+ MOVW $SYS_clock_gettime, R2
+ SYSCALL
+diff -ru b/src/runtime/sys_linux_ppc64x.s a/src/runtime/sys_linux_ppc64x.s
+--- b/src/runtime/sys_linux_ppc64x.s 2018-04-30 22:26:39.000000000 +0200
++++ a/src/runtime/sys_linux_ppc64x.s 2018-05-09 17:09:42.322531710 +0200
+@@ -176,7 +176,7 @@
+ RET
+
+ TEXT runtime·nanotime(SB),NOSPLIT,$16
+- MOVW $1, R3 // CLOCK_MONOTONIC
++ MOVW $7, R3 // CLOCK_BOOTTIME
+ MOVD $0(R1), R4
+ SYSCALL $SYS_clock_gettime
+ MOVD 0(R1), R3 // sec
+diff -ru b/src/runtime/sys_linux_s390x.s a/src/runtime/sys_linux_s390x.s
+--- b/src/runtime/sys_linux_s390x.s 2018-04-30 22:26:39.000000000 +0200
++++ a/src/runtime/sys_linux_s390x.s 2018-05-09 17:09:42.322531710 +0200
+@@ -188,7 +188,7 @@
+ RET
+
+ TEXT runtime·nanotime(SB),NOSPLIT,$16
+- MOVW $1, R2 // CLOCK_MONOTONIC
++ MOVW $7, R2 // CLOCK_BOOTTIME
+ MOVD $tp-16(SP), R3
+ MOVW $SYS_clock_gettime, R1
+ SYSCALL