public inbox for grub-devel@gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Improve ld.lld-21+ compatibility when building i386-pc target
@ 2026-01-26 11:59 Nicholas Vinson
  2026-01-26 11:59 ` [PATCH 1/5] i386/pc/int.h: conditionally apply regparm attr Nicholas Vinson
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Nicholas Vinson @ 2026-01-26 11:59 UTC (permalink / raw)
  To: grub-devel; +Cc: Nicholas Vinson, floppym, dkiper

Starting with ld.llvm-21, any attempt create a non-relocatable binary and set
one more secton addresses below 0x400000 results in a linker error. Furthermore,
the differences between ld.bfd and ld.lld made finding a proper set of
command-line flags tht worked with both linkers and bypass the image base
address restriction difficult. Therefore, the approach of using a custom linker
script was adopted to solve the issue.

This approach was tested using:

../configure CC=clang CXX=clang++ LDFLAGS="-fuse-ld=lld" TARGET_LDFLAGS="-fuse-ld=lld" --with-platform=pc
../configure CC=clang CXX=clang++ --with-platform=pc (both with ld.lld as the default and ld.bfd as the default)
../configure CC=gcc CXX=g++ --with-platform=pc

and a VM was used for testing. To build the disk images the VM was booted with,
the following scripts were used:

EFI disk:
--- /dev/null	2026-01-18 13:24:44.262332704 -0500
+++ efi_disk_image.sh	2026-01-25 11:17:33.554420324 -0500
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+set -xe
+
+dd if=/dev/zero of=grub.img bs=1M count=100 status=progress
+
+sfdisk --force --no-reread --no-tell-kernel grub.img <<EOF
+label: gpt
+label-id: ABEB6772-65C7-4391-BF21-B616916286B9
+size=1M, type=21686148-6449-6E6F-744E-656564454649, uuid=9892A604-439E-4401-A372-AAD5E99EADBB
+type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=FCE5EBB3-C887-4FDE-93C5-7670CC3914BF
+EOF
+
+LOOP_DEV=$(losetup --show -fP grub.img)
+sleep 1
+
+mkfs.ext4 -F "${LOOP_DEV}p2"
+
+mount "${LOOP_DEV}p2" /mnt/gentoo
+./grub-install -v --directory ./grub-core --locale-directory /usr/share/locale --boot-directory=/mnt/gentoo "${LOOP_DEV}"
+
+umount "${LOOP_DEV}p2"
+losetup -d "${LOOP_DEV}"
-- 

MBR image:
--- /dev/null	2026-01-18 13:24:44.262332704 -0500
+++ mbr_disk_image.sh	2026-01-25 11:17:24.129208591 -0500
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+set -xe
+
+dd if=/dev/zero of=grub.img bs=1M count=100 status=progress
+
+sfdisk --force --no-reread --no-tell-kernel grub.img <<EOF
+label: dos
+label-id: 0x12345678
+type=83, bootable
+EOF
+
+LOOP_DEV=$(losetup --show -fP grub.img)
+sleep 1
+
+mkfs.ext4 -F -O ^has_journal "${LOOP_DEV}p1"
+
+mount "${LOOP_DEV}p1" /mnt/gentoo
+./grub-install -v --directory ./grub-core --locale-directory /usr/share/locale --boot-directory=/mnt/gentoo "${LOOP_DEV}"
+
+umount "${LOOP_DEV}p1"
+losetup -d "${LOOP_DEV}"
-- 

In all cases, the VM successfully booted to the standard GRUB prompt.

Nicholas Vinson (5):
  i386/pc/int.h: conditionally apply regparm attr.
  grub-core: Update kernel image generation
  Revert "configure: Print a more helpful error if autoconf-archive is
    not installed"
  Revert "configure: Check linker for --image-base support"
  configure: drop -Ttext checks for i386-pc

 acinclude.m4                | 18 +++++++++++------
 conf/Makefile.extra-dist    |  1 +
 conf/i386-pc-kernel.ld      | 38 +++++++++++++++++++++++++++++++++++
 configure.ac                | 38 ++++++++++++++++++-----------------
 grub-core/Makefile.core.def | 40 +++++++++++++++++++++++++++----------
 include/grub/i386/pc/int.h  |  5 ++++-
 6 files changed, 105 insertions(+), 35 deletions(-)
 create mode 100644 conf/i386-pc-kernel.ld

-- 
2.52.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/5] i386/pc/int.h: conditionally apply regparm attr.
  2026-01-26 11:59 [PATCH 0/5] Improve ld.lld-21+ compatibility when building i386-pc target Nicholas Vinson
@ 2026-01-26 11:59 ` Nicholas Vinson
  2026-01-27 14:48   ` Daniel Kiper
  2026-01-26 11:59 ` [PATCH 2/5] grub-core: Update kernel image generation Nicholas Vinson
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Nicholas Vinson @ 2026-01-26 11:59 UTC (permalink / raw)
  To: grub-devel; +Cc: Nicholas Vinson, floppym, dkiper

Modern compilers are becoming more strict and are starting to warn when
certain attributs are ignored. The regparam attribute is such an
attribute.

Update the code so the regparam attribute is only appled when building
against i386 targets as that is the only scenario when it is not
ignored.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
---
 include/grub/i386/pc/int.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/grub/i386/pc/int.h b/include/grub/i386/pc/int.h
