fd0330
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
fd0330
From: Robbie Harwood <rharwood@redhat.com>
fd0330
Date: Wed, 5 Jan 2022 16:42:11 -0500
fd0330
Subject: [PATCH] Drop gnulib no-abort.patch
fd0330
fd0330
Originally added in db7337a3d353a817ffe9eb4a3702120527100be9, this
fd0330
patched out all relevant invocations of abort() in gnulib.  While it was
fd0330
not documented why at the time, testing suggests that there's no abort()
fd0330
implementation available for gnulib to use.
fd0330
fd0330
gnulib's position is that the use of abort() is correct here, since it
fd0330
happens when input violates a "shall" from POSIX.  Additionally, the
fd0330
code in question is probably not reachable.  Since abort() is more
fd0330
friendly to user-space, they prefer to make no change, so we can just
fd0330
carry a define instead.  (Suggested by Paul Eggert.)
fd0330
fd0330
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
fd0330
(cherry picked from commit 5137c8eb3ec11c3217acea1a93a3f88f3fa4cbca)
fd0330
---
fd0330
 bootstrap.conf                              |  2 +-
fd0330
 conf/Makefile.extra-dist                    |  1 -
fd0330
 config.h.in                                 |  3 +++
fd0330
 grub-core/lib/gnulib-patches/no-abort.patch | 26 --------------------------
fd0330
 4 files changed, 4 insertions(+), 28 deletions(-)
fd0330
 delete mode 100644 grub-core/lib/gnulib-patches/no-abort.patch
fd0330
fd0330
diff --git a/bootstrap.conf b/bootstrap.conf
fd0330
index 645e3a459c..71ce943c7d 100644
fd0330
--- a/bootstrap.conf
fd0330
+++ b/bootstrap.conf
fd0330
@@ -81,7 +81,7 @@ cp -a INSTALL INSTALL.grub
fd0330
 bootstrap_post_import_hook () {
fd0330
   set -e
fd0330
   for patchname in fix-null-deref fix-null-state-deref fix-regcomp-uninit-token \
fd0330
-      fix-regexec-null-deref fix-uninit-structure fix-unused-value fix-width no-abort; do
fd0330
+      fix-regexec-null-deref fix-uninit-structure fix-unused-value fix-width; do
fd0330
     patch -d grub-core/lib/gnulib -p2 \
fd0330
       < "grub-core/lib/gnulib-patches/$patchname.patch"
fd0330
   done
fd0330
diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
fd0330
index f4791dc6ca..5eef708338 100644
fd0330
--- a/conf/Makefile.extra-dist
fd0330
+++ b/conf/Makefile.extra-dist
fd0330
@@ -38,7 +38,6 @@ EXTRA_DIST += grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch
fd0330
 EXTRA_DIST += grub-core/lib/gnulib-patches/fix-uninit-structure.patch
fd0330
 EXTRA_DIST += grub-core/lib/gnulib-patches/fix-unused-value.patch
fd0330
 EXTRA_DIST += grub-core/lib/gnulib-patches/fix-width.patch
fd0330
-EXTRA_DIST += grub-core/lib/gnulib-patches/no-abort.patch
fd0330
 
fd0330
 EXTRA_DIST += grub-core/lib/libgcrypt
fd0330
 EXTRA_DIST += grub-core/lib/libgcrypt-grub/mpi/generic
fd0330
diff --git a/config.h.in b/config.h.in
fd0330
index 9c7b4afaaa..c3134309c6 100644
fd0330
--- a/config.h.in
fd0330
+++ b/config.h.in
fd0330
@@ -68,6 +68,9 @@
fd0330
 
fd0330
 #  ifndef _GL_INLINE_HEADER_BEGIN
fd0330
 #    define _GL_ATTRIBUTE_CONST __attribute__ ((const))
fd0330
+
fd0330
+/* We don't have an abort() for gnulib to call in regexp. */
fd0330
+#    define abort __builtin_unreachable
fd0330
 #  endif /* !_GL_INLINE_HEADER_BEGIN */
fd0330
 
fd0330
 #endif
fd0330
diff --git a/grub-core/lib/gnulib-patches/no-abort.patch b/grub-core/lib/gnulib-patches/no-abort.patch
fd0330
deleted file mode 100644
fd0330
index e469c4762e..0000000000
fd0330
--- a/grub-core/lib/gnulib-patches/no-abort.patch
fd0330
+++ /dev/null
fd0330
@@ -1,26 +0,0 @@
fd0330
-diff --git a/lib/regcomp.c b/lib/regcomp.c
fd0330
-index cc85f35ac..de45ebb5c 100644
fd0330
---- a/lib/regcomp.c
fd0330
-+++ b/lib/regcomp.c
fd0330
-@@ -528,9 +528,9 @@ regerror (int errcode, const regex_t *__restrict preg, char *__restrict errbuf,
fd0330
-        to this routine.  If we are given anything else, or if other regex
fd0330
-        code generates an invalid error code, then the program has a bug.
fd0330
-        Dump core so we can fix it.  */
fd0330
--    abort ();
fd0330
--
fd0330
--  msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]);
fd0330
-+    msg = gettext ("unknown regexp error");
fd0330
-+  else
fd0330
-+    msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]);
fd0330
- 
fd0330
-   msg_size = strlen (msg) + 1; /* Includes the null.  */
fd0330
- 
fd0330
-@@ -1136,7 +1136,7 @@ optimize_utf8 (re_dfa_t *dfa)
fd0330
- 	}
fd0330
- 	break;
fd0330
-       default:
fd0330
--	abort ();
fd0330
-+	break;
fd0330
-       }
fd0330
- 
fd0330
-   if (mb_chars || has_period)