Skip to contentSkip to conversation

Fix mingw compilation

PATCH Superseded Vladimir Serbinenko 1 participant 4 messages May 1, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#1 lore raw

PATCH 1/3 Fix error when cross-compiling for windows from unix-like OS

In this case exeext doesn't match the expected value by autoconf and so tests fail as autoconf looks for compiled binaries under wrong name.

---
 configure.ac | 12 ++++++++++++
 1 file changed, 12 insertions(+)
configure.ac +12 -0
index 83e3ddf90..e9c6ad8cc 100644
@@ -575,12 +575,22 @@ tmp_CFLAGS="$CFLAGS"
 tmp_LDFLAGS="$LDFLAGS"
 tmp_CPPFLAGS="$CPPFLAGS"
 tmp_LIBS="$LIBS"
+tmp_EXEEXT="$EXEEXT"
+tmp_ac_exeext="$ac_exeext"
 CC="$TARGET_CC"
 CFLAGS="$TARGET_CFLAGS"
 CPPFLAGS="$TARGET_CPPFLAGS"
 LDFLAGS="$TARGET_LDFLAGS"
 LIBS=""
 
+case "$target_os" in
+  cygwin*|mingw32*|mingw64*)		TARGET_EXEEXT=.exe ;;
+  *)					TARGET_EXEEXT= ;;
+esac
+
+EXEEXT="$TARGET_EXEEXT"
+ac_exeext="$TARGET_EXEEXT"
+
 if test "x$target_m32" = x1; then
   # Force 32-bit mode.
   TARGET_CFLAGS="$TARGET_CFLAGS -m32"
@@ -1618,6 +1628,8 @@ CFLAGS="$tmp_CFLAGS"
 CPPFLAGS="$tmp_CPPFLAGS"
 LDFLAGS="$tmp_LDFLAGS"
 LIBS="$tmp_LIBS"
+EXEEXT="$tmp_EXEEXT"
+ac_exeext="$tmp_ac_exeext"
 
 #
 # Check for options.
Signature · 7 lines
2.49.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#3 lore raw

PATCH 3/3 pe2elf: Set correct flag for relocation sections

In reply to Vladimir Serbinenko

Without this flag GRUB ignores the relocation section leading to a crash

---
 util/grub-pe2elf.c | 1 +
 1 file changed, 1 insertion(+)
util/grub-pe2elf.c +1 -0
index 11331294f..b686f0c82 100644
@@ -341,6 +341,7 @@ write_reloc_section (FILE* fp, const char *name, char *image,
       shdr[i].sh_offset = offset;
       shdr[i].sh_link = symtab_section;
       shdr[i].sh_addralign = 4;
+      shdr[i].sh_flags = SHF_INFO_LINK;
       shdr[i].sh_entsize = sizeof (elf_reloc_t);
       shdr[i].sh_size = num_rels * sizeof (elf_reloc_t);
 
Signature · 7 lines
2.49.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#2 lore raw

PATCH 2/3 compiler-rt: Add pei386_runtime_relocator stub

In reply to Vladimir Serbinenko

It's inserted by mingw and is meaningless in our environment

---
 grub-core/kern/compiler-rt.c | 4 ++++
 include/grub/compiler-rt.h   | 1 +
 2 files changed, 5 insertions(+)
grub-core/kern/compiler-rt.c +4 -0
index eda689a0c..28d3c62fe 100644
@@ -210,6 +210,10 @@ void ___chkstk_ms (void)
 void __chkstk_ms (void)
 {
 }
+
+void _pei386_runtime_relocator (void)
+{
+}
 #endif
 
 union component64
include/grub/compiler-rt.h +1 -0
index 17828b322..e139ebc87 100644
@@ -207,6 +207,7 @@ void EXPORT_FUNC (__register_frame_info) (void);
 void EXPORT_FUNC (__deregister_frame_info) (void);
 void EXPORT_FUNC (___chkstk_ms) (void);
 void EXPORT_FUNC (__chkstk_ms) (void);
+void EXPORT_FUNC (_pei386_runtime_relocator) (void);
 #endif
 
 #endif
Signature · 7 lines
2.49.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel