public inbox for grub-devel@gnu.org
 help / color / mirror / Atom feed
From: Nicholas Vinson <nvinson234@gmail.com>
To: grub-devel@gnu.org
Cc: Nicholas Vinson <nvinson234@gmail.com>,
	floppym@gentoo.org, dkiper@net-space.pl
Subject: [PATCH v2 0/8] Improve ld.lld-21+ compatibility when building i386-pc target
Date: Mon,  9 Feb 2026 19:43:28 -0500	[thread overview]
Message-ID: <cover.1770683931.git.nvinson234@gmail.com> (raw)

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 (8):
  i386/pc/int.h: conditionally apply regparm attr.
  grub-core: Update kernel image generation
  i386-cygwin-img-ld.sc -> i386-cygwin-img.lds
  Revert "configure: Print a more helpful error if autoconf-archive is
    not installed"
  Revert "configure: Check linker for --image-base support"
  Revert "INSTALL: Add note that the GNU Autoconf Archive may be needed"
  configure: drop -Ttext checks for i386-pc
  C23 fixes: fix strchr() and strrchr() handling

 INSTALL                                       |  1 -
 acinclude.m4                                  | 18 ++++---
 conf/Makefile.extra-dist                      |  3 +-
 ...6-cygwin-img-ld.sc => i386-cygwin-img.lds} |  0
 conf/i386-pc-kernel.lds                       | 51 +++++++++++++++++++
 configure.ac                                  | 42 +++++++--------
 grub-core/Makefile.core.def                   | 24 ++++++---
 grub-core/osdep/linux/ofpath.c                | 14 ++---
 include/grub/i386/pc/int.h                    |  5 +-
 util/probe.c                                  |  6 +--
 util/resolve.c                                | 10 ++--
 11 files changed, 123 insertions(+), 51 deletions(-)
 rename conf/{i386-cygwin-img-ld.sc => i386-cygwin-img.lds} (100%)
 create mode 100644 conf/i386-pc-kernel.lds

-- 
2.53.0


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

             reply	other threads:[~2026-02-10  0:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-10  0:43 Nicholas Vinson [this message]
2026-02-10  0:43 ` [PATCH v2 1/8] i386/pc/int.h: conditionally apply regparm attr Nicholas Vinson
2026-02-10  0:43 ` [PATCH v2 2/8] grub-core: Update kernel image generation Nicholas Vinson
2026-02-10  0:43 ` [PATCH v2 3/8] i386-cygwin-img-ld.sc -> i386-cygwin-img.lds Nicholas Vinson
2026-02-10  0:43 ` [PATCH v2 4/8] Revert "configure: Print a more helpful error if autoconf-archive is not installed" Nicholas Vinson
2026-02-10  0:43 ` [PATCH v2 5/8] Revert "configure: Check linker for --image-base support" Nicholas Vinson
2026-02-10  0:43 ` [PATCH v2 6/8] Revert "INSTALL: Add note that the GNU Autoconf Archive may be needed" Nicholas Vinson
2026-02-10  0:43 ` [PATCH v2 7/8] configure: drop -Ttext checks for i386-pc Nicholas Vinson
2026-02-10  0:43 ` [PATCH v2 8/8] C23 fixes: fix strchr() and strrchr() handling Nicholas Vinson
2026-02-10 15:47 ` [PATCH v2 0/8] Improve ld.lld-21+ compatibility when building i386-pc target Daniel Kiper
2026-02-10 23:27   ` Nicholas Vinson
2026-02-11 17:49     ` Daniel Kiper
2026-02-12  7:46     ` [PATCH] Fix build with glibc 2.43 after new ISO C23 changes Radoslav Kolev via Grub-devel
2026-02-12  7:53     ` [PATCH v2 0/8] Improve ld.lld-21+ compatibility when building i386-pc target Radoslav Kolev via Grub-devel
2026-02-12 13:21       ` Nicholas Vinson
2026-02-11 18:49   ` Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1770683931.git.nvinson234@gmail.com \
    --to=nvinson234@gmail.com \
    --cc=dkiper@net-space.pl \
    --cc=floppym@gentoo.org \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox