Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 May 2026 02:45:11 +0000
From:      Ahmad Khalifa <vexeduxr@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: d15cc7625dde - main - stand: compile ia32 EFI loader with -malign-double
Message-ID:  <6a1a4f37.31c8e.265484b8@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by vexeduxr:

URL: https://cgit.FreeBSD.org/src/commit/?id=d15cc7625dde9bcb6a63ee59cccf14f3b93b15bf

commit d15cc7625dde9bcb6a63ee59cccf14f3b93b15bf
Author:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
AuthorDate: 2026-05-30 02:40:39 +0000
Commit:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
CommitDate: 2026-05-30 02:40:39 +0000

    stand: compile ia32 EFI loader with -malign-double
    
    The UEFI spec says:
    > Structures are aligned on boundaries equal to the largest internal
    > datum of the structure and internal data are implicitly padded to
    > achieve natural alignment.
    
    Unlike the old Intel EFI toolkit, the EDK2 headers expect ia32 builds to
    use -malign-double to achive this.
    
    Make EFI versions of libsa32, liblua32, and ficl32. With the difference
    being that they are compiled with -malign-double.
    
    Differential Revision:  https://reviews.freebsd.org/D55385
---
 stand/defs.mk                  | 2 +-
 stand/efi/Makefile             | 8 +++++++-
 stand/efi/Makefile.inc         | 5 +++++
 stand/efi/ficl32efi/Makefile   | 3 +++
 stand/efi/liblua32efi/Makefile | 3 +++
 stand/efi/libsa32efi/Makefile  | 1 +
 stand/loader.mk                | 4 ++--
 7 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/stand/defs.mk b/stand/defs.mk
index 7f3803c7ab42..ac4f38451111 100644
--- a/stand/defs.mk
+++ b/stand/defs.mk
@@ -78,7 +78,7 @@ LIBSA=		${BOOTOBJ}/libsa/libsa.a
 .if ${MACHINE} == "i386"
 LIBSA32=	${LIBSA}
 .else
-LIBSA32=	${BOOTOBJ}/libsa32/libsa32.a
+LIBSA32=	${BOOTOBJ}/${"${LOADER}" == "loader_ia32":?efi/libsa32efi:libsa32}/libsa32.a
 .endif
 
 # Standard options:
diff --git a/stand/efi/Makefile b/stand/efi/Makefile
index 1887b9536a5b..5ece7eff8ef2 100644
--- a/stand/efi/Makefile
+++ b/stand/efi/Makefile
@@ -3,12 +3,18 @@ NO_OBJ=t
 .include <bsd.init.mk>
 
 SUBDIR.yes+=	libefi
-SUBDIR.${MK_LOADER_IA32}+=	libefi32
+SUBDIR.${MK_LOADER_IA32}+=	libsa32efi libefi32
 SUBDIR.${MK_FDT}+=	fdt
 SUBDIR.yes+=	.WAIT
 
 SUBDIR.yes+=	boot1 gptboot
 
+.if ${LOADER_DEFAULT_INTERP} == "lua"
+SUBDIR.${MK_LOADER_IA32}+=	liblua32efi
+.elif ${LOADER_DEFAULT_INTERP} == "4th"
+SUBDIR.${MK_LOADER_IA32}+=	ficl32efi
+.endif
+
 SUBDIR.${MK_FORTH}+= loader_4th
 SUBDIR.${MK_LOADER_LUA}+= loader_lua
 SUBDIR.${MK_LOADER_IA32}+= loader_ia32
diff --git a/stand/efi/Makefile.inc b/stand/efi/Makefile.inc
index 6bb0af1d84f3..452820aeeb32 100644
--- a/stand/efi/Makefile.inc
+++ b/stand/efi/Makefile.inc
@@ -8,6 +8,11 @@ LDFLAGS+=	-nostdlib
 .if ${MACHINE_CPUARCH} == "amd64"
 CFLAGS+=	-fshort-wchar
 CFLAGS+=	-mno-red-zone
+.if ${DO32:U0} == 1
+# This is needed so the EDK2 EFI structs have the correct layout for
+# the ia32 loader.
+CFLAGS+=	-malign-double
+.endif
 .endif
 
 .if ${MACHINE_CPUARCH} == "aarch64"
diff --git a/stand/efi/ficl32efi/Makefile b/stand/efi/ficl32efi/Makefile
new file mode 100644
index 000000000000..63800cb0f209
--- /dev/null
+++ b/stand/efi/ficl32efi/Makefile
@@ -0,0 +1,3 @@
+DO32=1
+
+.include "${.CURDIR}/../../ficl/Makefile"
diff --git a/stand/efi/liblua32efi/Makefile b/stand/efi/liblua32efi/Makefile
new file mode 100644
index 000000000000..cf391967ecf0
--- /dev/null
+++ b/stand/efi/liblua32efi/Makefile
@@ -0,0 +1,3 @@
+DO32=1
+
+.include "${.CURDIR}/../../liblua/Makefile"
diff --git a/stand/efi/libsa32efi/Makefile b/stand/efi/libsa32efi/Makefile
new file mode 100644
index 000000000000..109c420bf734
--- /dev/null
+++ b/stand/efi/libsa32efi/Makefile
@@ -0,0 +1 @@
+.include "${.CURDIR}/../../libsa32/Makefile"
diff --git a/stand/loader.mk b/stand/loader.mk
index 496252e7a534..0d94ed3e6263 100644
--- a/stand/loader.mk
+++ b/stand/loader.mk
@@ -162,14 +162,14 @@ LIBFICL=	${BOOTOBJ}/ficl/libficl.a
 .if ${MACHINE} == "i386"
 LIBFICL32=	${LIBFICL}
 .else
-LIBFICL32=	${BOOTOBJ}/ficl32/libficl.a
+LIBFICL32=	${BOOTOBJ}/${"${LOADER}" == "loader_ia32":?efi/ficl32efi:ficl32}/libficl.a
 .endif
 
 LIBLUA=		${BOOTOBJ}/liblua/liblua.a
 .if ${MACHINE} == "i386"
 LIBLUA32=	${LIBLUA}
 .else
-LIBLUA32=	${BOOTOBJ}/liblua32/liblua.a
+LIBLUA32=	${BOOTOBJ}/${"${LOADER}" == "loader_ia32":?efi/liblua32efi:liblua32}/liblua.a
 .endif
 
 CLEANFILES+=	vers.c


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a1a4f37.31c8e.265484b8>