Commit Graph
21 Commits
Author SHA1 Message Date
Nicholas Vinson 3dce38eb19 conf/i386-cygwin-img.lds: Update to use _grub_text_base symbol
This patch updates conf/i386-cygwin-img.lds to use the _grub_text_base
symbol just like conf/i386-pc-kernel.lds. It also updates configure.ac
to account for this change.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2026-03-05 15:08:00 +01:00
Nicholas Vinson 7d0a4c07a8 build: i386-cygwin-img-ld.sc -> i386-cygwin-img.lds
Rename i386-cygwin-img-ld.sc to i386-cygwin-img.lds as "lds" is the
preferred extension for linker scripts.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2026-03-05 15:03:57 +01:00
Nicholas Vinson ab6f735174 configure: Add --image-base check for non-i386
Configure check grub_PROG_OBJCOPY_ABSOLUTE is run for all non-Apple
targets. With ld.lld-21, the check fails for addresses below image base
address (which ld.lld-21 assumes is 0x200000).

Fix by checking if linker support --image-base flag, and if it does,
include "--image-base 0" to TARGET_IMG_BASE_LDOPT.

The AX_CHECK_LINK_FLAG macro has been added to avoid a dependency on
autoconf-archive.

Note: I tried this approach with i386-pc, but I ended up with a GRUB
image that failed to boot correctly.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2026-03-05 14:59:22 +01:00
Nicholas Vinson 86283bfd4e configure: Drop -Ttext checks for i386-pc
The i386-pc target now uses a linker script, so -Ttext is no longer
required. However, a new variable TARGET_IMG_BASE_LDOPT_ARG_SEP is
introduced to handle the fact that when using --defsym the argument
separator must be "=". The space character is a syntax error.

Finally, EXTRA_DIST is updated to track the linker script used.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2026-03-05 14:49:16 +01:00
Nicholas Vinson 935e889ab5 Revert "INSTALL: Add note that the GNU Autoconf Archive may be needed"
This reverts commit a90ccbac6 (INSTALL: Add note that the GNU Autoconf
Archive may be needed).

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2026-03-05 14:38:55 +01:00
Nicholas Vinson 1dc2986c7e Revert "configure: Check linker for --image-base support"
This reverts commit 1a5417f39 (configure: Check linker for --image-base support).

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2026-03-05 14:36:54 +01:00
Nicholas Vinson 7b72d6cbd5 Revert "configure: Print a more helpful error if autoconf-archive is not installed"
This reverts commit ac042f3f5 (configure: Print a more helpful error if
autoconf-archive is not installed).

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2026-03-05 14:34:48 +01:00
Nicholas Vinson ba2f351145 build/i386-pc: Update kernel image generation
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 and is
a more robust solution to supporting multiple linkers than attempting to
find a set of command-line flags that satisfied all supported linkers
and links the kernel properly. In the worst case, continued use of
command-line flags could result in having to create code branches to
support various linkers.

For example, when 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", did not work because 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.

This patch series does require linkers to support the --defsym flag,
which requires its argument to be of the form "sym=address" as
"sym address" is not supported.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2026-03-05 14:22:49 +01:00
Nicholas Vinson 9922ed133c include/grub/i386/pc/int.h: Move GRUB_MACHINE_PCBIOS ifdef
Modern compilers are becoming more strict and starting to warn when
certain attributes are ignored. The regparam attribute is such an
attribute.

Moreover, the function

  void EXPORT_FUNC (grub_bios_interrupt) (grub_uint8_t intno, struct grub_bios_int_registers *regs) __attribute__ ((regparm(3)));

is only defined with the i386-pc target.

Update include/grub/i386/pc/int.h so grub_bios_interrupt() is only
declared when GRUB_MACHINE_PCBIOS is defined. This addresses the issue
of declaring a function that is not defined for non-i386-pc targets and
prevents the "attribute ignored" diagnostic message.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2026-03-05 14:14:56 +01:00
Nicholas Vinson ce6f2b57f5 util/resolve: Save str[r]chr() ret val to const data ptr
With glibc-2.43 implementing the C23 standard, strrchr() and strchr()
now return "const char *" when its first argument is "const char *".

The fix is update all pointers receiving strrchr() and strchr()'s return
values so that they are now "const char *" instead of "char *".

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2026-02-26 15:59:23 +01:00
Nicholas Vinson 9f4a586f12 util/probe: Save strrchr() ret val to const data ptr
With glibc-2.43 implementing the C23 standard, strrchr() now returns
"const char *" when its first argument is "const char *".

The fix is update all pointers receiving strrchr()'s return value so
that they are now "const char *" instead of "char *".

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2026-02-26 15:54:04 +01:00
Nicholas Vinson b71ae6db28 osdep/linux/ofpath: Correct path_size calculation
path_size is computed in part by taking the size of the format string.
However, the format string contains conversion specifiers. These
conversion specifiers are included in the size calculation resulting in
a size calculation that is larger than it needs to be. This patch
corrects that error by removing the conversion specifiers when computing
path_size.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2026-02-26 15:51:56 +01:00
Nicholas Vinson 675d858103 osdep/linux/ofpath: Update strstr() calls
With C23, strstr() returns a "const char *" if its first argument is
"const char *", and these changes are implemented in glibc-2.43.

As a result, the first strstr() call in check_sas() now returns a "const
char *" instead of "char *" because sysfs_path is a "const char *". This
triggers a "discards qualifiers" warning, that is later promoted to an
error and ultimately causes the build to fail.

To fix the issue, this patch converts "ed", the pointer that stores
strstr()'s return value, to a "const char *". Removes the xstrdup()
call and cleans up the rest of the function by updating the *printf()
calls and using pointer arithmetic to compute lengths instead of strlen().

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2026-02-26 15:43:11 +01:00
Nicholas Vinson 1a5417f39a configure: Check linker for --image-base support
In several scenarios, configure tests assume it's safe to use
"-Wl,-Ttext,<address>", but starting with ld.lld-21, blindly using that
flag may result in configure-test failures due to ld.lld failing to
link. The failure is because ld.lld-21 no longer allows the specified
address is less than the base address.

However, ld.lld-21+ and ld.bfd-2.44+ both provide support for the
--image-base flag making it preferable over the older -Ttext flag.

Fixes: https://savannah.gnu.org/bugs/?67662

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-11-20 17:03:27 +01:00
Nicholas Vinson b58aa4e209 gentpl.py: Remove .interp section from .img files
When building .img files, a .interp section from the .image files will
sometimes be copied into the .img file. This additional section pushes
the .img file beyond the 512-byte limit and causes grub-install to fail
to run for i386-pc platforms.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2023-01-19 17:39:05 +01:00
Nicholas Vinson 1b3d97bdf8 configure: Warn if stack protector is not allowed
Introduce ERROR_PLATFORM_NOT_SUPPORT_SSP environment variable to treat
the "--enable-stack-protector is only supported on EFI platforms" message
as a warning instead of an error. If ERROR_PLATFORM_NOT_SUPPORT_SSP is
set to "no" (case-insensitive), then the message will be printed as
a warning. Otherwise, it prints as an error. The default behavior is to
print the message as an error.

For any wrapper build script that has some variation of:

    for p in SELECTED_GRUB_PLATFORMS; do    \
        configure --enable-stack-protector  \
            --with-platform${P} ... || die; \
    done
    make

The GRUB will fail to build if SELECTED_GRUB_PLATFORMS contains a platform
that does not support SSP.

Such wrapper scripts need to work-around this issue by modifying the
above for-loop, so it conditionally passes --enable-stack-protector to
configure for the proper GRUB platform(s).

However, if the above example is modified to have to conditionally pass
in --enable-stack-protector, its behavior is effectively the same as the
proposed change. Additionally, The list of SSP supported platforms is
now in 2 places. One in the configure script and one in the build wrapper
script. If the second list is not properly maintained it could mistakenly
disable SSP for a platform that later gained support for it.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2022-07-12 14:33:25 +02:00
Nicholas Vinson c7cb11b219 probe: Support probing for msdos PARTUUID
Extend partition UUID probing support in GRUB core to display pseudo
partition UUIDs for MBR (MSDOS) partitions.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2019-10-21 14:00:54 +02:00
Nicholas Vinson 51be3372ec templates: Update grub script template files
Update grub-mkconfig.in and 10_linux.in to support grub-probe's new
partuuid target.  Update grub.texi documentation.  The following table
shows how GRUB_DISABLE_LINUX_UUID, GRUB_DISABLE_LINUX_PARTUUID, and
initramfs detection interact:

Initramfs  GRUB_DISABLE_LINUX_PARTUUID  GRUB_DISABLE_LINUX_UUID  Linux Root
detected   Set                          Set                      ID Method

false      false                        false                    part UUID
false      false                        true                     part UUID
false      true                         false                    dev name
false      true                         true                     dev name
true       false                        false                    fs UUID
true       false                        true                     part UUID
true       true                         false                    fs UUID
true       true                         true                     dev name

Note: GRUB_DISABLE_LINUX_PARTUUID and GRUB_DISABLE_LINUX_UUID equate to
      'false' when unset or set to any value other than 'true'.
      GRUB_DISABLE_LINUX_PARTUUID defaults to 'true'.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-04-23 13:31:02 +02:00
Nicholas Vinson 0c0bcffc23 grub-probe: Add PARTUUID detection support
Add PARTUUID detection support grub-probe for MBR and GPT partition schemes.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-04-23 13:24:29 +02:00
Nicholas Vinson a16f4a822f disk: Update grub_gpt_partentry
Rename grub_gpt_part_type to grub_gpt_part_guid and update grub_gpt_partentry
to use this type for both the partition type GUID string and the partition GUID
string entries.  This change ensures that the two GUID fields are handled more
consistently and helps to simplify the changes needed to add Linux partition
GUID support.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-04-23 13:21:45 +02:00
Nicholas Vinson c2b86ae1fc grub-probe: Centralize GUID prints
Define print_gpt_guid(), so there is a central function for printing
GUID strings.  This change is a precursor for later patches which rely
on this logic.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-04-23 13:21:22 +02:00