From 73702990470f5d795ee6e0866e341998d5857d3c Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Tue, 19 Oct 2021 15:18:01 -0400 Subject: Pass --disable-dynamicbase to ld The following commit (erroneously) enabled dynamicbase by default for all PE binaries: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=514b4e191d5f46de8e142fe216e677a35fa9c4bb But that messes up fork() and rebase on Cygwin, which rely on DLLs having static (but editable) bases. --- 1002-cygwin-ld-flags.patch | 24 ++++++++++++++++++++++++ cygwin-gcc.spec | 6 +++++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 1002-cygwin-ld-flags.patch diff --git a/1002-cygwin-ld-flags.patch b/1002-cygwin-ld-flags.patch new file mode 100644 index 0000000..ca9fdff --- /dev/null +++ b/1002-cygwin-ld-flags.patch @@ -0,0 +1,24 @@ +diff -up gcc-11.2.0/gcc/config/i386/cygwin.h.dynamicbase gcc-11.2.0/gcc/config/i386/cygwin.h +--- gcc-11.2.0/gcc/config/i386/cygwin.h.dynamicbase 2021-10-19 12:13:30.662685331 -0400 ++++ gcc-11.2.0/gcc/config/i386/cygwin.h 2021-10-19 12:14:31.539839223 -0400 +@@ -138,7 +138,7 @@ along with GCC; see the file COPYING3. + %{shared: %{mdll: %eshared and mdll are not compatible}} \ + %{shared: --shared} %{mdll:--dll} \ + %{static:-Bstatic} %{!static:-Bdynamic} \ +- %{shared|mdll: --enable-auto-image-base -e __cygwin_dll_entry@12} \ ++ %{shared|mdll: --disable-dynamicbase --enable-auto-image-base -e __cygwin_dll_entry@12} \ + --dll-search-prefix=cyg \ + %{rdynamic: --export-all-symbols} \ + %{!shared: %{!mdll: --large-address-aware --tsaware}}" +diff -up gcc-11.2.0/gcc/config/i386/cygwin-w64.h.dynamicbase gcc-11.2.0/gcc/config/i386/cygwin-w64.h +--- gcc-11.2.0/gcc/config/i386/cygwin-w64.h.dynamicbase 2021-10-19 14:22:45.560706087 -0400 ++++ gcc-11.2.0/gcc/config/i386/cygwin-w64.h 2021-10-19 14:23:17.766770713 -0400 +@@ -64,7 +64,7 @@ along with GCC; see the file COPYING3. + %{shared: %{mdll: %eshared and mdll are not compatible}} \ + %{shared: --shared} %{mdll:--dll} \ + %{static:-Bstatic} %{!static:-Bdynamic} \ +- %{shared|mdll: " SUB_LINK_ENTRY " --enable-auto-image-base} \ ++ %{shared|mdll: " SUB_LINK_ENTRY " --disable-dynamicbase --enable-auto-image-base} \ + %(shared_libgcc_undefs) \ + --dll-search-prefix=cyg \ + %{rdynamic: --export-all-symbols} \ diff --git a/cygwin-gcc.spec b/cygwin-gcc.spec index 39c8e24..7dfb51a 100644 --- a/cygwin-gcc.spec +++ b/cygwin-gcc.spec @@ -5,7 +5,7 @@ %global gcc_micro 0 # Note, gcc_release must be integer, if you want to add suffixes to # %%{release}, append them after %%{gcc_release} on Release: line. -%global gcc_release 1 +%global gcc_release 2 Name: cygwin-gcc Version: %{gcc_major}.%{gcc_minor}.%{gcc_micro} @@ -54,6 +54,7 @@ Patch11: 0011-Cygwin-define-STD_UNIX.patch # Fedora-specific patches Patch1001: 1001-textdomain.patch +Patch1002: 1002-cygwin-ld-flags.patch # Upstream patches #Patch2001: pr47030.patch @@ -523,6 +524,9 @@ cat cygwin-cpplib.lang >> cygwin-gcc.lang %changelog +* Tue Oct 19 2021 Yaakov Selkowitz - 11.2.0-2 +- Disable dynamicbase by default in DLLs + * Thu Sep 02 2021 Yaakov Selkowitz - 11.2.0-1 - new version -- cgit