File grub2-emu-PIE.patch of Package grub2
---
configure.ac | 23 ++++++++++++++++++++++-
grub-core/genmoddep.awk | 2 +-
2 files changed, 23 insertions(+), 2 deletions(-)
--- a/configure.ac
+++ b/configure.ac
@@ -1610,6 +1610,25 @@ fi
CFLAGS="$TARGET_CFLAGS"
# Position independent executable.
+AC_ARG_ENABLE([grub-emu-PIE],
+ [AS_HELP_STRING([--enable-grub-emu-PIE],
+ [build grub-emu as Position Independent Executable (default=no)])])
+if test x"$enable_grub_emu_PIE" = xyes; then
+ if test x$target_cpu = xarm64 ; then
+ AC_MSG_WARN([--enable-grub-emu-PIE is not supported on arm64])
+ enable_grub_emu_PIE=no
+ fi
+ if test x"$platform" != xemu ; then
+ AC_MSG_WARN([--enable-grub-emu-PIE is only attempted on emu builds])
+ enable_grub_emu_PIE=no
+ fi
+else
+ enable_grub_emu_PIE=no
+fi
+AC_SUBST([enable_grub_emu_PIE])
+
+if test x"$enable_grub_emu_PIE" = xno || test x$target_cpu = xarm64 ; then
+
grub_CHECK_PIE
grub_CHECK_NO_PIE
grub_CHECK_NO_PIE_ONEWORD
@@ -1633,7 +1652,7 @@ fi]
CFLAGS="$TARGET_CFLAGS"
LDFLAGS="$TARGET_LDFLAGS"
-# Position independent executable.
+# Position independent code.
grub_CHECK_PIC
[# On most platforms we don't want PIC as it only makes relocations harder
# and code less efficient. On mips we want to have one got table per module
@@ -1653,6 +1672,8 @@ fi]
CFLAGS="$TARGET_CFLAGS"
+fi
+
if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 || test "$target_cpu" = riscv64 ; then
# Use large model to support 4G memory
AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
--- a/grub-core/genmoddep.awk
+++ b/grub-core/genmoddep.awk
@@ -27,7 +27,7 @@ BEGIN {
} else if ($1 == "undefined") {
if ($3 in symtab)
modtab[$2] = modtab[$2] " " symtab[$3];
- else if ($3 != "__gnu_local_gp" && $3 != "_gp_disp") {
+ else if ($3 != "__gnu_local_gp" && $3 != "_gp_disp" && $3 != "_GLOBAL_OFFSET_TABLE_" ) {
printf "%s in %s is not defined\n", $3, $2 >"/dev/stderr";
error++;
}