index a60104001..4b569ca25 100644
--- a/include/grub/i386/pc/int.h
+++ b/include/grub/i386/pc/int.h
@@ -24,7 +24,10 @@
 
 void EXPORT_FUNC (grub_bios_interrupt) (grub_uint8_t intno,
 					struct grub_bios_int_registers *regs)
-     __attribute__ ((regparm(3)));
+#if defined(__i386__) && !defined(__x86_64__)
+     __attribute__ ((regparm(3)))
+#endif
+;
 
 #ifdef GRUB_MACHINE_PCBIOS
 extern struct grub_i386_idt *EXPORT_VAR(grub_realidt);
-- 
2.52.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/5] grub-core: Update kernel image generation
  2026-01-26 11:59 [PATCH 0/5] Improve ld.lld-21+ compatibility when building i386-pc target Nicholas Vinson
  2026-01-26 11:59 ` [PATCH 1/5] i386/pc/int.h: conditionally apply regparm attr Nicholas Vinson
@ 2026-01-26 11:59 ` Nicholas Vinson
  2026-01-27 15:41   ` Daniel Kiper
  2026-01-26 11:59 ` [PATCH 3/5] Revert "configure: Print a more helpful error if autoconf-archive is not installed" Nicholas Vinson
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Nicholas Vinson @ 2026-01-26 11:59 UTC (permalink / raw)
  To: grub-devel; +Cc: Nicholas Vinson, floppym, dkiper

The i386-pc kernel image fails to build because of changes made to
address ld.lld-21 and newer linking issues. Specifically, with
ld.lld-21, if you try to set the text section address below image base
address when linking a non-relocatable binary, ld.lld wil fail to link.

Switching to using a customized linker script solves the issue.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
---
 conf/Makefile.extra-dist    |  1 +
 conf/i386-pc-kernel.ld      | 38 +++++++++++++++++++++++++++++++++++
 grub-core/Makefile.core.def | 40 +++++++++++++++++++++++++++----------
 3 files changed, 69 insertions(+), 10 deletions(-)
 create mode 100644 conf/i386-pc-kernel.ld

diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
index d22b6c862..fd904cd33 100644
--- a/conf/Makefile.extra-dist
+++ b/conf/Makefile.extra-dist
@@ -17,6 +17,7 @@ EXTRA_DIST += docs/grub.cfg
 EXTRA_DIST += docs/osdetect.cfg
 
 EXTRA_DIST += conf/i386-cygwin-img-ld.sc
+EXTRA_DIST += conf/i386-pc-kernel.ld
 
 EXTRA_DIST += grub-core/Makefile.core.def
 EXTRA_DIST += grub-core/Makefile.gcry.def
