[PATCH] Fix version parsing and checks to also support gnu-efi >= 4.0

1 view
Skip to first unread message

Storm, Christian

unread,
Nov 20, 2025, 2:01:42 PM (6 days ago) Nov 20
to efibootg...@googlegroups.com
From: Christian Storm <christi...@siemens.com>

The current mechanism to parse gnu-efi's version is restricted to
gnu-efi 3.x series. Improve the calculation to also account for
gnu-efi 4.x series (and beyond).

Reported-by: Andreas Tobler <andreas...@onway.ch>
Signed-off-by: Christian Storm <christi...@siemens.com>
---
configure.ac | 6 +++---
drivers/watchdog/wdfuncs_end.c | 2 +-
drivers/watchdog/wdfuncs_start.c | 2 +-
main.c | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index d1c932b..7f22339 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,7 +40,7 @@ AC_PROG_CC
AC_CHECK_TOOL(LD, ld)
AC_CHECK_TOOL(OBJCOPY, objcopy)
AC_CHECK_TOOL(GREP, grep)
-AC_CHECK_TOOL(TR, tr)
+AC_CHECK_TOOL(AWK, awk)

dnl Dont try to use things like -std=c99 for efi compilation
GNUEFI_CC=$CC
@@ -232,9 +232,9 @@ if test "x$PKG_CONFIG" = "xno"; then
fi

# Note: gnu-efi introduced pkg-config with version 3.0.16
-# GNU_EFI_VERSION resolves to gnu-efi's version without dots, e.g., GNU_EFI_VERSION=3016
+# GNU_EFI_VERSION resolves to gnu-efi's version without dots, e.g., GNU_EFI_VERSION=3000016
# gnu-efi versions < 3.0.16 resolve to GNU_EFI_VERSION=0
-AC_SUBST([GNU_EFI_VERSION], [$( ($PKG_CONFIG --modversion "gnu-efi" 2>/dev/null || echo 0) | $TR -d '.' )])
+AC_SUBST([GNU_EFI_VERSION], [$( ($PKG_CONFIG --modversion "gnu-efi" 2>/dev/null || echo 0) | $AWK -F. '{print $1*1000000 + $2*1000 + $3}' )])
AC_DEFINE_UNQUOTED([GNU_EFI_VERSION], [${GNU_EFI_VERSION}], [gnu-efi version])

AC_SUBST([OBJCOPY_HAS_EFI_APP_TARGET], [$($OBJCOPY --info | $GREP -q pei- 2>/dev/null && echo "true")])
diff --git a/drivers/watchdog/wdfuncs_end.c b/drivers/watchdog/wdfuncs_end.c
index d19a0ab..f90ffc7 100644
--- a/drivers/watchdog/wdfuncs_end.c
+++ b/drivers/watchdog/wdfuncs_end.c
@@ -12,7 +12,7 @@
* SPDX-License-Identifier: GPL-2.0-only
*/

-#if GNU_EFI_VERSION < 3016
+#if GNU_EFI_VERSION < 3000016

#include <efi.h>
#include "utils.h"
diff --git a/drivers/watchdog/wdfuncs_start.c b/drivers/watchdog/wdfuncs_start.c
index bdf47f5..c627050 100644
--- a/drivers/watchdog/wdfuncs_start.c
+++ b/drivers/watchdog/wdfuncs_start.c
@@ -12,7 +12,7 @@
* SPDX-License-Identifier: GPL-2.0-only
*/

-#if GNU_EFI_VERSION < 3016
+#if GNU_EFI_VERSION < 3000016

#include <efi.h>
#include "utils.h"
diff --git a/main.c b/main.c
index 5d61385..b1bbc56 100644
--- a/main.c
+++ b/main.c
@@ -45,7 +45,7 @@ VOID register_watchdog(WATCHDOG_DRIVER *driver)

static EFI_STATUS probe_watchdogs(UINTN timeout)
{
-#if GNU_EFI_VERSION < 3016
+#if GNU_EFI_VERSION < 3000016
const unsigned long *entry = wdfuncs_start;
for (entry++; entry < wdfuncs_end; entry++) {
((void (*)(void))*entry)();
--
2.52.0

Jan Kiszka

unread,
Nov 21, 2025, 9:27:36 AM (5 days ago) Nov 21
to Storm, Christian, efibootg...@googlegroups.com
Thanks applied.

Jan

PS: Triggered https://bugzilla.mozilla.org/show_bug.cgi?id=2001632 with
my patch tooling. No idea yet what makes this "special".

--
Siemens AG, Foundational Technologies
Linux Expert Center
Reply all
Reply to author
Forward
0 new messages