1From dfda505870f94a7ac8063eb47f622ddc65665ff1 Mon Sep 17 00:00:00 2001
2From: James Hilliard <james.hilliard1@gmail.com>
3Date: Tue, 14 Jun 2022 19:42:43 -0600
4Subject: [PATCH] Revert "Linux: Implement a useful version of _startup_fatal"
5
6Fixes:
7csu/libc-tls.c:202: undefined reference to `_startup_fatal_not_constant'
8
9This reverts commit 2d05ba7f8ef979947e910a37ae8115a816eb4d08.
10
11Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
12---
13 sysdeps/unix/sysv/linux/i386/startup.h | 23 ++++++++++++---
14 sysdeps/unix/sysv/linux/ia64/startup.h | 22 ---------------
15 sysdeps/unix/sysv/linux/startup.h      | 39 --------------------------
16 3 files changed, 19 insertions(+), 65 deletions(-)
17 delete mode 100644 sysdeps/unix/sysv/linux/ia64/startup.h
18 delete mode 100644 sysdeps/unix/sysv/linux/startup.h
19
20diff --git a/sysdeps/unix/sysv/linux/i386/startup.h b/sysdeps/unix/sysv/linux/i386/startup.h
21index 213805d7d2..67c9310f3a 100644
22--- a/sysdeps/unix/sysv/linux/i386/startup.h
23+++ b/sysdeps/unix/sysv/linux/i386/startup.h
24@@ -1,5 +1,5 @@
25 /* Linux/i386 definitions of functions used by static libc main startup.
26-   Copyright (C) 2022 Free Software Foundation, Inc.
27+   Copyright (C) 2017-2022 Free Software Foundation, Inc.
28    This file is part of the GNU C Library.
29
30    The GNU C Library is free software; you can redistribute it and/or
31@@ -16,7 +16,22 @@
32    License along with the GNU C Library; if not, see
33    <https://www.gnu.org/licenses/>.  */
34
35-/* Can't use "call *%gs:SYSINFO_OFFSET" during startup.  */
36-#define I386_USE_SYSENTER 0
37+#if BUILD_PIE_DEFAULT
38+/* Can't use "call *%gs:SYSINFO_OFFSET" during statup in static PIE.  */
39+# define I386_USE_SYSENTER 0
40
41-#include_next <startup.h>
42+# include <sysdep.h>
43+# include <abort-instr.h>
44+
45+__attribute__ ((__noreturn__))
46+static inline void
47+_startup_fatal (const char *message __attribute__ ((unused)))
48+{
49+  /* This is only called very early during startup in static PIE.
50+     FIXME: How can it be improved?  */
51+  ABORT_INSTRUCTION;
52+  __builtin_unreachable ();
53+}
54+#else
55+# include_next <startup.h>
56+#endif
57diff --git a/sysdeps/unix/sysv/linux/ia64/startup.h b/sysdeps/unix/sysv/linux/ia64/startup.h
58deleted file mode 100644
59index 77f29f15a2..0000000000
60--- a/sysdeps/unix/sysv/linux/ia64/startup.h
61+++ /dev/null
62@@ -1,22 +0,0 @@
63-/* Linux/ia64 definitions of functions used by static libc main startup.
64-   Copyright (C) 2022 Free Software Foundation, Inc.
65-   This file is part of the GNU C Library.
66-
67-   The GNU C Library is free software; you can redistribute it and/or
68-   modify it under the terms of the GNU Lesser General Public
69-   License as published by the Free Software Foundation; either
70-   version 2.1 of the License, or (at your option) any later version.
71-
72-   The GNU C Library is distributed in the hope that it will be useful,
73-   but WITHOUT ANY WARRANTY; without even the implied warranty of
74-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
75-   Lesser General Public License for more details.
76-
77-   You should have received a copy of the GNU Lesser General Public
78-   License along with the GNU C Library; if not, see
79-   <https://www.gnu.org/licenses/>.  */
80-
81-/* This code is used before the TCB is set up.  */
82-#define IA64_USE_NEW_STUB 0
83-
84-#include_next <startup.h>
85diff --git a/sysdeps/unix/sysv/linux/startup.h b/sysdeps/unix/sysv/linux/startup.h
86deleted file mode 100644
87index 39859b404a..0000000000
88--- a/sysdeps/unix/sysv/linux/startup.h
89+++ /dev/null
90@@ -1,39 +0,0 @@
91-/* Linux definitions of functions used by static libc main startup.
92-   Copyright (C) 2017-2022 Free Software Foundation, Inc.
93-   This file is part of the GNU C Library.
94-
95-   The GNU C Library is free software; you can redistribute it and/or
96-   modify it under the terms of the GNU Lesser General Public
97-   License as published by the Free Software Foundation; either
98-   version 2.1 of the License, or (at your option) any later version.
99-
100-   The GNU C Library is distributed in the hope that it will be useful,
101-   but WITHOUT ANY WARRANTY; without even the implied warranty of
102-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
103-   Lesser General Public License for more details.
104-
105-   You should have received a copy of the GNU Lesser General Public
106-   License along with the GNU C Library; if not, see
107-   <https://www.gnu.org/licenses/>.  */
108-
109-#ifdef SHARED
110-# include_next <startup.h>
111-#else
112-# include <sysdep.h>
113-
114-/* Avoid a run-time invocation of strlen.  */
115-#define _startup_fatal(message)                                         \
116-  do                                                                    \
117-    {                                                                   \
118-      size_t __message_length = __builtin_strlen (message);             \
119-      if (! __builtin_constant_p (__message_length))                    \
120-        {                                                               \
121-          extern void _startup_fatal_not_constant (void);               \
122-          _startup_fatal_not_constant ();                               \
123-        }                                                               \
124-      INTERNAL_SYSCALL_CALL (write, STDERR_FILENO, (message),           \
125-                             __message_length);                         \
126-      INTERNAL_SYSCALL_CALL (exit_group, 127);                          \
127-    }                                                                   \
128-  while (0)
129-#endif  /* !SHARED */
130--
1312.25.1
132
133