summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kaster <andrewdkaster@gmail.com>2020-01-01 14:16:06 -0500
committerAndreas Kling <awesomekling@gmail.com>2020-01-01 23:05:17 +0100
commit2979491512d5c6dbbce265af4fd0e2ddd8968d16 (patch)
tree7005bcda7b2dcacbf98d72a25c24ac16efc28abe
parent99e06c53e512dd3ab0e356524f3828af8c69c946 (diff)
downloadserenity-2979491512d5c6dbbce265af4fd0e2ddd8968d16.zip
Toolchain: Use crtbeginS and crtendS for shared objects
Turns out the reason GCC wasn't as smart about startup code for shared objects as we hoped is because nobody told it to be :D Change the STARTFILE_SPEC and ENDFILE_SPEC in gcc/config/serenity.h to skip crt0.o and to link the S variants of crtbegin and crtend for shared objects. Because we're using the crtbegin and crtend from libgcc, also tell libgcc in libgcc/config.host to compile crtbeginS and crtendS from crtstuff.c.
-rw-r--r--Ports/gcc/patches/gcc.patch10
-rw-r--r--Toolchain/Patches/gcc.patch10
2 files changed, 10 insertions, 10 deletions
diff --git a/Ports/gcc/patches/gcc.patch b/Ports/gcc/patches/gcc.patch
index cfe7a4a360..c11ac5cbc2 100644
--- a/Ports/gcc/patches/gcc.patch
+++ b/Ports/gcc/patches/gcc.patch
@@ -7,7 +7,7 @@ index 75bb6a313..da281fb48 100755
# Copyright 1992-2019 Free Software Foundation, Inc.
-timestamp='2019-01-01'
-+timestamp='2019-12-17'
++timestamp='2020-01-01
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -153,11 +153,11 @@ index 000000000..925c88dd6
+/* Files that are linked before user code.
+ The %s tells GCC to look for these files in the library directory. */
+#undef STARTFILE_SPEC
-+#define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s"
++#define STARTFILE_SPEC "%{!shared:crt0.o%s} crti.o%s %{shared:crtbeginS.o%s; :crtbegin.o%s}"
+
+/* Files that are linked after user code. */
+#undef ENDFILE_SPEC
-+#define ENDFILE_SPEC "crtend.o%s crtn.o%s"
++#define ENDFILE_SPEC "%{shared:crtendS.o%s; :crtend.o%s} crtn.o%s"
+
+#undef LINK_SPEC
+#define LINK_SPEC "%{shared:-shared} %{static:-static} %{!shared: %{!static: %{rdynamic:-export-dynamic}}}"
@@ -181,11 +181,11 @@ index 91abc84da..659376d14 100644
extra_parts="crt0.o"
;;
+i[34567]86-*-serenity*)
-+ extra_parts="$extra_parts crti.o crtbegin.o crtend.o crtn.o"
++ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o"
+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
+ ;;
+x86_64-*-serenity*)
-+ extra_parts="$extra_parts crti.o crtbegin.o crtend.o crtn.o"
++ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o"
+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
+ ;;
+arm-*-serenity*)
diff --git a/Toolchain/Patches/gcc.patch b/Toolchain/Patches/gcc.patch
index cfe7a4a360..40b32f4649 100644
--- a/Toolchain/Patches/gcc.patch
+++ b/Toolchain/Patches/gcc.patch
@@ -7,7 +7,7 @@ index 75bb6a313..da281fb48 100755
# Copyright 1992-2019 Free Software Foundation, Inc.
-timestamp='2019-01-01'
-+timestamp='2019-12-17'
++timestamp='2020-01-01'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -153,11 +153,11 @@ index 000000000..925c88dd6
+/* Files that are linked before user code.
+ The %s tells GCC to look for these files in the library directory. */
+#undef STARTFILE_SPEC
-+#define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s"
++#define STARTFILE_SPEC "%{!shared:crt0.o%s} crti.o%s %{shared:crtbeginS.o%s; :crtbegin.o%s}"
+
+/* Files that are linked after user code. */
+#undef ENDFILE_SPEC
-+#define ENDFILE_SPEC "crtend.o%s crtn.o%s"
++#define ENDFILE_SPEC "%{shared:crtendS.o%s; :crtend.o%s} crtn.o%s"
+
+#undef LINK_SPEC
+#define LINK_SPEC "%{shared:-shared} %{static:-static} %{!shared: %{!static: %{rdynamic:-export-dynamic}}}"
@@ -181,11 +181,11 @@ index 91abc84da..659376d14 100644
extra_parts="crt0.o"
;;
+i[34567]86-*-serenity*)
-+ extra_parts="$extra_parts crti.o crtbegin.o crtend.o crtn.o"
++ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o"
+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
+ ;;
+x86_64-*-serenity*)
-+ extra_parts="$extra_parts crti.o crtbegin.o crtend.o crtn.o"
++ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o"
+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
+ ;;
+arm-*-serenity*)