diff --git a/conf/i386-pc-kernel.ld b/conf/i386-pc-kernel.ld
new file mode 100644
index 000000000..80d5734b3
--- /dev/null
+++ b/conf/i386-pc-kernel.ld
@@ -0,0 +1,38 @@
+ENTRY(_start)
+
+PHDRS {
+    text PT_LOAD FLAGS(7);
+}
+
+SECTIONS
+{
+    . = _grub_text_base;
+    .text : {
+        _start = .;
+        *(.text .text.*)
+    } :text
+    .rodata : {
+        *(.rodata .rodata.*)
+    } :text
+    .module_license : {
+        *(.module_license)
+    } :text
+    .data : {
+        *(.data .data.*)
+        . = ALIGN(0x10);
+        _edata = .;
+    } :text
+    .bss : {
+        __bss_start = .;
+        *(.bss .bss.*)
+        *(COMMON)
+        . = ALIGN(0x10);
+        _end = .;
+    } :text
+    /DISCARD/ : {
+        *(.interp)
+        *(.note*)
+        *(.comment)
+        *(.build-id)
+    }
+}
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 0cf155128..7cc7963c7 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -82,7 +82,8 @@ kernel = {
   riscv64_efi_stripflags   = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame';
 
   i386_pc_ldflags          = '$(TARGET_IMG_LDFLAGS)';
-  i386_pc_ldflags          = '$(TARGET_IMG_BASE_LDOPT),0x9000';
+  i386_pc_ldflags          = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
+  i386_pc_ldflags          = '$(TARGET_IMG_BASE_LDOPT)=0x9000';
   i386_qemu_ldflags        = '$(TARGET_IMG_LDFLAGS)';
   i386_qemu_ldflags        = '$(TARGET_IMG_BASE_LDOPT),0x9000';
   i386_coreboot_ldflags    = '$(TARGET_IMG_LDFLAGS)';
@@ -449,8 +450,11 @@ image = {
   i386_qemu = boot/i386/qemu/boot.S;
   sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S;
 
+  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
+
   i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
-  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
+  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
+  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x7C00';
 
   i386_qemu_ldflags = '$(TARGET_IMG_LDFLAGS)';
   i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),$(GRUB_BOOT_MACHINE_LINK_ADDR)';
@@ -475,10 +479,13 @@ image = {
   name = boot_hybrid;
   i386_pc = boot/i386/pc/boot.S;
 
+  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
+
   cppflags = '-DHYBRID_BOOT=1';
   
   i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
-  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
+  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
+  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x7C00';
 
   objcopyflags = '-O binary';
   enable = i386_pc;
@@ -486,10 +493,13 @@ image = {
 
 image = {
   name = cdboot;
-
   i386_pc = boot/i386/pc/cdboot.S;
+
+  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
+
   i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
-  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
+  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
+  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x7C00';
 
   sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S;
 
@@ -508,8 +518,11 @@ image = {
   name = pxeboot;
   i386_pc = boot/i386/pc/pxeboot.S;
 
+  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
+
   i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
-  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
+  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
+  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x7C00';
 
   objcopyflags = '-O binary';
   enable = i386_pc;
@@ -519,8 +532,11 @@ image = {
   name = diskboot;
   i386_pc = boot/i386/pc/diskboot.S;
 
+  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
+
   i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
-  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x8000';
+  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
+  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x8000';
 
   sparc64_ieee1275 = boot/sparc64/ieee1275/diskboot.S;
   sparc64_ieee1275_ldflags = '-Wl,-Ttext=0x4200';
@@ -535,8 +551,11 @@ image = {
   name = lnxboot;
   i386_pc = boot/i386/pc/lnxboot.S;
 
+  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
+
   i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
-  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x6000';
+  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
+  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x6000';
 
   objcopyflags = '-O binary';
   enable = i386_pc;
@@ -576,10 +595,11 @@ image = {
   name = lzma_decompress;
   i386_pc = boot/i386/pc/startup_raw.S;
   i386_pc_nodist = rs_decoder.h;
+  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
 
   objcopyflags = '-O binary';
-  ldflags = '$(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x8200';
-  enable = i386_pc;
+  ldflags = '$(TARGET_IMG_LDFLAGS) -Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld $(TARGET_IMG_BASE_LDOPT)=0x8200';
+  lnable = i386_pc;
 };
 
 image = {
-- 
2.52.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/5] Revert "configure: Print a more helpful error if autoconf-archive is not installed"
  2026-01-26 11:59 [PATCH 0/5] Improve ld.lld-21+ compatibility when building i386-pc target Nicholas Vinson
  2026-01-26 11:59 ` [PATCH 1/5] i386/pc/int.h: conditionally apply regparm attr Nicholas Vinson
  2026-01-26 11:59 ` [PATCH 2/5] grub-core: Update kernel image generation Nicholas Vinson
@ 2026-01-26 11:59 ` Nicholas Vinson
  2026-01-27 16:35   ` Daniel Kiper
  2026-01-26 11:59 ` [PATCH 4/5] Revert "configure: Check linker for --image-base support" Nicholas Vinson
  2026-01-26 11:59 ` [PATCH 5/5] configure: drop -Ttext checks for i386-pc Nicholas Vinson
  4 siblings, 1 reply; 14+ messages in thread
From: Nicholas Vinson @ 2026-01-26 11:59 UTC (permalink / raw)
  To: grub-devel; +Cc: Nicholas Vinson, floppym, dkiper

This reverts commit ac042f3f58d33ce9cd5ff61750f06da1a1d7b0eb.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
---
 configure.ac | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index d8ca1b7c1..45f19f188 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1792,11 +1792,6 @@ LIBS=""
 # Defined in acinclude.m4.
 grub_ASM_USCORE
 grub_PROG_TARGET_CC
-
-# The error message produced by autoconf if autoconf-archive is not installed is
-# quite misleading and not very helpful. So, try point people in the right direction.
-m4_ifndef([AX_CHECK_LINK_FLAG], [m4_fatal([autoconf-archive is missing. You must install it to generate the configure script.])])
-
 if test "x$TARGET_APPLE_LINKER" != x1 ; then
 AX_CHECK_LINK_FLAG([-Wl,--image-base,0x400000],
     [TARGET_IMG_BASE_LDOPT="-Wl,--image-base"],
-- 
2.52.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/5] Revert "configure: Check linker for --image-base support"
  2026-01-26 11:59 [PATCH 0/5] Improve ld.lld-21+ compatibility when building i386-pc target Nicholas Vinson
                   ` (2 preceding siblings ...)
  2026-01-26 11:59 ` [PATCH 3/5] Revert "configure: Print a more helpful error if autoconf-archive is not installed" Nicholas Vinson
@ 2026-01-26 11:59 ` Nicholas Vinson
  2026-01-27 16:36   ` Daniel Kiper
  2026-01-26 11:59 ` [PATCH 5/5] configure: drop -Ttext checks for i386-pc Nicholas Vinson
  4 siblings, 1 reply; 14+ messages in thread
From: Nicholas Vinson @ 2026-01-26 11:59 UTC (permalink / raw)
  To: grub-devel; +Cc: Nicholas Vinson, floppym, dkiper

This reverts commit 1a5417f39a0ccefcdd5440f2a67f84d2d2e26960.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
---
 acinclude.m4 |  5 -----
 configure.ac | 14 ++------------
 2 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index 70c1912f8..fa7840f09 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -79,11 +79,6 @@ AC_DEFUN([grub_PROG_OBJCOPY_ABSOLUTE],
 [AC_MSG_CHECKING([whether ${TARGET_OBJCOPY} works for absolute addresses])
 AC_CACHE_VAL(grub_cv_prog_objcopy_absolute,
 [cat > conftest.c <<\EOF
-asm (
-    ".globl start, _start, __start\n"
-    ".ifdef cmain; .set start = _start = __start = cmain\n.endif\n"
-    ".ifdef _cmain; .set start = _start = __start = _cmain\n.endif\n"
-);
 void cmain (void);
 void
 cmain (void)
diff --git a/configure.ac b/configure.ac
index 45f19f188..209c0fb11 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1461,6 +1461,7 @@ elif test x$grub_cv_target_cc_link_format = x-mi386pe || test x$grub_cv_target_c
   TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/conf/i386-cygwin-img-ld.sc"
   TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
   TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/i386-cygwin-img-ld.sc"
+  TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
   TARGET_IMG_CFLAGS=
 else
   TARGET_APPLE_LINKER=0
@@ -1468,6 +1469,7 @@ else
   TARGET_IMG_LDSCRIPT=
   TARGET_IMG_LDFLAGS='-Wl,-N'
   TARGET_IMG_LDFLAGS_AC='-Wl,-N'
+  TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
   TARGET_IMG_CFLAGS=
 fi
 
@@ -1793,18 +1795,6 @@ LIBS=""
 grub_ASM_USCORE
 grub_PROG_TARGET_CC
 if test "x$TARGET_APPLE_LINKER" != x1 ; then
-AX_CHECK_LINK_FLAG([-Wl,--image-base,0x400000],
-    [TARGET_IMG_BASE_LDOPT="-Wl,--image-base"],
-    [TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"],
-    [],
-    [AC_LANG_SOURCE([
-asm (".globl start; start:");
-asm (".globl _start; _start:");
-asm (".globl __start; __start:");
-void __main (void);
-void __main (void) {}
-int main (void);
-    ])])
 grub_PROG_OBJCOPY_ABSOLUTE
 fi
 grub_PROG_LD_BUILD_ID_NONE
-- 
2.52.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/5] configure: drop -Ttext checks for i386-pc
  2026-01-26 11:59 [PATCH 0/5] Improve ld.lld-21+ compatibility when building i386-pc target Nicholas Vinson
                   ` (3 preceding siblings ...)
  2026-01-26 11:59 ` [PATCH 4/5] Revert "configure: Check linker for --image-base support" Nicholas Vinson
@ 2026-01-26 11:59 ` Nicholas Vinson
  2026-01-27 17:24   ` Daniel Kiper
  4 siblings, 1 reply; 14+ messages in thread
From: Nicholas Vinson @ 2026-01-26 11:59 UTC (permalink / raw)
  To: grub-devel; +Cc: Nicholas Vinson, floppym, dkiper

The i386-pc target now uses a linker script, so -Ttext is no longer
required.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
---
 acinclude.m4 | 13 ++++++++++++-
 configure.ac | 21 +++++++++++++++++++--
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index fa7840f09..478aab6d3 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -93,7 +93,18 @@ else
 fi
 grub_cv_prog_objcopy_absolute=yes
 for link_addr in 0x2000 0x8000 0x7C00; do
-  if AC_TRY_COMMAND([${CC-cc} ${TARGET_CFLAGS} ${TARGET_LDFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},$link_addr conftest.o -o conftest.exec]); then :
+
+  target_img_base_ld="${TARGET_IMG_BASE_LDOPT}"
+  case "$target_img_base_ld" in
+    *_grub_text_base)
+      target_img_base_ld="${target_img_base_ld}=$link_addr"
+    ;;
+    *)
+      target_img_base_ld="${target_img_base_ld},$link_addr"
+    ;;
+  esac
+
+  if AC_TRY_COMMAND([${CC-cc} ${TARGET_CFLAGS} ${TARGET_LDFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${target_img_base_ld} conftest.o -o conftest.exec]); then :
   else
     AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr])
   fi
diff --git a/configure.ac b/configure.ac
index 209c0fb11..5207a8a35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1469,7 +1469,13 @@ else
   TARGET_IMG_LDSCRIPT=
   TARGET_IMG_LDFLAGS='-Wl,-N'
   TARGET_IMG_LDFLAGS_AC='-Wl,-N'
-  TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
+  if test "x$target_cpu-$platform" != "xi386-pc"; then
+    TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
+  else
+    TARGET_IMG_BASE_LDOPT="-Wl,--defsym,_grub_text_base"
+    TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/conf/i386-pc-kernel.ld"
+    TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/i386-pc-kernel.ld"
+  fi
   TARGET_IMG_CFLAGS=
 fi
 
@@ -1802,7 +1808,18 @@ if test "x$target_cpu" = xi386; then
   if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then
     if test ! -z "$TARGET_IMG_LDSCRIPT"; then
       # Check symbols provided by linker script.
-      CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000"
+      target_img_base_ld="${TARGET_IMG_BASE_LDOPT}"
+      case "$target_img_base_ld" in
+        *_grub_text_base)
+          target_img_base_ld="${target_img_base_ld}="
+        ;;
+        *)
+          target_img_base_ld="${target_img_base_ld},"
+        ;;
+      esac
+      target_img_base_ld="${target_img_base_ld}0x8000"
+      CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${target_img_base_ld}"
+      target_img_base_ld=""
     fi
     grub_CHECK_BSS_START_SYMBOL
     grub_CHECK_END_SYMBOL
-- 
2.52.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/5] i386/pc/int.h: conditionally apply regparm attr.
  2026-01-26 11:59 ` [PATCH 1/5] i386/pc/int.h: conditionally apply regparm attr Nicholas Vinson
@ 2026-01-27 14:48   ` Daniel Kiper
  0 siblings, 0 replies; 14+ messages in thread
From: Daniel Kiper @ 2026-01-27 14:48 UTC (permalink / raw)
  To: Nicholas Vinson; +Cc: grub-devel, floppym

On Mon, Jan 26, 2026 at 06:59:32AM -0500, Nicholas Vinson wrote:
> Modern compilers are becoming more strict and are starting to warn when
> certain attributs are ignored. The regparam attribute is such an
> attribute.
>
> Update the code so the regparam attribute is only appled when building
> against i386 targets as that is the only scenario when it is not
> ignored.
>
> Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] grub-core: Update kernel image generation
  2026-01-26 11:59 ` [PATCH 2/5] grub-core: Update kernel image generation Nicholas Vinson
@ 2026-01-27 15:41   ` Daniel Kiper
  2026-02-03 14:08     ` Nicholas Vinson
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Kiper @ 2026-01-27 15:41 UTC (permalink / raw)
  To: Nicholas Vinson; +Cc: grub-devel, floppym

On Mon, Jan 26, 2026 at 06:59:33AM -0500, Nicholas Vinson wrote:
> The i386-pc kernel image fails to build because of changes made to
> address ld.lld-21 and newer linking issues. Specifically, with
> ld.lld-21, if you try to set the text section address below image base
> address when linking a non-relocatable binary, ld.lld wil fail to link.

I think in first place it begs for explanation why this is correct in our
case. Should not we fix our builds to make newer linkers happy?

> Switching to using a customized linker script solves the issue.
>
> Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
> ---
>  conf/Makefile.extra-dist    |  1 +
>  conf/i386-pc-kernel.ld      | 38 +++++++++++++++++++++++++++++++++++
>  grub-core/Makefile.core.def | 40 +++++++++++++++++++++++++++----------
>  3 files changed, 69 insertions(+), 10 deletions(-)
>  create mode 100644 conf/i386-pc-kernel.ld
>
> diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
> index d22b6c862..fd904cd33 100644
> --- a/conf/Makefile.extra-dist
> +++ b/conf/Makefile.extra-dist
> @@ -17,6 +17,7 @@ EXTRA_DIST += docs/grub.cfg
>  EXTRA_DIST += docs/osdetect.cfg
>
>  EXTRA_DIST += conf/i386-cygwin-img-ld.sc
> +EXTRA_DIST += conf/i386-pc-kernel.ld
>
>  EXTRA_DIST += grub-core/Makefile.core.def
>  EXTRA_DIST += grub-core/Makefile.gcry.def
> diff --git a/conf/i386-pc-kernel.ld b/conf/i386-pc-kernel.ld
> new file mode 100644
> index 000000000..80d5734b3
> --- /dev/null
> +++ b/conf/i386-pc-kernel.ld

s/ld/lds/ and I would rename i386-cygwin-img-ld.sc to
i386-cygwin-img-ld.lds too. Of course in separate patch...

> @@ -0,0 +1,38 @@
> +ENTRY(_start)
> +
> +PHDRS {
> +    text PT_LOAD FLAGS(7);

text PT_LOAD FLAGS(7); /* PF_R | PF_W | PF_X */

> +}
> +
> +SECTIONS
> +{
> +    . = _grub_text_base;
> +    .text : {
> +        _start = .;
> +        *(.text .text.*)
> +    } :text
> +    .rodata : {
> +        *(.rodata .rodata.*)
> +    } :text
> +    .module_license : {
> +        *(.module_license)
> +    } :text
> +    .data : {
> +        *(.data .data.*)
> +        . = ALIGN(0x10);

Where does this number come from? And I would define a constant at the
beginning of the linker script...

> +        _edata = .;
> +    } :text
> +    .bss : {
> +        __bss_start = .;
> +        *(.bss .bss.*)
> +        *(COMMON)
> +        . = ALIGN(0x10);

Ditto...

> +        _end = .;
> +    } :text
> +    /DISCARD/ : {
> +        *(.interp)
> +        *(.note*)
> +        *(.comment)
> +        *(.build-id)
> +    }
> +}
> diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
> index 0cf155128..7cc7963c7 100644
> --- a/grub-core/Makefile.core.def
> +++ b/grub-core/Makefile.core.def
> @@ -82,7 +82,8 @@ kernel = {
>    riscv64_efi_stripflags   = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame';
>
>    i386_pc_ldflags          = '$(TARGET_IMG_LDFLAGS)';
> -  i386_pc_ldflags          = '$(TARGET_IMG_BASE_LDOPT),0x9000';
> +  i386_pc_ldflags          = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
> +  i386_pc_ldflags          = '$(TARGET_IMG_BASE_LDOPT)=0x9000';

Could not we stick to "," and do not make a change to "="?

>    i386_qemu_ldflags        = '$(TARGET_IMG_LDFLAGS)';
>    i386_qemu_ldflags        = '$(TARGET_IMG_BASE_LDOPT),0x9000';
>    i386_coreboot_ldflags    = '$(TARGET_IMG_LDFLAGS)';
> @@ -449,8 +450,11 @@ image = {
>    i386_qemu = boot/i386/qemu/boot.S;
>    sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S;
>
> +  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
> +
>    i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
> -  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
> +  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
> +  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x7C00';

Ditto...

>    i386_qemu_ldflags = '$(TARGET_IMG_LDFLAGS)';
>    i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),$(GRUB_BOOT_MACHINE_LINK_ADDR)';
> @@ -475,10 +479,13 @@ image = {
>    name = boot_hybrid;
>    i386_pc = boot/i386/pc/boot.S;
>
> +  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
> +
>    cppflags = '-DHYBRID_BOOT=1';
>
>    i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
> -  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
> +  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
> +  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x7C00';

Ditto and below...

>    objcopyflags = '-O binary';
>    enable = i386_pc;
> @@ -486,10 +493,13 @@ image = {
>
>  image = {
>    name = cdboot;
> -

Please drop this change...

>    i386_pc = boot/i386/pc/cdboot.S;
> +
> +  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
> +
>    i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
> -  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
> +  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
> +  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x7C00';
>
>    sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S;
>
> @@ -508,8 +518,11 @@ image = {
>    name = pxeboot;
>    i386_pc = boot/i386/pc/pxeboot.S;
>
> +  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
> +
>    i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
> -  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
> +  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
> +  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x7C00';
>
>    objcopyflags = '-O binary';
>    enable = i386_pc;
> @@ -519,8 +532,11 @@ image = {
>    name = diskboot;
>    i386_pc = boot/i386/pc/diskboot.S;
>
> +  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
> +
>    i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
> -  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x8000';
> +  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
> +  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x8000';
>
>    sparc64_ieee1275 = boot/sparc64/ieee1275/diskboot.S;
>    sparc64_ieee1275_ldflags = '-Wl,-Ttext=0x4200';
> @@ -535,8 +551,11 @@ image = {
>    name = lnxboot;
>    i386_pc = boot/i386/pc/lnxboot.S;
>
> +  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
> +
>    i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
> -  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x6000';
> +  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
> +  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x6000';
>
>    objcopyflags = '-O binary';
>    enable = i386_pc;
> @@ -576,10 +595,11 @@ image = {
>    name = lzma_decompress;
>    i386_pc = boot/i386/pc/startup_raw.S;
>    i386_pc_nodist = rs_decoder.h;
> +  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
>
>    objcopyflags = '-O binary';
> -  ldflags = '$(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x8200';
> -  enable = i386_pc;
> +  ldflags = '$(TARGET_IMG_LDFLAGS) -Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld $(TARGET_IMG_BASE_LDOPT)=0x8200';
> +  lnable = i386_pc;

Hmmm... Looks like a mistake...

Daniel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/5] Revert "configure: Print a more helpful error if autoconf-archive is not installed"
  2026-01-26 11:59 ` [PATCH 3/5] Revert "configure: Print a more helpful error if autoconf-archive is not installed" Nicholas Vinson
@ 2026-01-27 16:35   ` Daniel Kiper
  0 siblings, 0 replies; 14+ messages in thread
From: Daniel Kiper @ 2026-01-27 16:35 UTC (permalink / raw)
  To: Nicholas Vinson; +Cc: grub-devel, floppym

On Mon, Jan 26, 2026 at 06:59:34AM -0500, Nicholas Vinson wrote:
> This reverts commit ac042f3f58d33ce9cd5ff61750f06da1a1d7b0eb.
>
> Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/5] Revert "configure: Check linker for --image-base support"
  2026-01-26 11:59 ` [PATCH 4/5] Revert "configure: Check linker for --image-base support" Nicholas Vinson
@ 2026-01-27 16:36   ` Daniel Kiper
  2026-02-03 14:15     ` Nicholas Vinson
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Kiper @ 2026-01-27 16:36 UTC (permalink / raw)
  To: Nicholas Vinson; +Cc: grub-devel, floppym

On Mon, Jan 26, 2026 at 06:59:35AM -0500, Nicholas Vinson wrote:
> This reverts commit 1a5417f39a0ccefcdd5440f2a67f84d2d2e26960.
>
> Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

... and commit 3c9c2a629 (INSTALL: Add note that the GNU Autoconf
Archive may be needed) has to be reverted as well...

Daniel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] configure: drop -Ttext checks for i386-pc
  2026-01-26 11:59 ` [PATCH 5/5] configure: drop -Ttext checks for i386-pc Nicholas Vinson
@ 2026-01-27 17:24   ` Daniel Kiper
  2026-02-03 14:26     ` Nicholas Vinson
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Kiper @ 2026-01-27 17:24 UTC (permalink / raw)
  To: Nicholas Vinson; +Cc: grub-devel, floppym

On Mon, Jan 26, 2026 at 06:59:36AM -0500, Nicholas Vinson wrote:
> The i386-pc target now uses a linker script, so -Ttext is no longer
> required.
>
> Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

And you can ignore my comment WRT "=" and "," in patch #2 review.
Now I understand the reason. Though I think it should be explained in
the commit message of #2...

Daniel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] grub-core: Update kernel image generation
  2026-01-27 15:41   ` Daniel Kiper
@ 2026-02-03 14:08     ` Nicholas Vinson
  0 siblings, 0 replies; 14+ messages in thread
From: Nicholas Vinson @ 2026-02-03 14:08 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: grub-devel, floppym

On 1/27/26 10:41, Daniel Kiper wrote:
> On Mon, Jan 26, 2026 at 06:59:33AM -0500, Nicholas Vinson wrote:
>> The i386-pc kernel image fails to build because of changes made to
>> address ld.lld-21 and newer linking issues. Specifically, with
>> ld.lld-21, if you try to set the text section address below image base
>> address when linking a non-relocatable binary, ld.lld wil fail to link.
> 
> I think in first place it begs for explanation why this is correct in our
> case. Should not we fix our builds to make newer linkers happy?

Using a customized linker script actually does a better job of making 
newer linkers "happy" than trying to find a set of command-line flags 
that satisifies all supported linkers and properly produces the kernel.

Then dealing with just ld.bfd and ld.lld, the behavioral differences 
between the two made finding a proper subset of flags that worked 
impossible. The previous attempt dropped -Ttext for --image-base, which 
has been proven not to work. The simplest correction, -Wl,--image-base=0 
-Wl,-Ttext, does not appear work. My testing with that option resulted 
in a GRUB kernel that entered into a tight infinite refresh loop.

Moreover, ld.lld does not order the sections the same way ld.bfd does, 
and that results in object files with gaps or holes when sections are 
stripped. I suspect, but did not investigate, that this plays a role in 
the infinite refresh loop I mentioned earlier.

The easiest way to resolve all this is to use customized linker scripts. 
These scripts, by default, override any default configuration the linker 
would otherwise impose, allow for complete control in aligning sections, 
and allows GRUB to specify where in the load segment each section goes.

> 
>> Switching to using a customized linker script solves the issue.
>>
>> Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
>> ---
>>   conf/Makefile.extra-dist    |  1 +
>>   conf/i386-pc-kernel.ld      | 38 +++++++++++++++++++++++++++++++++++
>>   grub-core/Makefile.core.def | 40 +++++++++++++++++++++++++++----------
>>   3 files changed, 69 insertions(+), 10 deletions(-)
>>   create mode 100644 conf/i386-pc-kernel.ld
>>
>> diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
>> index d22b6c862..fd904cd33 100644
>> --- a/conf/Makefile.extra-dist
>> +++ b/conf/Makefile.extra-dist
>> @@ -17,6 +17,7 @@ EXTRA_DIST += docs/grub.cfg
>>   EXTRA_DIST += docs/osdetect.cfg
>>
>>   EXTRA_DIST += conf/i386-cygwin-img-ld.sc
>> +EXTRA_DIST += conf/i386-pc-kernel.ld
>>
>>   EXTRA_DIST += grub-core/Makefile.core.def
>>   EXTRA_DIST += grub-core/Makefile.gcry.def
>> diff --git a/conf/i386-pc-kernel.ld b/conf/i386-pc-kernel.ld
>> new file mode 100644
>> index 000000000..80d5734b3
>> --- /dev/null
>> +++ b/conf/i386-pc-kernel.ld
> 
> s/ld/lds/ and I would rename i386-cygwin-img-ld.sc to

done.

> i386-cygwin-img-ld.lds too. Of course in separate patch...

done.

> 
>> @@ -0,0 +1,38 @@
>> +ENTRY(_start)
>> +
>> +PHDRS {
>> +    text PT_LOAD FLAGS(7);
> 
> text PT_LOAD FLAGS(7); /* PF_R | PF_W | PF_X */

done.

> 
>> +}
>> +
>> +SECTIONS
>> +{
>> +    . = _grub_text_base;
>> +    .text : {
>> +        _start = .;
>> +        *(.text .text.*)
>> +    } :text
>> +    .rodata : {
>> +        *(.rodata .rodata.*)
>> +    } :text
>> +    .module_license : {
>> +        *(.module_license)
>> +    } :text
>> +    .data : {
>> +        *(.data .data.*)
>> +        . = ALIGN(0x10);
> 
> Where does this number come from? And I would define a constant at the
> beginning of the linker script...
> 

done.

>> +        _edata = .;
>> +    } :text
>> +    .bss : {
>> +        __bss_start = .;
>> +        *(.bss .bss.*)
>> +        *(COMMON)
>> +        . = ALIGN(0x10);
> 
> Ditto...
> 

done.

>> +        _end = .;
>> +    } :text
>> +    /DISCARD/ : {
>> +        *(.interp)
>> +        *(.note*)
>> +        *(.comment)
>> +        *(.build-id)
>> +    }
>> +}
>> diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
>> index 0cf155128..7cc7963c7 100644
>> --- a/grub-core/Makefile.core.def
>> +++ b/grub-core/Makefile.core.def
>> @@ -82,7 +82,8 @@ kernel = {
>>     riscv64_efi_stripflags   = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame';
>>
>>     i386_pc_ldflags          = '$(TARGET_IMG_LDFLAGS)';
>> -  i386_pc_ldflags          = '$(TARGET_IMG_BASE_LDOPT),0x9000';
>> +  i386_pc_ldflags          = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
>> +  i386_pc_ldflags          = '$(TARGET_IMG_BASE_LDOPT)=0x9000';
> 
> Could not we stick to "," and do not make a change to "="?

No. ld.bfd and ld.lld require '=' instead of ' ' when using --defsym.

> 
>>     i386_qemu_ldflags        = '$(TARGET_IMG_LDFLAGS)';
>>     i386_qemu_ldflags        = '$(TARGET_IMG_BASE_LDOPT),0x9000';
>>     i386_coreboot_ldflags    = '$(TARGET_IMG_LDFLAGS)';
>> @@ -449,8 +450,11 @@ image = {
>>     i386_qemu = boot/i386/qemu/boot.S;
>>     sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S;
>>
>> +  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
>> +
>>     i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
>> -  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
>> +  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
>> +  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x7C00';
> 
> Ditto...
> 
>>     i386_qemu_ldflags = '$(TARGET_IMG_LDFLAGS)';
>>     i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),$(GRUB_BOOT_MACHINE_LINK_ADDR)';
>> @@ -475,10 +479,13 @@ image = {
>>     name = boot_hybrid;
>>     i386_pc = boot/i386/pc/boot.S;
>>
>> +  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
>> +
>>     cppflags = '-DHYBRID_BOOT=1';
>>
>>     i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
>> -  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
>> +  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
>> +  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x7C00';
> 
> Ditto and below...
> 
>>     objcopyflags = '-O binary';
>>     enable = i386_pc;
>> @@ -486,10 +493,13 @@ image = {
>>
>>   image = {
>>     name = cdboot;
>> -
> 
> Please drop this change...

done.

> 
>>     i386_pc = boot/i386/pc/cdboot.S;
>> +
>> +  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
>> +
>>     i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
>> -  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
>> +  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
>> +  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x7C00';
>>
>>     sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S;
>>
>> @@ -508,8 +518,11 @@ image = {
>>     name = pxeboot;
>>     i386_pc = boot/i386/pc/pxeboot.S;
>>
>> +  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
>> +
>>     i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
>> -  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
>> +  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
>> +  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x7C00';
>>
>>     objcopyflags = '-O binary';
>>     enable = i386_pc;
>> @@ -519,8 +532,11 @@ image = {
>>     name = diskboot;
>>     i386_pc = boot/i386/pc/diskboot.S;
>>
>> +  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
>> +
>>     i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
>> -  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x8000';
>> +  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
>> +  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x8000';
>>
>>     sparc64_ieee1275 = boot/sparc64/ieee1275/diskboot.S;
>>     sparc64_ieee1275_ldflags = '-Wl,-Ttext=0x4200';
>> @@ -535,8 +551,11 @@ image = {
>>     name = lnxboot;
>>     i386_pc = boot/i386/pc/lnxboot.S;
>>
>> +  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
>> +
>>     i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
>> -  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x6000';
>> +  i386_pc_ldflags = '-Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld';
>> +  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT)=0x6000';
>>
>>     objcopyflags = '-O binary';
>>     enable = i386_pc;
>> @@ -576,10 +595,11 @@ image = {
>>     name = lzma_decompress;
>>     i386_pc = boot/i386/pc/startup_raw.S;
>>     i386_pc_nodist = rs_decoder.h;
>> +  i386_pc_extra_dist = '$(top_srcdir)/conf/i386-pc-kernel.ld';
>>
>>     objcopyflags = '-O binary';
>> -  ldflags = '$(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x8200';
>> -  enable = i386_pc;
>> +  ldflags = '$(TARGET_IMG_LDFLAGS) -Wl,-T$(top_srcdir)/conf/i386-pc-kernel.ld $(TARGET_IMG_BASE_LDOPT)=0x8200';
>> +  lnable = i386_pc;
> 
> Hmmm... Looks like a mistake...

Fixed.

Thanks,
Nicholas Vinson
> 
> Daniel


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/5] Revert "configure: Check linker for --image-base support"
  2026-01-27 16:36   ` Daniel Kiper
@ 2026-02-03 14:15     ` Nicholas Vinson
  0 siblings, 0 replies; 14+ messages in thread
From: Nicholas Vinson @ 2026-02-03 14:15 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: grub-devel, floppym



On 1/27/26 11:36, Daniel Kiper wrote:
> On Mon, Jan 26, 2026 at 06:59:35AM -0500, Nicholas Vinson wrote:
>> This reverts commit 1a5417f39a0ccefcdd5440f2a67f84d2d2e26960.
>>
>> Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
> 
> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
> 
> ... and commit 3c9c2a629 (INSTALL: Add note that the GNU Autoconf
> Archive may be needed) has to be reverted as well...

done.

> 
> Daniel


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] configure: drop -Ttext checks for i386-pc
  2026-01-27 17:24   ` Daniel Kiper
@ 2026-02-03 14:26     ` Nicholas Vinson
  0 siblings, 0 replies; 14+ messages in thread
From: Nicholas Vinson @ 2026-02-03 14:26 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: grub-devel, floppym



On 1/27/26 12:24, Daniel Kiper wrote:
> On Mon, Jan 26, 2026 at 06:59:36AM -0500, Nicholas Vinson wrote:
>> The i386-pc target now uses a linker script, so -Ttext is no longer
>> required.
>>
>> Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
> 
> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
> 
> And you can ignore my comment WRT "=" and "," in patch #2 review.
> Now I understand the reason. Though I think it should be explained in
> the commit message of #2...

Done.

I found an additional issue related to ld.lld that I had originally 
disregarded as a testing error on my part due to its intermittent 
nature. Once I have a fix for it, I'll respin this patch series.

Thanks,
Nicholas Vinson

> 
> Daniel


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-02-03 14:27 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-26 11:59 [PATCH 0/5] Improve ld.lld-21+ compatibility when building i386-pc target Nicholas Vinson
2026-01-26 11:59 ` [PATCH 1/5] i386/pc/int.h: conditionally apply regparm attr Nicholas Vinson
2026-01-27 14:48   ` Daniel Kiper
2026-01-26 11:59 ` [PATCH 2/5] grub-core: Update kernel image generation Nicholas Vinson
2026-01-27 15:41   ` Daniel Kiper
2026-02-03 14:08     ` Nicholas Vinson
2026-01-26 11:59 ` [PATCH 3/5] Revert "configure: Print a more helpful error if autoconf-archive is not installed" Nicholas Vinson
2026-01-27 16:35   ` Daniel Kiper
2026-01-26 11:59 ` [PATCH 4/5] Revert "configure: Check linker for --image-base support" Nicholas Vinson
2026-01-27 16:36   ` Daniel Kiper
2026-02-03 14:15     ` Nicholas Vinson
2026-01-26 11:59 ` [PATCH 5/5] configure: drop -Ttext checks for i386-pc Nicholas Vinson
2026-01-27 17:24   ` Daniel Kiper
2026-02-03 14:26     ` Nicholas Vinson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox