tk: fix issues on x64 with addresses over 4GB.

Fixes #6931.
This commit is contained in:
Jeremy Drake
2020-09-06 12:20:55 -07:00
parent de59359670
commit 01d92abd9d
3 changed files with 56 additions and 3 deletions

View File

@@ -0,0 +1,23 @@
From efb26166cd9347b21a12fe840e2c80d1e660cf31 Mon Sep 17 00:00:00 2001
From: "jan.nijtmans" <nijtmans@users.sourceforge.net>
Date: Mon, 9 Dec 2019 23:07:44 +0000
Subject: [PATCH] Fix [7ca9a5b7cc]: Segfault due to pointer truncation in
DLL_PROCESS_DETACH
---
win/tkWin32Dll.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/win/tkWin32Dll.c b/win/tkWin32Dll.c
index 3c3d83a4b..88b050723 100644
--- a/win/tkWin32Dll.c
+++ b/win/tkWin32Dll.c
@@ -150,7 +150,7 @@ DllMain(
* Call TkFinalize
*/
- "movq $0x0, 0x0(%%esp)" "\n\t"
+ "movq $0x0, 0x0(%%rsp)" "\n\t"
"call TkFinalize" "\n\t"
/*

View File

@@ -0,0 +1,24 @@
From 892a3d64076baacbf011e008eda9a43660da05e5 Mon Sep 17 00:00:00 2001
From: jeremyd2019 <github@jdrake.com>
Date: Sun, 6 Sep 2020 12:10:54 -0700
Subject: [PATCH] use rip-relative addressing on x64
If the image base is greater than 4GB, the previous method results in a linker error
tkWin32Dll.o:tkWin32Dll.c:(.text+0x4d): relocation truncated to fit: R_X86_64_32S against `.text'
---
win/tkWin32Dll.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/win/tkWin32Dll.c b/win/tkWin32Dll.c
index 49ffd832c..9ff374e4d 100644
--- a/win/tkWin32Dll.c
+++ b/win/tkWin32Dll.c
@@ -135,7 +135,7 @@ DllMain(
"leaq %[registration], %%rdx" "\n\t"
"movq %%gs:0, %%rax" "\n\t"
"movq %%rax, 0x0(%%rdx)" "\n\t" /* link */
- "leaq 1f, %%rax" "\n\t"
+ "leaq 1f(%%rip), %%rax" "\n\t"
"movq %%rax, 0x8(%%rdx)" "\n\t" /* handler */
"movq %%rbp, 0x10(%%rdx)" "\n\t" /* rbp */
"movq %%rsp, 0x18(%%rdx)" "\n\t" /* rsp */

View File

@@ -7,7 +7,7 @@ pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
_basever=8.6.10
_patch=
pkgver=${_basever}${_patch}
pkgrel=1
pkgrel=2
pkgdesc="A windowing toolkit for use with tcl (mingw-w64)"
arch=('any')
url="https://tcl.sourceforge.io/"
@@ -20,13 +20,17 @@ source=("https://downloads.sourceforge.net/sourceforge/tcl/${_realname}${pkgver}
003-fix-forbidden-colon-in-paths.mingw.patch
004-install-man.mingw.patch
006-prevent-tclStubsPtr-segfault.patch
008-dont-link-shared-with--static-libgcc.patch)
008-dont-link-shared-with--static-libgcc.patch
009-esp-pointer-truncation.patch
010-rip-relative-address.patch)
sha256sums=('63df418a859d0a463347f95ded5cd88a3dd3aaa1ceecaeee362194bc30f3e386'
'441f2f5bdf1ee2bf6697569365207d554130bd5a2bac01e10a6e1a37738d8006'
'5347487af0e736dbb51425b22ed308840faf75b44c070623baa55f78dac3d053'
'8516749dd73c084ece7b9df6d1ba5708e652e8ba39cad59120c7f909f61747f0'
'0029fde6782ce7635e9957412d3e36a7e76d304399d57d64a42818f93e705621'
'a16406e8519ab681bba0915e35b23a7f91cf978934b0a4ebdc7e949e87f0c877')
'a16406e8519ab681bba0915e35b23a7f91cf978934b0a4ebdc7e949e87f0c877'
'a8c7038e93957c7d99401ea0e2637f057074b71a712fb6de21355dd86d43ce55'
'd32df352043e038db3ce40bc71f968aee9f9a53b195aff925ccd588ab823d085')
prepare() {
cd "${srcdir}/${_realname}${_basever}"
@@ -35,6 +39,8 @@ prepare() {
patch -p1 -i "${srcdir}"/004-install-man.mingw.patch
patch -p1 -i "${srcdir}"/006-prevent-tclStubsPtr-segfault.patch
patch -p1 -i "${srcdir}"/008-dont-link-shared-with--static-libgcc.patch
patch -p1 -i "${srcdir}"/009-esp-pointer-truncation.patch
patch -p1 -i "${srcdir}"/010-rip-relative-address.patch
cd win && autoreconf -fi
}