grub powerpc64 little-endian enablement
cover grub powerpc64 little-endian enablement
From: Paulo Flabiano Smorigo <[email protected]>
Hi,
At the beginning of the year we provide a patchset that enabled GRUB for little-endian PowerPC. Our approach at the time was to build GRUB itself and its tools in 64-bit little-endian. One of the reasons of build in 64-bit is to avoid 32-bit dependencies in the distro and build a system entirely 64-bit.
This patchset was not welcomed at the time because it would bring a high-maintainance-cost, without real gain since it could just be cross-compiled.
After that, Brent Baude, Vladmir (phcoder) and I started to work in a solution that would cross-compile but without 32-bit dependencies. This patchset is the result of this new approach. It's based on the work of Brent Baude, Vladimir (phcoder), and Tomohiro.
It can be devided in two parts:
1) Skip libgcc dependency just for ppc64el (patch 1 and 2);
2) Check elf endianess and byteswap if necessary (patch 3);
The result is GRUB itself in 32-bit BE and its tools in 64-bit LE. This solution satisfies the needs of the distros. I tested it in three different distros, in both endianess and it's fine.
If thoses patches were accepted we will have an official solution. Nowadays, distros are taking diffrent approachs. Some of then are using the original solutions and others are using cross-compiler.
--
Paulo Flabiano Smorigo
IBM Linux Technology Center
Paulo Flabiano Smorigo (3):
Add powerpc little-endian (ppc64le) flags Files reorganization and include some libgcc fuctions Suport for bi-endianess in elf file
configure.ac | 17 ++++- grub-core/Makefile.am | 2 + grub-core/Makefile.core.def | 1 + grub-core/kern/elf.c | 60 +++++++++++++++- grub-core/kern/elfXX.c | 73 ++++++++++++++++++++ grub-core/kern/misc.c | 107 ++++++++++++++++++++++++++++ grub-core/kern/powerpc/compiler-rt.S | 130 +++++++++++++++++++++++++++++++++++ include/grub/compiler.h | 61 ++++++++++++++++ include/grub/libgcc.h | 67 ------------------ 9 files changed, 447 insertions(+), 71 deletions(-) create mode 100644 grub-core/kern/powerpc/compiler-rt.S
Signature · 1 line
1.8.1.4
RFC PATCH 1/3 Add powerpc little-endian (ppc64le) flags
libgcc dependency was removed *just* for this target because the distros that use ppc64el doesn't have 32-bit support on it.
* configure.ac: Add targets for powerpc64el and skip libgcc.
* Makefile.am: Likewise.
--- configure.ac | 17 +++++++++++++++-- grub-core/Makefile.am | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-)
configure.ac +15 -2
@@ -119,6 +119,7 @@ if test "x$with_platform" = x; then x86_64-*) platform=pc ;; powerpc-*) platform=ieee1275 ;; powerpc64-*) platform=ieee1275 ;; + powerpc64le-*) platform=ieee1275 ;; sparc64-*) platform=ieee1275 ;; mipsel-*) platform=loongson ;; mips-*) platform=arc ;;
@@ -137,6 +138,7 @@ case "$target_cpu"-"$platform" in x86_64-xen) ;; x86_64-*) target_cpu=i386 ;; powerpc64-ieee1275) target_cpu=powerpc ;; + powerpc64le-ieee1275) target_cpu=powerpc ;; esac # Check if the platform is supported, make final adjustments.
@@ -581,6 +583,13 @@ if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then TARGET_CFLAGS="$TARGET_CFLAGS -march=i386" fi +if test x$target_cpu = xpowerpc && test x$ac_cv_c_bigendian = xno; then + LD_FORCE_LE=1 + TARGET_CFLAGS="$TARGET_CFLAGS -mbig-endian -DNO_LIBGCC=1" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS -mbig-endian" + TARGET_LDFLAGS="$TARGET_LDFLAGS -static -mbig-endian" +fi + if test "x$target_m32" = x1; then # Force 32-bit mode. TARGET_CFLAGS="$TARGET_CFLAGS -m32"
@@ -1024,7 +1033,8 @@ else CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error" fi CPPFLAGS="$TARGET_CPPFLAGS" -if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then +if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes \ + || ( test x$target_cpu = xpowerpc && test x$ac_cv_c_bigendian = xno ); then TARGET_LIBGCC= else TARGET_LIBGCC=-lgcc
@@ -1608,7 +1618,9 @@ if test x"$enable_werror" != xno ; then HOST_CFLAGS="$HOST_CFLAGS -Werror" fi -if test "x$grub_cv_cc_target_clang" = xno; then +# if not clang or power LE, use static libgcc +if test "x$grub_cv_cc_target_clang" = xno \ + || ! ( test x$target_cpu = xpowerpc && test x$ac_cv_c_bigendian = xno ); then TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc" else TARGET_LDFLAGS_STATIC_LIBGCC=
@@ -1671,6 +1683,7 @@ AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275]) AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu]) AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275]) +AM_CONDITIONAL([COND_powerpc_le], [test x$target_cpu = xpowerpc -a x$ac_cv_c_bigendian = xno]) AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel]) AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel]) AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
grub-core/Makefile.am +2 -0
@@ -84,8 +84,10 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h if !COND_clang +if !COND_powerpc_le KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h endif +endif KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h if COND_i386_pc
Signature · 1 line
1.8.1.4
Re: [RFC PATCH 1/3] Add powerpc little-endian (ppc64le) flags
Quoted 97 lines · Paulo Flabiano Smorigo
libgcc dependency was removed *just* for this target because the distros that use ppc64el doesn't have 32-bit support on it.
* configure.ac: Add targets for powerpc64el and skip libgcc.
* Makefile.am: Likewise.--- configure.ac | 17 +++++++++++++++-- grub-core/Makefile.am | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-)configure.ac +15
-2@@ -119,6 +119,7 @@ if test "x$with_platform" = x; then x86_64-*) platform=pc ;; powerpc-*) platform=ieee1275 ;; powerpc64-*) platform=ieee1275 ;; + powerpc64le-*) platform=ieee1275 ;; sparc64-*) platform=ieee1275 ;; mipsel-*) platform=loongson ;; mips-*) platform=arc ;;@@ -137,6 +138,7 @@ case "$target_cpu"-"$platform" in x86_64-xen) ;; x86_64-*) target_cpu=i386 ;; powerpc64-ieee1275) target_cpu=powerpc ;; + powerpc64le-ieee1275) target_cpu=powerpc ;; esac # Check if the platform is supported, make final adjustments.@@ -581,6 +583,13 @@ if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then TARGET_CFLAGS="$TARGET_CFLAGS -march=i386" fi +if test x$target_cpu = xpowerpc && test x$ac_cv_c_bigendian = xno; then + LD_FORCE_LE=1 + TARGET_CFLAGS="$TARGET_CFLAGS -mbig-endian -DNO_LIBGCC=1" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS -mbig-endian" + TARGET_LDFLAGS="$TARGET_LDFLAGS -static -mbig-endian" +fi + if test "x$target_m32" = x1; then # Force 32-bit mode. TARGET_CFLAGS="$TARGET_CFLAGS -m32"@@ -1024,7 +1033,8 @@ else CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error" fi CPPFLAGS="$TARGET_CPPFLAGS" -if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then +if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes \ + || ( test x$target_cpu = xpowerpc && test x$ac_cv_c_bigendian = xno ); then TARGET_LIBGCC= else TARGET_LIBGCC=-lgcc@@ -1608,7 +1618,9 @@ if test x"$enable_werror" != xno ; then HOST_CFLAGS="$HOST_CFLAGS -Werror" fi -if test "x$grub_cv_cc_target_clang" = xno; then +# if not clang or power LE, use static libgcc +if test "x$grub_cv_cc_target_clang" = xno \ + || ! ( test x$target_cpu = xpowerpc && test x$ac_cv_c_bigendian = xno ); then TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc" else TARGET_LDFLAGS_STATIC_LIBGCC=@@ -1671,6 +1683,7 @@ AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275]) AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu]) AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275]) +AM_CONDITIONAL([COND_powerpc_le], [test x$target_cpu = xpowerpc -a x$ac_cv_c_bigendian = xno]) AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel]) AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel]) AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])grub-core/Makefile.am +2
-0@@ -84,8 +84,10 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h if !COND_clang +if !COND_powerpc_le KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h endif +endif KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h if COND_i386_pcSignature · 7 lines
1.8.1.4 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
I just moved some part of this patch to the second one. Now this patch only add the target and all libgcc stuff is in the second one.
Signature · 2 lines
Paulo Flabiano Smorigo IBM Linux Technology Center
From 7a2e287e6ed00476c6760797541c3aff49dbeb40 Mon Sep 17 00:00:00 2001
From: Paulo Flabiano Smorigo <[email protected]>
Date: Wed, 17 Sep 2014 14:42:40 -0300
Subject: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
* configure.ac: Add target for ppc64le (ppc64el).
--- configure.ac | 9 +++++++++ 1 file changed, 9 insertions(+)
configure.ac +9 -0
@@ -119,6 +119,7 @@ if test "x$with_platform" = x; then x86_64-*) platform=pc ;; powerpc-*) platform=ieee1275 ;; powerpc64-*) platform=ieee1275 ;; + powerpc64le-*) platform=ieee1275 ;; sparc64-*) platform=ieee1275 ;; mipsel-*) platform=loongson ;; mips-*) platform=arc ;;
@@ -137,6 +138,7 @@ case "$target_cpu"-"$platform" in x86_64-xen) ;; x86_64-*) target_cpu=i386 ;; powerpc64-ieee1275) target_cpu=powerpc ;; + powerpc64le-ieee1275) target_cpu=powerpc ;; esac # Check if the platform is supported, make final adjustments.
@@ -581,6 +583,13 @@ if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then TARGET_CFLAGS="$TARGET_CFLAGS -march=i386" fi +if test x$target_cpu = xpowerpc && test x$ac_cv_c_bigendian = xno; then + #LD_FORCE_LE=1 + TARGET_CFLAGS="$TARGET_CFLAGS -mbig-endian" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS -mbig-endian" + TARGET_LDFLAGS="$TARGET_LDFLAGS -static -mbig-endian" +fi + if test "x$target_m32" = x1; then # Force 32-bit mode. TARGET_CFLAGS="$TARGET_CFLAGS -m32"
Signature · 1 line
1.8.4.2
Re: [RFC PATCH 1/3] Add powerpc little-endian (ppc64le) flags
configure.ac if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then · line 587
Quoted 2 lines · Paulo Flabiano Smorigo
configure.ac +2
-0+if test x$target_cpu = xpowerpc && test x$ac_cv_c_bigendian = xno; then + #LD_FORCE_LE=1
You should probably either uncomment this or remove it. We don't normally leave commented-out bits of code lying around, at least not without another comment explaining what's going on ...
Thanks,
Signature · 1 line
Colin Watson [[email protected]]
Re: [RFC PATCH 1/3] Add powerpc little-endian (ppc64le) flags
In reply to Paulo Flabiano SmorigoQuoted 1 line · Paulo Flabiano Smorigo
+if test x$target_cpu = xpowerpc && test x$ac_cv_c_bigendian = xno; then
This should be done before endianness check as endianness check may have other influences as well. Also I think you got the check from host, not target. AFAIR target doesn't use endian check at all, which makes this patch unsuitable for cross-compile.
Could you send your latest patch version in new thread? I'm pretty confused with this thread.
RFC PATCH 2/3 Files reorganization and include some libgcc fuctions
In reply to Paulo Flabiano SmorigoAs we avoid libgcc dependency for powerpc64el, we moved some functions to other files and add the necessary ones.
* Makefile.core.def: Include compiler-rt.S.
* misc.c: Add the necessary libgcc functions.
* compiler-rt.S: New file.
* libgcc.h: Move some content from here ...
* compiler.h: ... to here.
--- grub-core/Makefile.core.def | 1 + grub-core/kern/misc.c | 107 ++++++++++++++++++++++++++++ grub-core/kern/powerpc/compiler-rt.S | 130 +++++++++++++++++++++++++++++++++++ include/grub/compiler.h | 61 ++++++++++++++++ include/grub/libgcc.h | 67 ------------------ 5 files changed, 299 insertions(+), 67 deletions(-) create mode 100644 grub-core/kern/powerpc/compiler-rt.S
grub-core/Makefile.core.def +1 -0
@@ -252,6 +252,7 @@ kernel = { powerpc_ieee1275 = kern/powerpc/cache.S; powerpc_ieee1275 = kern/powerpc/dl.c; + powerpc_ieee1275 = kern/powerpc/compiler-rt.S; sparc64_ieee1275 = kern/sparc64/cache.S; sparc64_ieee1275 = kern/sparc64/dl.c;
grub-core/kern/misc.c +107 -0
110 lines not on this page · raw message
grub-core/kern/powerpc/compiler-rt.S new file +130 -0
130 lines not on this page · raw message
include/grub/compiler.h +61 -0
65 lines not on this page · raw message
include/grub/libgcc.h +0 -67
73 lines not on this page · raw message
Signature · 1 line
1.8.1.4
Re: [RFC PATCH 2/3] Files reorganization and include some libgcc fuctions
grub-core/kern/misc.c grub_real_boot_time (const char *file, · line 1346
Quoted 10 lines · Paulo Flabiano Smorigo
grub-core/kern/misc.c +2
-0@@ -1342,3 +1342,110 @@ grub_real_boot_time (const char *file, grub_error_pop (); }#endif + +#if defined (NO_LIBGCC )
Should this perhaps be restricted to __powerpc__ as well? Alternatively, the prototypes in include/grub/compiler.h (or include/grub/misc.h; see below) should be used on other architectures too. Either way, the declarations and definitions should match.
include/grub/compiler.h line 51
Quoted 9 lines
include/grub/compiler.h +1
-0@@ -48,4 +48,65 @@# define WARN_UNUSED_RESULT #endif +#include "types.h"
Shouldn't this be #include <grub/types.h>, assuming that you need this for grub_uint*_t? Also, includes should generally be grouped at the top of the file.
Quoted 4 lines
include/grub/compiler.h +4
-0+union component64 +{ +grub_uint64_t full; + struct
include/grub/compiler.h line 66
Quoted 10 lines
include/grub/compiler.h +10
-0+ { +#ifdef GRUB_CPU_WORDS_BIGENDIAN +grub_uint32_t high; +grub_uint32_t low; +#else +grub_uint32_t low; +grub_uint32_t high; +#endif + }; +};
This is only used by grub-core/kern/misc.c. Please move it there rather than putting it somewhere that's included by everything in GRUB.
include/grub/compiler.h line 68
Quoted 1 line
include/grub/compiler.h +1
-0+#if defined (__powerpc__)
Should this be #if defined (__powerpc__) && defined (NO_LIBGCC) or something similar, to match the general way things are set up in configure.ac? (Also see comment above about declarations matching definitions.)
Relatedly, have you tested this patch set with a native build on a 32-bit BE powerpc system, as opposed to 32-bit BE built on a 64-bit LE system? This looks like a potential problem there.
include/grub/compiler.h line 73
Quoted 5 lines
include/grub/compiler.h +5
-0+grub_uint64_t EXPORT_FUNC (__lshrdi3 ) (grub_uint64_t u,int b); +grub_uint64_t EXPORT_FUNC (__ashrdi3 ) (grub_uint64_t u,int b); +grub_uint64_t EXPORT_FUNC (__ashldi3 ) (grub_uint64_t u,int b); +int EXPORT_FUNC (__ucmpdi2 ) (grub_uint64_t a,grub_uint64_t b); +void EXPORT_FUNC (_restgpr_14_x ) (void );
[...]
These aren't compiler features, so don't belong in include/grub/compiler.h. Other architectures seem to have this kind of thing in include/grub/misc.h inside a big #ifndef GRUB_UTIL conditional, so please move all this to there.
Quoted 68 lines
include/grub/libgcc.h +0
-60@@ -16,73 +16,6 @@* along with GRUB. If not, see <http://www.gnu.org/licenses/>. */ -/* We need to include config-util.h.in for HAVE_*. */ -#ifndef __STDC_VERSION__ -#define __STDC_VERSION__ 0 -#endif -#include <config-util.h> - -/* On x86 these functions aren't really needed. Save some space. */ -#if !defined (__i386__) && !defined (__x86_64__) -# ifdef HAVE___ASHLDI3 -void EXPORT_FUNC (__ashldi3 ) (void ); -# endif -# ifdef HAVE___ASHRDI3 -void EXPORT_FUNC (__ashrdi3 ) (void ); -# endif -# ifdef HAVE___LSHRDI3 -void EXPORT_FUNC (__lshrdi3 ) (void ); -# endif -# ifdef HAVE___UCMPDI2 -void EXPORT_FUNC (__ucmpdi2 ) (void ); -# endif -# ifdef HAVE___BSWAPSI2 -void EXPORT_FUNC (__bswapsi2 ) (void ); -# endif -# ifdef HAVE___BSWAPDI2 -void EXPORT_FUNC (__bswapdi2 ) (void ); -# endif -#endif - -#ifdef HAVE__RESTGPR_14_X -void EXPORT_FUNC (_restgpr_14_x ) (void ); -void EXPORT_FUNC (_restgpr_15_x ) (void ); -void EXPORT_FUNC (_restgpr_16_x ) (void ); -void EXPORT_FUNC (_restgpr_17_x ) (void ); -void EXPORT_FUNC (_restgpr_18_x ) (void ); -void EXPORT_FUNC (_restgpr_19_x ) (void ); -void EXPORT_FUNC (_restgpr_20_x ) (void ); -void EXPORT_FUNC (_restgpr_21_x ) (void ); -void EXPORT_FUNC (_restgpr_22_x ) (void ); -void EXPORT_FUNC (_restgpr_23_x ) (void ); -void EXPORT_FUNC (_restgpr_24_x ) (void ); -void EXPORT_FUNC (_restgpr_25_x ) (void ); -void EXPORT_FUNC (_restgpr_26_x ) (void ); -void EXPORT_FUNC (_restgpr_27_x ) (void ); -void EXPORT_FUNC (_restgpr_28_x ) (void ); -void EXPORT_FUNC (_restgpr_29_x ) (void ); -void EXPORT_FUNC (_restgpr_30_x ) (void ); -void EXPORT_FUNC (_restgpr_31_x ) (void ); -void EXPORT_FUNC (_savegpr_14 ) (void ); -void EXPORT_FUNC (_savegpr_15 ) (void ); -void EXPORT_FUNC (_savegpr_16 ) (void ); -void EXPORT_FUNC (_savegpr_17 ) (void ); -void EXPORT_FUNC (_savegpr_18 ) (void ); -void EXPORT_FUNC (_savegpr_19 ) (void ); -void EXPORT_FUNC (_savegpr_20 ) (void ); -void EXPORT_FUNC (_savegpr_21 ) (void ); -void EXPORT_FUNC (_savegpr_22 ) (void ); -void EXPORT_FUNC (_savegpr_23 ) (void ); -void EXPORT_FUNC (_savegpr_24 ) (void ); -void EXPORT_FUNC (_savegpr_25 ) (void ); -void EXPORT_FUNC (_savegpr_26 ) (void );
include/grub/libgcc.h line 21
Quoted 10 lines
include/grub/libgcc.h +0
-7-void EXPORT_FUNC (_savegpr_27 ) (void ); -void EXPORT_FUNC (_savegpr_28 ) (void ); -void EXPORT_FUNC (_savegpr_29 ) (void ); -void EXPORT_FUNC (_savegpr_30 ) (void ); -void EXPORT_FUNC (_savegpr_31 ) (void ); -#endif -#if defined (__arm__)void EXPORT_FUNC (__aeabi_lasr ) (void );void EXPORT_FUNC (__aeabi_llsl ) (void );
I don't think you should touch this file at all. I don't know precisely how it's used, but it only seems to be used to generate symbol lists; furthermore, you're removing some things from it that are not clearly powerpc-specific and either making them powerpc-specific (__ashldi3, __ashrdi3, __lshrdi3, __ucmpdi2) or dropping them altogether (__bswapsi2, __bswapdi2). This is worrisome and suggests the possibility that this will break other architectures. Does your patch work if you just leave include/grub/libgcc.h unmodified?
Thanks,
Signature · 1 line
Colin Watson [[email protected]]
Re: [RFC PATCH 2/3] Files reorganization and include some libgcc fuctions
Colin, I changed the patches following your suggestions and making it more likely to the no-libgcc branch from Vladimir. In this branch, phcoder added compiler-rt.{c,h,S} with the necessary code in it.
My approach is very minimalist and only for powerpc. I tried to avoid change the behavior for other architecture since we are in code freeze.
In the future we can think in spread this approach for all archs and use all implementation that phcoder is doing in the no-libgcc branch.
Quoted 16 lines · Colin Watson
grub-core/kern/misc.c grub_real_boot_time (const char *file, · line 1346
Quoted 10 lines · Paulo Flabiano Smorigo
grub-core/kern/misc.c +2
-0@@ -1342,3 +1342,110 @@ grub_real_boot_time (const char *file, grub_error_pop (); }#endif + +#if defined (NO_LIBGCC )Should this perhaps be restricted to
__powerpc__as well? Alternatively, the prototypes ininclude/grub/compiler.h(orinclude/grub/misc.h; see below) should be used on other architectures too. Either way, the declarations and definitions should match.
Yes, now I only use __powerpc__
Quoted 9 lines
Quoted 9 lines
include/grub/compiler.h +0
-0@@ -48,4 +48,65 @@# define WARN_UNUSED_RESULT #endif
Quoted 5 lines
include/grub/compiler.h line 51
Quoted 1 line
include/grub/compiler.h +1
-0+#include "types.h" Shouldn't this be #include <
grub/types.h>, assuming that you need this for grub_uint*_t? Also, includes should generally be grouped at the top of the file.
All in the compile-rt.c now
Quoted 19 lines
Quoted 5 lines
include/grub/compiler.h +4
-0+union component64 +{ +grub_uint64_t full; + structinclude/grub/compiler.h line 65
Quoted 10 lines
include/grub/compiler.h +10
-0+ { +#ifdef GRUB_CPU_WORDS_BIGENDIAN +grub_uint32_t high; +grub_uint32_t low; +#else +grub_uint32_t low; +grub_uint32_t high; +#endif + }; +};This is only used by
grub-core/kern/misc.c. Please move it there rather than putting it somewhere that's included by everything in GRUB.
Quoted 6 lines
include/grub/compiler.h line 66
Quoted 1 line
include/grub/compiler.h +1
-0+#if defined (__powerpc__)Should this be #if defined (
__powerpc__) && defined (NO_LIBGCC) or something similar, to match the general way things are set up in configure.ac? (Also see comment above about declarations matching definitions.)
Fixed.
Quoted 5 lines
Relatedly, have you tested this patch set with a native build on a 32-bit BE powerpc system, as opposed to 32-bit BE built on a 64-bit LE system? This looks like a potential problem there.
Yes. I tested it in both BE and LE systems. No problem found. I did another round of test with this changes and will do some more this week.
Quoted 11 lines
include/grub/compiler.h line 71
Quoted 5 lines
include/grub/compiler.h +5
-0+grub_uint64_t EXPORT_FUNC (__lshrdi3 ) (grub_uint64_t u,int b); +grub_uint64_t EXPORT_FUNC (__ashrdi3 ) (grub_uint64_t u,int b); +grub_uint64_t EXPORT_FUNC (__ashldi3 ) (grub_uint64_t u,int b); +int EXPORT_FUNC (__ucmpdi2 ) (grub_uint64_t a,grub_uint64_t b); +void EXPORT_FUNC (_restgpr_14_x ) (void );[...]
These aren't compiler features, so don't belong in
include/grub/compiler.h. Other architectures seem to have this kind of thing ininclude/grub/misc.hinside a big #ifndefGRUB_UTILconditional, so please move all this to there.
Yes, I follow what phcoder did in no-libgcc branch. This lines are in the compiler-rt.c file.
Quoted 80 lines
Quoted 69 lines
include/grub/libgcc.h +0
-60@@ -16,73 +16,6 @@* along with GRUB. If not, see <http://www.gnu.org/licenses/>. */ -/* We need to include config-util.h.in for HAVE_*. */ -#ifndef __STDC_VERSION__ -#define __STDC_VERSION__ 0 -#endif -#include <config-util.h> - -/* On x86 these functions aren't really needed. Save some space. */ -#if !defined (__i386__) && !defined (__x86_64__) -# ifdef HAVE___ASHLDI3 -void EXPORT_FUNC (__ashldi3 ) (void ); -# endif -# ifdef HAVE___ASHRDI3 -void EXPORT_FUNC (__ashrdi3 ) (void ); -# endif -# ifdef HAVE___LSHRDI3 -void EXPORT_FUNC (__lshrdi3 ) (void ); -# endif -# ifdef HAVE___UCMPDI2 -void EXPORT_FUNC (__ucmpdi2 ) (void ); -# endif -# ifdef HAVE___BSWAPSI2 -void EXPORT_FUNC (__bswapsi2 ) (void ); -# endif -# ifdef HAVE___BSWAPDI2 -void EXPORT_FUNC (__bswapdi2 ) (void ); -# endif -#endif - -#ifdef HAVE__RESTGPR_14_X -void EXPORT_FUNC (_restgpr_14_x ) (void ); -void EXPORT_FUNC (_restgpr_15_x ) (void ); -void EXPORT_FUNC (_restgpr_16_x ) (void ); -void EXPORT_FUNC (_restgpr_17_x ) (void ); -void EXPORT_FUNC (_restgpr_18_x ) (void ); -void EXPORT_FUNC (_restgpr_19_x ) (void ); -void EXPORT_FUNC (_restgpr_20_x ) (void ); -void EXPORT_FUNC (_restgpr_21_x ) (void ); -void EXPORT_FUNC (_restgpr_22_x ) (void ); -void EXPORT_FUNC (_restgpr_23_x ) (void ); -void EXPORT_FUNC (_restgpr_24_x ) (void ); -void EXPORT_FUNC (_restgpr_25_x ) (void ); -void EXPORT_FUNC (_restgpr_26_x ) (void ); -void EXPORT_FUNC (_restgpr_27_x ) (void ); -void EXPORT_FUNC (_restgpr_28_x ) (void ); -void EXPORT_FUNC (_restgpr_29_x ) (void ); -void EXPORT_FUNC (_restgpr_30_x ) (void ); -void EXPORT_FUNC (_restgpr_31_x ) (void ); -void EXPORT_FUNC (_savegpr_14 ) (void ); -void EXPORT_FUNC (_savegpr_15 ) (void ); -void EXPORT_FUNC (_savegpr_16 ) (void ); -void EXPORT_FUNC (_savegpr_17 ) (void ); -void EXPORT_FUNC (_savegpr_18 ) (void ); -void EXPORT_FUNC (_savegpr_19 ) (void ); -void EXPORT_FUNC (_savegpr_20 ) (void ); -void EXPORT_FUNC (_savegpr_21 ) (void ); -void EXPORT_FUNC (_savegpr_22 ) (void ); -void EXPORT_FUNC (_savegpr_23 ) (void ); -void EXPORT_FUNC (_savegpr_24 ) (void ); -void EXPORT_FUNC (_savegpr_25 ) (void ); -void EXPORT_FUNC (_savegpr_26 ) (void );include/grub/libgcc.h line 21
Quoted 10 lines
include/grub/libgcc.h +0
-7-void EXPORT_FUNC (_savegpr_27 ) (void ); -void EXPORT_FUNC (_savegpr_28 ) (void ); -void EXPORT_FUNC (_savegpr_29 ) (void ); -void EXPORT_FUNC (_savegpr_30 ) (void ); -void EXPORT_FUNC (_savegpr_31 ) (void ); -#endif -#if defined (__arm__)void EXPORT_FUNC (__aeabi_lasr ) (void );void EXPORT_FUNC (__aeabi_llsl ) (void );
Quoted 8 lines
I don't think you should touch this file at all. I don't know precisely how it's used, but it only seems to be used to generate symbol lists; furthermore, you're removing some things from it that are not clearly powerpc-specific and either making them powerpc-specific (
__ashldi3,__ashrdi3,__lshrdi3,__ucmpdi2) or dropping them altogether (__bswapsi2,__bswapdi2). This is worrisome and suggests the possibility that this will break other architectures. Does your patch work if you just leaveinclude/grub/libgcc.hunmodified?
Please, check this new patchset. libgcc.h is intact.
Quoted 11 lines
Thanks,
Signature · 6 lines
Colin Watson [[email protected]] _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Paulo Flabiano Smorigo IBM Linux Technology Center
From 45cd4be413b1ef318406480deb69ab8e9bb8fe45 Mon Sep 17 00:00:00 2001
From: Paulo Flabiano Smorigo <[email protected]>
Date: Wed, 17 Sep 2014 14:44:30 -0300
Subject: [PATCH 2/2] Skip libgcc dependency for powerpc
* configure.ac: Add conditions to avoid libgcc dependency.
* Makefile.am: Likewise.
* Makefile.core.def: Include compiler-rt.S and compiler-rt.c.
* compiler-rt.c: New file.
* compiler-rt.S: Likewise.
* compiler-rt.h: Likewise.
--- configure.ac | 10 ++- grub-core/Makefile.am | 1 + grub-core/Makefile.core.def | 2 + grub-core/kern/compiler-rt.c | 166 +++++++++++++++++++++++++++++++++++ grub-core/kern/powerpc/compiler-rt.S | 130 +++++++++++++++++++++++++++ include/grub/compiler-rt.h | 82 +++++++++++++++++ 6 files changed, 387 insertions(+), 4 deletions(-) create mode 100644 grub-core/kern/compiler-rt.c create mode 100644 grub-core/kern/powerpc/compiler-rt.S create mode 100644 include/grub/compiler-rt.h
configure.ac +6 -4
@@ -1033,7 +1033,7 @@ else CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error" fi CPPFLAGS="$TARGET_CPPFLAGS" -if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then +if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test x$target_cpu = xpowerpc || test "x$grub_cv_cc_target_clang" = xyes; then TARGET_LIBGCC= else TARGET_LIBGCC=-lgcc
@@ -1051,8 +1051,10 @@ fi CFLAGS="$TARGET_CFLAGS -nostdlib $DEFSYM" fi -# Check for libgcc symbols -AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x) +if ! test x$target_cpu = xpowerpc; then + # Check for libgcc symbols + AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x) +fi if test "x$TARGET_APPLE_LINKER" = x1 ; then CFLAGS="$TARGET_CFLAGS -nostdlib -static"
@@ -1617,7 +1619,7 @@ if test x"$enable_werror" != xno ; then HOST_CFLAGS="$HOST_CFLAGS -Werror" fi -if test "x$grub_cv_cc_target_clang" = xno; then +if test "x$grub_cv_cc_target_clang" = xno && test x$target_cpu != xpowerpc; then TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc" else TARGET_LDFLAGS_STATIC_LIBGCC=
grub-core/Makefile.am +1 -0
@@ -76,6 +76,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i18n.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/kernel.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/list.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/misc.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/compiler-rt.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/parser.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/partition.h
grub-core/Makefile.core.def +2 -0
@@ -132,6 +132,7 @@ kernel = { common = kern/rescue_reader.c; common = kern/term.c; + noemu = kern/compiler-rt.c; noemu = kern/mm.c; noemu = kern/time.c; noemu = kern/generic/millisleep.c;
@@ -252,6 +253,7 @@ kernel = { powerpc_ieee1275 = kern/powerpc/cache.S; powerpc_ieee1275 = kern/powerpc/dl.c; + powerpc_ieee1275 = kern/powerpc/compiler-rt.S; sparc64_ieee1275 = kern/sparc64/cache.S; sparc64_ieee1275 = kern/sparc64/dl.c;
grub-core/kern/compiler-rt.c new file +166 -0
166 lines not on this page · raw message
grub-core/kern/powerpc/compiler-rt.S new file +130 -0
130 lines not on this page · raw message
include/grub/compiler-rt.h new file +82 -0
82 lines not on this page · raw message
Signature · 1 line
1.8.4.2
Re: [RFC PATCH 2/3] Files reorganization and include some libgcc fuctions
Quoted 9 lines · Paulo Flabiano Smorigo
Colin, I changed the patches following your suggestions and making it more likely to the no-libgcc branch from Vladimir. In this branch, phcoder added compiler-rt.{c,h,S} with the necessary code in it.
My approach is very minimalist and only for powerpc. I tried to avoid change the behavior for other architecture since we are in code freeze.
In the future we can think in spread this approach for all archs and use all implementation that phcoder is doing in the no-libgcc branch.
Thanks, this looks much better now. I don't feel comfortable pushing it to master without Vladimir's signoff, but I'll apply this and patch 1/3 to Debian for the time being so that we can get rid of the build-dependency on a cross-compiler.
Cheers,
Signature · 1 line
Colin Watson [[email protected]]
Re: [RFC PATCH 2/3] Files reorganization and include some libgcc fuctions
In reply to Paulo Flabiano SmorigoQuoted 4 lines · Paulo Flabiano Smorigo
Colin, I changed the patches following your suggestions and making it more likely to the no-libgcc branch from Vladimir. In this branch, phcoder added compiler-rt.{c,h,S} with the necessary code in it.
compiler-rt.{c,S} fixes bunch of possible problems when libgcc doesn't match the intended platform (e.g. because of SSE flags). So I think we should have whole thing go in.
Biggest problem is the lack of tests for those functions.
Quoted 205 lines
My approach is very minimalist and only for powerpc. I tried to avoid change the behavior for other architecture since we are in code freeze.
In the future we can think in spread this approach for all archs and use all implementation that phcoder is doing in the no-libgcc branch.
Quoted 16 lines · Colin Watson
grub-core/kern/misc.c grub_real_boot_time (const char *file, · line 1346
Quoted 10 lines · Paulo Flabiano Smorigo
grub-core/kern/misc.c +2
-0@@ -1342,3 +1342,110 @@ grub_real_boot_time (const char *file, grub_error_pop (); }#endif + +#if defined (NO_LIBGCC )Should this perhaps be restricted to
__powerpc__as well? Alternatively, the prototypes ininclude/grub/compiler.h(orinclude/grub/misc.h; see below) should be used on other architectures too. Either way, the declarations and definitions should match.Yes, now I only use
__powerpc__Quoted 9 lines
Quoted 9 lines
include/grub/compiler.h +0
-0@@ -48,4 +48,65 @@# define WARN_UNUSED_RESULT #endif Quoted 5 lines
include/grub/compiler.h line 51
Quoted 1 line
include/grub/compiler.h +1
-0+#include "types.h" Shouldn't this be #include <
grub/types.h>, assuming that you need this for grub_uint*_t? Also, includes should generally be grouped at the top of the file.All in the
compile-rt.cnowQuoted 19 lines
Quoted 5 lines
include/grub/compiler.h +4
-0+union component64 +{ +grub_uint64_t full; + structinclude/grub/compiler.h line 65
Quoted 10 lines
include/grub/compiler.h +10
-0+ { +#ifdef GRUB_CPU_WORDS_BIGENDIAN +grub_uint32_t high; +grub_uint32_t low; +#else +grub_uint32_t low; +grub_uint32_t high; +#endif + }; +};This is only used by
grub-core/kern/misc.c. Please move it there rather than putting it somewhere that's included by everything in GRUB.Quoted 6 lines
include/grub/compiler.h line 66
Quoted 1 line
include/grub/compiler.h +1
-0+#if defined (__powerpc__)Should this be #if defined (
__powerpc__) && defined (NO_LIBGCC) or something similar, to match the general way things are set up in configure.ac? (Also see comment above about declarations matching definitions.)Fixed.
Quoted 5 lines
Relatedly, have you tested this patch set with a native build on a 32-bit BE powerpc system, as opposed to 32-bit BE built on a 64-bit LE system? This looks like a potential problem there.
Yes. I tested it in both BE and LE systems. No problem found. I did another round of test with this changes and will do some more this week.
Quoted 11 lines
include/grub/compiler.h line 71
Quoted 5 lines
include/grub/compiler.h +5
-0+grub_uint64_t EXPORT_FUNC (__lshrdi3 ) (grub_uint64_t u,int b); +grub_uint64_t EXPORT_FUNC (__ashrdi3 ) (grub_uint64_t u,int b); +grub_uint64_t EXPORT_FUNC (__ashldi3 ) (grub_uint64_t u,int b); +int EXPORT_FUNC (__ucmpdi2 ) (grub_uint64_t a,grub_uint64_t b); +void EXPORT_FUNC (_restgpr_14_x ) (void );[...]
These aren't compiler features, so don't belong in
include/grub/compiler.h. Other architectures seem to have this kind of thing ininclude/grub/misc.hinside a big #ifndefGRUB_UTILconditional, so please move all this to there.Yes, I follow what phcoder did in no-libgcc branch. This lines are in the
compiler-rt.cfile.Quoted 80 lines
Quoted 69 lines
include/grub/libgcc.h +0
-60@@ -16,73 +16,6 @@* along with GRUB. If not, see <http://www.gnu.org/licenses/>. */ -/* We need to include config-util.h.in for HAVE_*. */ -#ifndef __STDC_VERSION__ -#define __STDC_VERSION__ 0 -#endif -#include <config-util.h> - -/* On x86 these functions aren't really needed. Save some space. */ -#if !defined (__i386__) && !defined (__x86_64__) -# ifdef HAVE___ASHLDI3 -void EXPORT_FUNC (__ashldi3 ) (void ); -# endif -# ifdef HAVE___ASHRDI3 -void EXPORT_FUNC (__ashrdi3 ) (void ); -# endif -# ifdef HAVE___LSHRDI3 -void EXPORT_FUNC (__lshrdi3 ) (void ); -# endif -# ifdef HAVE___UCMPDI2 -void EXPORT_FUNC (__ucmpdi2 ) (void ); -# endif -# ifdef HAVE___BSWAPSI2 -void EXPORT_FUNC (__bswapsi2 ) (void ); -# endif -# ifdef HAVE___BSWAPDI2 -void EXPORT_FUNC (__bswapdi2 ) (void ); -# endif -#endif - -#ifdef HAVE__RESTGPR_14_X -void EXPORT_FUNC (_restgpr_14_x ) (void ); -void EXPORT_FUNC (_restgpr_15_x ) (void ); -void EXPORT_FUNC (_restgpr_16_x ) (void ); -void EXPORT_FUNC (_restgpr_17_x ) (void ); -void EXPORT_FUNC (_restgpr_18_x ) (void ); -void EXPORT_FUNC (_restgpr_19_x ) (void ); -void EXPORT_FUNC (_restgpr_20_x ) (void ); -void EXPORT_FUNC (_restgpr_21_x ) (void ); -void EXPORT_FUNC (_restgpr_22_x ) (void ); -void EXPORT_FUNC (_restgpr_23_x ) (void ); -void EXPORT_FUNC (_restgpr_24_x ) (void ); -void EXPORT_FUNC (_restgpr_25_x ) (void ); -void EXPORT_FUNC (_restgpr_26_x ) (void ); -void EXPORT_FUNC (_restgpr_27_x ) (void ); -void EXPORT_FUNC (_restgpr_28_x ) (void ); -void EXPORT_FUNC (_restgpr_29_x ) (void ); -void EXPORT_FUNC (_restgpr_30_x ) (void ); -void EXPORT_FUNC (_restgpr_31_x ) (void ); -void EXPORT_FUNC (_savegpr_14 ) (void ); -void EXPORT_FUNC (_savegpr_15 ) (void ); -void EXPORT_FUNC (_savegpr_16 ) (void ); -void EXPORT_FUNC (_savegpr_17 ) (void ); -void EXPORT_FUNC (_savegpr_18 ) (void ); -void EXPORT_FUNC (_savegpr_19 ) (void ); -void EXPORT_FUNC (_savegpr_20 ) (void ); -void EXPORT_FUNC (_savegpr_21 ) (void ); -void EXPORT_FUNC (_savegpr_22 ) (void ); -void EXPORT_FUNC (_savegpr_23 ) (void ); -void EXPORT_FUNC (_savegpr_24 ) (void ); -void EXPORT_FUNC (_savegpr_25 ) (void ); -void EXPORT_FUNC (_savegpr_26 ) (void );include/grub/libgcc.h line 21
Quoted 10 lines
include/grub/libgcc.h +0
-7-void EXPORT_FUNC (_savegpr_27 ) (void ); -void EXPORT_FUNC (_savegpr_28 ) (void ); -void EXPORT_FUNC (_savegpr_29 ) (void ); -void EXPORT_FUNC (_savegpr_30 ) (void ); -void EXPORT_FUNC (_savegpr_31 ) (void ); -#endif -#if defined (__arm__)void EXPORT_FUNC (__aeabi_lasr ) (void );void EXPORT_FUNC (__aeabi_llsl ) (void );Quoted 8 lines
I don't think you should touch this file at all. I don't know precisely how it's used, but it only seems to be used to generate symbol lists; furthermore, you're removing some things from it that are not clearly powerpc-specific and either making them powerpc-specific (
__ashldi3,__ashrdi3,__lshrdi3,__ucmpdi2) or dropping them altogether (__bswapsi2,__bswapdi2). This is worrisome and suggests the possibility that this will break other architectures. Does your patch work if you just leaveinclude/grub/libgcc.hunmodified?Please, check this new patchset.
libgcc.his intact.Quoted 11 lines
Thanks,
Signature · 6 lines
Colin Watson [[email protected]] _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
RFC PATCH 3/3 Suport for bi-endianess in elf file
In reply to Paulo Flabiano Smorigo* grub-core/kern/elf.c: check and switch endianess with grub_{be,le}_to cpu functions.
* grub-core/kern/elfXX.c: Likewise.
--- grub-core/kern/elf.c | 60 +++++++++++++++++++++++++++++++++++++++-- grub-core/kern/elfXX.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+), 2 deletions(-)
grub-core/kern/elf.c +58 -2
@@ -28,6 +28,11 @@GRUB_MOD_LICENSE ("GPLv3+" ); +void grub_elf32_check_endianess (grub_elf_t elf); +void grub_elf64_check_endianess (grub_elf_t elf); +grub_err_t grub_elf32_check_version (grub_elf_t elf); +grub_err_t grub_elf64_check_version (grub_elf_t elf); +/* Check if EHDR is a valid ELF header. */ static grub_err_t grub_elf_check_header (grub_elf_t elf)
@@ -38,10 +43,22 @@ grub_elf_check_header (grub_elf_t elf) || e->e_ident[EI_MAG1] != ELFMAG1 || e->e_ident[EI_MAG2] != ELFMAG2 || e->e_ident[EI_MAG3] != ELFMAG3 - || e->e_ident[EI_VERSION] != EV_CURRENT - || e->e_version != EV_CURRENT) + || e->e_ident[EI_VERSION] != EV_CURRENT)return grub_error (GRUB_ERR_BAD_OS ,N_ ("invalid arch-independent ELF magic" )); +if (grub_elf_is_elf32 (elf)) + { +grub_elf32_check_endianess (elf); +grub_elf32_check_version (elf); + } +else if (grub_elf_is_elf64 (elf)) + { +grub_elf64_check_endianess (elf); +grub_elf64_check_version (elf); + } +else +return grub_error (GRUB_ERR_BAD_OS ,N_ ("invalid arch-dependent ELF magic" )); +return GRUB_ERR_NONE ; }
@@ -127,7 +144,20 @@ grub_elf_open (const char *name)#define grub_elf_is_elfXX grub_elf_is_elf32#define grub_elfXX_load_phdrs grub_elf32_load_phdrs#define ElfXX_Phdr Elf32_Phdr +#define ElfXX_Ehdr Elf32_Ehdr#define grub_uintXX_t grub_uint32_t +#define grub_be_to_halfXX grub_be_to_cpu16 +#define grub_be_to_wordXX grub_be_to_cpu32 +#define grub_be_to_addrXX grub_be_to_cpu32 +#define grub_be_to_offXX grub_be_to_cpu32 +#define grub_be_to_XwordXX grub_be_to_wordXX +#define grub_le_to_halfXX grub_le_to_cpu16 +#define grub_le_to_wordXX grub_le_to_cpu32 +#define grub_le_to_addrXX grub_le_to_cpu32 +#define grub_le_to_offXX grub_le_to_cpu32 +#define grub_le_to_XwordXX grub_le_to_wordXX +#define grub_elfXX_check_endianess grub_elf32_check_endianess +#define grub_elfXX_check_version grub_elf32_check_version#include "elfXX.c"
@@ -140,7 +170,20 @@ grub_elf_open (const char *name)#undef grub_elf_is_elfXX#undef grub_elfXX_load_phdrs#undef ElfXX_Phdr +#undef ElfXX_Ehdr#undef grub_uintXX_t +#undef grub_be_to_halfXX +#undef grub_be_to_wordXX +#undef grub_be_to_addrXX +#undef grub_be_to_offXX +#undef grub_be_to_XwordXX +#undef grub_le_to_halfXX +#undef grub_le_to_wordXX +#undef grub_le_to_addrXX +#undef grub_le_to_offXX +#undef grub_le_to_XwordXX +#undef grub_elfXX_check_endianess +#undef grub_elfXX_check_version/* 64-bit */
@@ -153,6 +196,19 @@ grub_elf_open (const char *name)#define grub_elf_is_elfXX grub_elf_is_elf64#define grub_elfXX_load_phdrs grub_elf64_load_phdrs#define ElfXX_Phdr Elf64_Phdr +#define ElfXX_Ehdr Elf64_Ehdr#define grub_uintXX_t grub_uint64_t +#define grub_be_to_halfXX grub_be_to_cpu16 +#define grub_be_to_wordXX grub_be_to_cpu32 +#define grub_be_to_addrXX grub_be_to_cpu64 +#define grub_be_to_offXX grub_be_to_cpu64 +#define grub_be_to_XwordXX grub_be_to_cpu64 +#define grub_le_to_halfXX grub_le_to_cpu16 +#define grub_le_to_wordXX grub_le_to_cpu32 +#define grub_le_to_addrXX grub_le_to_cpu64 +#define grub_le_to_offXX grub_le_to_cpu64 +#define grub_le_to_XwordXX grub_le_to_cpu64 +#define grub_elfXX_check_endianess grub_elf64_check_endianess +#define grub_elfXX_check_version grub_elf64_check_version#include "elfXX.c"
grub-core/kern/elfXX.c +73 -0
76 lines not on this page · raw message
Signature · 1 line
1.8.1.4
Re: [RFC PATCH 3/3] Suport for bi-endianess in elf file
Quoted 4 lines · Paulo Flabiano Smorigo
*
grub-core/kern/elf.c: check and switch endianess with grub_{be,le}_to cpu functions.
*grub-core/kern/elfXX.c: Likewise.
As a general comment - currently we need it for one platform only so let's wrap additional code in #ifdef __powerpc__ until any more users emerge, to avoid dead code on other platforms (especially size-critical like i386-pc).
Quoted 31 lines
--- grub-core/kern/elf.c | 60 +++++++++++++++++++++++++++++++++++++++-- grub-core/kern/elfXX.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+), 2 deletions(-)grub-core/kern/elf.c +6
-2@@ -28,6 +28,11 @@GRUB_MOD_LICENSE ("GPLv3+" ); +void grub_elf32_check_endianess (grub_elf_t elf); +void grub_elf64_check_endianess (grub_elf_t elf); +grub_err_t grub_elf32_check_version (grub_elf_t elf); +grub_err_t grub_elf64_check_version (grub_elf_t elf); +/* Check if EHDR is a valid ELF header. */ static grub_err_t grub_elf_check_header (grub_elf_t elf)@@ -38,10 +43,22 @@ grub_elf_check_header (grub_elf_t elf) || e->e_ident[EI_MAG1] != ELFMAG1 || e->e_ident[EI_MAG2] != ELFMAG2 || e->e_ident[EI_MAG3] != ELFMAG3 - || e->e_ident[EI_VERSION] != EV_CURRENT - || e->e_version != EV_CURRENT) + || e->e_ident[EI_VERSION] != EV_CURRENT)return grub_error (GRUB_ERR_BAD_OS ,N_ ("invalid arch-independent ELF magic" ));
grub-core/kern/elf.c grub_elf_check_header (grub_elf_t elf) · line 58
Quoted 10 lines
grub-core/kern/elf.c +10
-0+if (grub_elf_is_elf32 (elf)) + { +grub_elf32_check_endianess (elf); +grub_elf32_check_version (elf); + } +else if (grub_elf_is_elf64 (elf)) + { +grub_elf64_check_endianess (elf); +grub_elf64_check_version (elf); + }
This ignores any errors these functions may return. I would suggest
#if defined(__powerpc__)
if ((grub_elf_is_elf32 (elf))
grub_elf32_check_endianess (elf);
...
grub-core/kern/elf.c grub_elf_check_header (grub_elf_t elf) · line 61
Quoted 3 lines
grub-core/kern/elf.c +3
-0+else +return grub_error (GRUB_ERR_BAD_OS ,N_ ("invalid arch-dependent ELF magic" )); +
It probably should be "Uknown ELF class" here.
#endif /* __powerpc__ */
if (e->e_version != EV_CURRENT)
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-independent ELF
magic"));
Quoted 4 lines
grub-core/kern/elf.c +0
-0return GRUB_ERR_NONE ; }
grub-core/kern/elf.c grub_elf_open (const char *name) · line 153
Quoted 10 lines
grub-core/kern/elf.c +6
-0@@ -127,7 +144,20 @@ grub_elf_open (const char *name)#define grub_elf_is_elfXX grub_elf_is_elf32#define grub_elfXX_load_phdrs grub_elf32_load_phdrs#define ElfXX_Phdr Elf32_Phdr +#define ElfXX_Ehdr Elf32_Ehdr#define grub_uintXX_t grub_uint32_t +#define grub_be_to_halfXX grub_be_to_cpu16 +#define grub_be_to_wordXX grub_be_to_cpu32 +#define grub_be_to_addrXX grub_be_to_cpu32 +#define grub_be_to_offXX grub_be_to_cpu32 +#define grub_be_to_XwordXX grub_be_to_wordXX
Only addr and off are different between 32/64. Do we really need to define others?
Quoted 56 lines
grub-core/kern/elf.c +33
-0+#define grub_le_to_halfXX grub_le_to_cpu16 +#define grub_le_to_wordXX grub_le_to_cpu32 +#define grub_le_to_addrXX grub_le_to_cpu32 +#define grub_le_to_offXX grub_le_to_cpu32 +#define grub_le_to_XwordXX grub_le_to_wordXX +#define grub_elfXX_check_endianess grub_elf32_check_endianess +#define grub_elfXX_check_version grub_elf32_check_version#include "elfXX.c" @@ -140,7 +170,20 @@ grub_elf_open (const char *name)#undef grub_elf_is_elfXX#undef grub_elfXX_load_phdrs#undef ElfXX_Phdr +#undef ElfXX_Ehdr#undef grub_uintXX_t +#undef grub_be_to_halfXX +#undef grub_be_to_wordXX +#undef grub_be_to_addrXX +#undef grub_be_to_offXX +#undef grub_be_to_XwordXX +#undef grub_le_to_halfXX +#undef grub_le_to_wordXX +#undef grub_le_to_addrXX +#undef grub_le_to_offXX +#undef grub_le_to_XwordXX +#undef grub_elfXX_check_endianess +#undef grub_elfXX_check_version/* 64-bit */ @@ -153,6 +196,19 @@ grub_elf_open (const char *name)#define grub_elf_is_elfXX grub_elf_is_elf64#define grub_elfXX_load_phdrs grub_elf64_load_phdrs#define ElfXX_Phdr Elf64_Phdr +#define ElfXX_Ehdr Elf64_Ehdr#define grub_uintXX_t grub_uint64_t +#define grub_be_to_halfXX grub_be_to_cpu16 +#define grub_be_to_wordXX grub_be_to_cpu32 +#define grub_be_to_addrXX grub_be_to_cpu64 +#define grub_be_to_offXX grub_be_to_cpu64 +#define grub_be_to_XwordXX grub_be_to_cpu64 +#define grub_le_to_halfXX grub_le_to_cpu16 +#define grub_le_to_wordXX grub_le_to_cpu32 +#define grub_le_to_addrXX grub_le_to_cpu64 +#define grub_le_to_offXX grub_le_to_cpu64 +#define grub_le_to_XwordXX grub_le_to_cpu64 +#define grub_elfXX_check_endianess grub_elf64_check_endianess +#define grub_elfXX_check_version grub_elf64_check_version#include "elfXX.c" grub-core/kern/elfXX.c +0
-0
grub-core/kern/elfXX.c grub_elfXX_load (grub_elf_t elf, const char *filename, · line 163
Quoted 10 lines
grub-core/kern/elfXX.c +7
-0@@ -154,3 +154,76 @@ grub_elfXX_load (grub_elf_t elf, const char *filename,return grub_errno; } + +void +grub_elfXX_check_endianess (grub_elf_t elf) +{ +ElfXX_Ehdr *e = &(elf->ehdr.ehdrXX); +ElfXX_Phdr *phdr; +
This block is not needed on BE systems; and as of this writing there is no LE system that needs it at all, so I suggest to leave it in place but effectively ifdef out like
#if !defined(GRUB_CPU_WORDS_BIGENDIAN) && 0
Quoted 8 lines
grub-core/kern/elfXX.c +8
-0+if (e->e_ident[EI_DATA ] ==ELFDATA2MSB ) + { + e->e_type =grub_be_to_halfXX (e->e_type); + e->e_machine =grub_be_to_halfXX (e->e_machine); + e->e_version =grub_be_to_wordXX (e->e_version); + e->e_entry =grub_be_to_addrXX (e->e_entry); + e->e_phoff =grub_be_to_offXX (e->e_phoff); + e->e_shoff =grub_be_to_offXX (e->e_shoff);
grub-core/kern/elfXX.c grub_elfXX_load (grub_elf_t elf, const char *filename, · line 181
Quoted 10 lines
grub-core/kern/elfXX.c +10
-0+ e->e_flags =grub_be_to_wordXX (e->e_flags); + e->e_ehsize =grub_be_to_halfXX (e->e_ehsize); + e->e_phentsize =grub_be_to_halfXX (e->e_phentsize); + e->e_phnum =grub_be_to_halfXX (e->e_phnum); + e->e_shentsize =grub_be_to_halfXX (e->e_shentsize); + e->e_shnum =grub_be_to_halfXX (e->e_shnum); + e->e_shstrndx =grub_be_to_halfXX (e->e_shstrndx); + + FOR_ELFXX_PHDRS (elf,phdr) + {
I suggest split in two parts - first one to byteswap ELF headers and second one for p-sections in grub_elfXX_load_phdrs. This makes error handling easier - byteswap is always possible, and at the point it will be called in grub_elfXX_load_phdrs all error checks are done. Also it is not needed until version is validated and we actually decide to load sections.
And please wrap them under #ifdef __powerpc__ as well.
grub-core/kern/elfXX.c grub_elfXX_load (grub_elf_t elf, const char *filename, · line 191
Quoted 10 lines
grub-core/kern/elfXX.c +10
-0+ phdr->p_type =grub_be_to_wordXX (phdr->p_type); + phdr->p_flags =grub_be_to_wordXX (phdr->p_flags); + phdr->p_offset =grub_be_to_offXX (phdr->p_offset); + phdr->p_vaddr =grub_be_to_addrXX (phdr->p_vaddr); + phdr->p_paddr =grub_be_to_addrXX (phdr->p_paddr); + phdr->p_filesz =grub_be_to_XwordXX (phdr->p_filesz); + phdr->p_memsz =grub_be_to_XwordXX (phdr->p_memsz); + phdr->p_align =grub_be_to_XwordXX (phdr->p_align); + } + }
#endif
#if defined(GRUB_CPU_WORDS_BIGENDIAN) && defined(__powerpc__) (or whatever is needed to detect it) By the same logic code is needed on BE platforms only and so far only on PPC.
Quoted 28 lines
grub-core/kern/elfXX.c +28
-0+else if (e->e_ident[EI_DATA ] ==ELFDATA2LSB ) + { + e->e_type =grub_le_to_halfXX (e->e_type); + e->e_machine =grub_le_to_halfXX (e->e_machine); + e->e_version =grub_le_to_wordXX (e->e_version); + e->e_entry =grub_le_to_addrXX (e->e_entry); + e->e_phoff =grub_le_to_offXX (e->e_phoff); + e->e_shoff =grub_le_to_offXX (e->e_shoff); + e->e_flags =grub_le_to_wordXX (e->e_flags); + e->e_ehsize =grub_le_to_halfXX (e->e_ehsize); + e->e_phentsize =grub_le_to_halfXX (e->e_phentsize); + e->e_phnum =grub_le_to_halfXX (e->e_phnum); + e->e_shentsize =grub_le_to_halfXX (e->e_shentsize); + e->e_shnum =grub_le_to_halfXX (e->e_shnum); + e->e_shstrndx =grub_le_to_halfXX (e->e_shstrndx); + + FOR_ELFXX_PHDRS (elf,phdr) + { + phdr->p_type =grub_le_to_wordXX (phdr->p_type); + phdr->p_flags =grub_le_to_wordXX (phdr->p_flags); + phdr->p_offset =grub_le_to_offXX (phdr->p_offset); + phdr->p_vaddr =grub_le_to_addrXX (phdr->p_vaddr); + phdr->p_paddr =grub_le_to_addrXX (phdr->p_paddr); + phdr->p_filesz =grub_le_to_XwordXX (phdr->p_filesz); + phdr->p_memsz =grub_le_to_XwordXX (phdr->p_memsz); + phdr->p_align =grub_le_to_XwordXX (phdr->p_align); + } + }
grub-core/kern/elfXX.c grub_elfXX_load (grub_elf_t elf, const char *filename, · line 229
Quoted 10 lines
grub-core/kern/elfXX.c +10
-0+} + +grub_err_t +grub_elfXX_check_version (grub_elf_t elf) +{ +if (elf->ehdr.ehdrXX.e_version !=EV_CURRENT ) +return grub_error (GRUB_ERR_BAD_OS ,N_ ("invalid arch-independent ELF magic" )); + +return GRUB_ERR_NONE ; +}
This becomes redundant with suggested reorder.
Quoted 8 lines
--
1.8.1.4_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
В Thu, 28 Aug 2014 16:56:02 -0300
Paulo Flabiano Smorigo <[email protected]> пишет:
Quoted 17 lines
From: Paulo Flabiano Smorigo <[email protected]>
Hi,
At the beginning of the year we provide a patchset that enabled GRUB for little-endian PowerPC. Our approach at the time was to build GRUB itself and its tools in 64-bit little-endian. One of the reasons of build in 64-bit is to avoid 32-bit dependencies in the distro and build a system entirely 64-bit.
This patchset was not welcomed at the time because it would bring a high-maintainance-cost, without real gain since it could just be cross-compiled.
After that, Brent Baude, Vladmir (phcoder) and I started to work in a solution that would cross-compile but without 32-bit dependencies. This patchset is the result of this new approach. It's based on the work of Brent Baude, Vladimir (phcoder), and Tomohiro.
Quoted 9 lines
It can be devided in two parts:
1) Skip libgcc dependency just for ppc64el (patch 1 and 2);
2) Check elf endianess and byteswap if necessary (patch 3);The result is GRUB itself in 32-bit BE and its tools in 64-bit LE. This solution satisfies the needs of the distros. I tested it in three different distros, in both endianess and it's fine.
Unfortunately I'm still not able to boot this version on QEMU. I build on openSUSE for three acrhs - ppc, ppc64, ppc64le. First two are OK and boot successfully. Third one does not work - it ends up in exception. I get initial GRUB greeting and that's all.
Same problem I got with Vladimir libgcc patch series.
It could be toolkit issue of course; but still it would need fixing before we can merge it.
Could you help in debugging this issue? I have near to zero experience with PPC; I can do what you tell me, but not much more.
I run it with
qemu-system-ppc64 -M pseries -cdrom /tmp/grub2-ppc64le.iso -boot d
Attached is screenshot of error.
В Sun, 21 Sep 2014 17:58:44 +0400
Andrei Borzenkov <[email protected]> пишет:
Quoted 40 lines
В Thu, 28 Aug 2014 16:56:02 -0300
Paulo Flabiano Smorigo <[email protected]> пишет:Quoted 17 lines
From: Paulo Flabiano Smorigo <[email protected]>
Hi,
At the beginning of the year we provide a patchset that enabled GRUB for little-endian PowerPC. Our approach at the time was to build GRUB itself and its tools in 64-bit little-endian. One of the reasons of build in 64-bit is to avoid 32-bit dependencies in the distro and build a system entirely 64-bit.
This patchset was not welcomed at the time because it would bring a high-maintainance-cost, without real gain since it could just be cross-compiled.
After that, Brent Baude, Vladmir (phcoder) and I started to work in a solution that would cross-compile but without 32-bit dependencies. This patchset is the result of this new approach. It's based on the work of Brent Baude, Vladimir (phcoder), and Tomohiro.
Quoted 9 lines
It can be devided in two parts:
1) Skip libgcc dependency just for ppc64el (patch 1 and 2);
2) Check elf endianess and byteswap if necessary (patch 3);The result is GRUB itself in 32-bit BE and its tools in 64-bit LE. This solution satisfies the needs of the distros. I tested it in three different distros, in both endianess and it's fine.
Unfortunately I'm still not able to boot this version on QEMU. I build on openSUSE for three acrhs - ppc, ppc64, ppc64le. First two are OK and boot successfully. Third one does not work - it ends up in exception. I get initial GRUB greeting and that's all.
Same problem I got with Vladimir libgcc patch series.
It could be toolkit issue of course; but still it would need fixing before we can merge it.
Quoted 10 lines
Could you help in debugging this issue? I have near to zero experience with PPC; I can do what you tell me, but not much more.
I run it with
qemu-system-ppc64 -M pseries -cdrom
/tmp/grub2-ppc64le.iso-boot dAttached is screenshot of error.
And here is the difference in generated code in case it helps (one random module as example) ...
tmp/a2 renamed from tmp/a1 +36 -36
@@ -1,5 +1,5 @@ -usr.ppc/lib/grub2/powerpc-ieee1275/ext2.mod: file format elf32-powerpc +usr.ppc64le/lib/grub2/powerpc-ieee1275/ext2.mod: file format elf32-powerpc Disassembly of section .text:
@@ -18,15 +18,15 @@ Disassembly of section .text: 28: 38 21 00 10 addi r1,r1,16 2c: 7c 08 03 a6 mtlr r0 30: 4e 80 00 20 blr - 34: 94 21 ff a0 stwu r1,-96(r1) + 34: 94 21 ff 90 stwu r1,-112(r1) 38: 38 e3 00 28 addi r7,r3,40 3c: 7d 80 00 26 mfcr r12 40: 39 23 00 14 addi r9,r3,20 44: 7c 08 02 a6 mflr r0 48: 39 43 00 18 addi r10,r3,24 - 4c: bf 61 00 4c stmw r27,76(r1) - 50: 90 01 00 64 stw r0,100(r1) - 54: 91 81 00 48 stw r12,72(r1) + 4c: bf 61 00 5c stmw r27,92(r1) + 50: 90 01 00 74 stw r0,116(r1) + 54: 91 81 00 58 stw r12,88(r1) 58: 3b c4 ff ff addi r30,r4,-1 5c: 7c 7f 1b 78 mr r31,r3 60: 7c bc 2b 78 mr r28,r5
@@ -103,10 +103,10 @@ Disassembly of section .text: 17c: 2f 83 00 00 cmpwi cr7,r3,0 180: 41 9e 00 08 beq cr7,188 <grub_mod_init-0xd50> 184: 81 3d 00 00 lwz r9,0(r29) - 188: 81 81 00 48 lwz r12,72(r1) - 18c: 39 61 00 60 addi r11,r1,96 + 188: 81 81 00 58 lwz r12,88(r1) + 18c: 39 61 00 70 addi r11,r1,112 190: 7d 23 4b 78 mr r3,r9 - 194: 7d 80 81 20 mtcrf 8,r12 + 194: 7d 90 81 20 mtocrf 8,r12 198: 48 00 00 00 b 198 <grub_mod_init-0xd40> 19c: 94 21 ff e0 stwu r1,-32(r1) 1a0: 7c 08 02 a6 mflr r0
@@ -234,10 +234,10 @@ Disassembly of section .text: 388: 39 61 00 20 addi r11,r1,32 38c: 80 69 00 00 lwz r3,0(r9) 390: 48 00 00 00 b 390 <grub_mod_init-0xb48> - 394: 94 21 ff b0 stwu r1,-80(r1) + 394: 94 21 ff a0 stwu r1,-96(r1) 398: 7c 08 02 a6 mflr r0 - 39c: be 61 00 1c stmw r19,28(r1) - 3a0: 90 01 00 54 stw r0,84(r1) + 39c: be 61 00 2c stmw r19,44(r1) + 3a0: 90 01 00 64 stw r0,100(r1) 3a4: 7c df 33 78 mr r31,r6 3a8: 7c be 2b 78 mr r30,r5 3ac: 83 63 00 00 lwz r27,0(r3)
@@ -489,12 +489,12 @@ Disassembly of section .text: 784: 48 00 00 0c b 790 <grub_mod_init-0x748> 788: 7f c3 f3 78 mr r3,r30 78c: 7f e4 fb 78 mr r4,r31 - 790: 39 61 00 50 addi r11,r1,80 + 790: 39 61 00 60 addi r11,r1,96 794: 48 00 00 00 b 794 <grub_mod_init-0x744> - 798: 94 21 ff e0 stwu r1,-32(r1) + 798: 94 21 ff d0 stwu r1,-48(r1) 79c: 7c 08 02 a6 mflr r0 - 7a0: bf a1 00 14 stmw r29,20(r1) - 7a4: 90 01 00 24 stw r0,36(r1) + 7a0: bf a1 00 24 stmw r29,36(r1) + 7a4: 90 01 00 34 stw r0,52(r1) 7a8: 3f a0 00 00 lis r29,0 7ac: 7c 9e 23 78 mr r30,r4 7b0: 83 e3 00 00 lwz r31,0(r3)
@@ -525,7 +525,7 @@ Disassembly of section .text: 814: 7f e3 fb 78 mr r3,r31 818: 48 00 00 01 bl 818 <grub_mod_init-0x6c0> 81c: 3d 20 00 00 lis r9,0 - 820: 39 61 00 20 addi r11,r1,32 + 820: 39 61 00 30 addi r11,r1,48 824: 80 69 00 00 lwz r3,0(r9) 828: 48 00 00 00 b 828 <grub_mod_init-0x6b0> 82c: 94 21 ff e0 stwu r1,-32(r1)
@@ -555,13 +555,13 @@ Disassembly of section .text: 88c: 39 61 00 20 addi r11,r1,32 890: 80 69 00 00 lwz r3,0(r9) 894: 48 00 00 00 b 894 <grub_mod_init-0x644> - 898: 94 21 ff d0 stwu r1,-48(r1) + 898: 94 21 ff c0 stwu r1,-64(r1) 89c: 7c 6b 1b 78 mr r11,r3 8a0: 7c 08 02 a6 mflr r0 8a4: 7c a6 2b 78 mr r6,r5 8a8: 38 ab 00 08 addi r5,r11,8 - 8ac: bf c1 00 28 stmw r30,40(r1) - 8b0: 90 01 00 34 stw r0,52(r1) + 8ac: bf c1 00 38 stmw r30,56(r1) + 8b0: 90 01 00 44 stw r0,68(r1) 8b4: 3b cb 00 70 addi r30,r11,112 8b8: 7c 80 23 78 mr r0,r4 8bc: 80 63 00 00 lwz r3,0(r3)
@@ -584,7 +584,7 @@ Disassembly of section .text: 900: 7d 64 5b 78 mr r4,r11 904: 7c 05 03 78 mr r5,r0 908: 48 00 00 01 bl 908 <grub_mod_init-0x5d0> - 90c: 39 61 00 30 addi r11,r1,48 + 90c: 39 61 00 40 addi r11,r1,64 910: 48 00 00 00 b 910 <grub_mod_init-0x5c8> 914: 7c 68 1b 78 mr r8,r3 918: 80 63 00 44 lwz r3,68(r3)
@@ -596,10 +596,10 @@ Disassembly of section .text: 930: 81 08 00 14 lwz r8,20(r8) 934: 38 63 01 5c addi r3,r3,348 938: 4b ff ff 60 b 898 <grub_mod_init-0x640> - 93c: 94 21 fe c0 stwu r1,-320(r1) + 93c: 94 21 fe b0 stwu r1,-336(r1) 940: 7c 08 02 a6 mflr r0 - 944: be c1 01 18 stmw r22,280(r1) - 948: 90 01 01 44 stw r0,324(r1) + 944: be c1 01 28 stmw r22,296(r1) + 948: 90 01 01 54 stw r0,340(r1) 94c: 7c 7f 1b 78 mr r31,r3 950: 7c 9a 23 78 mr r26,r4 954: 7c b9 2b 78 mr r25,r5
@@ -715,7 +715,7 @@ Disassembly of section .text: b0c: 2f 83 00 00 cmpwi cr7,r3,0 b10: 41 9e fe b0 beq cr7,9c0 <grub_mod_init-0x518> b14: 38 60 00 01 li r3,1 - b18: 39 61 01 40 addi r11,r1,320 + b18: 39 61 01 50 addi r11,r1,336 b1c: 48 00 00 00 b b1c <grub_mod_init-0x3bc> b20: 94 21 ff d0 stwu r1,-48(r1) b24: 39 20 00 00 li r9,0
@@ -769,10 +769,10 @@ Disassembly of section .text: be4: 39 61 00 30 addi r11,r1,48 be8: 80 7f 00 00 lwz r3,0(r31) bec: 48 00 00 00 b bec <grub_mod_init-0x2ec> - bf0: 94 21 ff f0 stwu r1,-16(r1) + bf0: 94 21 ff e0 stwu r1,-32(r1) bf4: 7c 08 02 a6 mflr r0 - bf8: bf c1 00 08 stmw r30,8(r1) - bfc: 90 01 00 14 stw r0,20(r1) + bf8: bf c1 00 18 stmw r30,24(r1) + bfc: 90 01 00 24 stw r0,36(r1) c00: 7c 7f 1b 78 mr r31,r3 c04: 81 23 00 88 lwz r9,136(r3) c08: 2f 89 00 00 cmpwi cr7,r9,0
@@ -821,7 +821,7 @@ Disassembly of section .text: cb4: 7d 20 fc 2c lwbrx r9,0,r31 cb8: 7f c3 f3 78 mr r3,r30 cbc: 7d 5e 49 ae stbx r10,r30,r9 - cc0: 39 61 00 10 addi r11,r1,16 + cc0: 39 61 00 20 addi r11,r1,32 cc4: 48 00 00 00 b cc4 <grub_mod_init-0x214> cc8: 94 21 ff d0 stwu r1,-48(r1) ccc: 7c 08 02 a6 mflr r0
@@ -878,14 +878,14 @@ Disassembly of section .text: d98: 4e 80 04 21 bctrl d9c: 39 61 00 30 addi r11,r1,48 da0: 48 00 00 00 b da0 <grub_mod_init-0x138> - da4: 94 21 ff d0 stwu r1,-48(r1) + da4: 94 21 ff c0 stwu r1,-64(r1) da8: 39 20 00 00 li r9,0 dac: 7c 08 02 a6 mflr r0 - db0: bf 41 00 18 stmw r26,24(r1) + db0: bf 41 00 28 stmw r26,40(r1) db4: 3f a0 00 00 lis r29,0 db8: 7c 7f 1b 78 mr r31,r3 dbc: 80 7d 00 00 lwz r3,0(r29) - dc0: 90 01 00 34 stw r0,52(r1) + dc0: 90 01 00 44 stw r0,68(r1) dc4: 7c 9a 23 78 mr r26,r4 dc8: 91 21 00 08 stw r9,8(r1) dcc: 48 00 00 01 bl dcc <grub_mod_init-0x10c>
@@ -953,23 +953,23 @@ Disassembly of section .text: ec4: 80 7b 00 00 lwz r3,0(r27) ec8: 48 00 00 01 bl ec8 <grub_mod_init-0x10> ecc: 7f a3 eb 78 mr r3,r29 - ed0: 39 61 00 30 addi r11,r1,48 + ed0: 39 61 00 40 addi r11,r1,64 ed4: 48 00 00 00 b ed4 <grub_mod_init-0x4> 00000ed8 <grub_mod_init>: - ed8: 94 21 ff f0 stwu r1,-16(r1) + ed8: 94 21 ff e0 stwu r1,-32(r1) edc: 3c 80 00 00 lis r4,0 ee0: 7c 08 02 a6 mflr r0 ee4: 38 84 00 00 addi r4,r4,0 - ee8: 93 e1 00 0c stw r31,12(r1) + ee8: 93 e1 00 1c stw r31,28(r1) eec: 7c 7f 1b 78 mr r31,r3 ef0: 3c 60 00 00 lis r3,0 - ef4: 90 01 00 14 stw r0,20(r1) + ef4: 90 01 00 24 stw r0,36(r1) ef8: 38 63 00 00 addi r3,r3,0 efc: 48 00 00 01 bl efc <grub_mod_init+0x24> f00: 3d 20 00 00 lis r9,0 f04: 93 e9 00 00 stw r31,0(r9) - f08: 39 61 00 10 addi r11,r1,16 + f08: 39 61 00 20 addi r11,r1,32 f0c: 48 00 00 00 b f0c <grub_mod_init+0x34> 00000f10 <grub_mod_fini>:
Quoted 261 lines · Andrei Borzenkov
В Sun, 21 Sep 2014 17:58:44 +0400
Andrei Borzenkov <[email protected]> пишет:Quoted 40 lines
В Thu, 28 Aug 2014 16:56:02 -0300
Paulo Flabiano Smorigo <[email protected]> пишет:Quoted 17 lines
From: Paulo Flabiano Smorigo <[email protected]>
Hi,
At the beginning of the year we provide a patchset that enabled GRUB for little-endian PowerPC. Our approach at the time was to build GRUB itself and its tools in 64-bit little-endian. One of the reasons of build in 64-bit is to avoid 32-bit dependencies in the distro and build a system entirely 64-bit.
This patchset was not welcomed at the time because it would bring a high-maintainance-cost, without real gain since it could just be cross-compiled.
After that, Brent Baude, Vladmir (phcoder) and I started to work in a solution that would cross-compile but without 32-bit dependencies. This patchset is the result of this new approach. It's based on the work of Brent Baude, Vladimir (phcoder), and Tomohiro.
Quoted 9 lines
It can be devided in two parts:
1) Skip libgcc dependency just for ppc64el (patch 1 and 2);
2) Check elf endianess and byteswap if necessary (patch 3);The result is GRUB itself in 32-bit BE and its tools in 64-bit LE. This solution satisfies the needs of the distros. I tested it in three different distros, in both endianess and it's fine.
Unfortunately I'm still not able to boot this version on QEMU. I build on openSUSE for three acrhs - ppc, ppc64, ppc64le. First two are OK and boot successfully. Third one does not work - it ends up in exception. I get initial GRUB greeting and that's all.
Same problem I got with Vladimir libgcc patch series.
It could be toolkit issue of course; but still it would need fixing before we can merge it.
Quoted 10 lines
Could you help in debugging this issue? I have near to zero experience with PPC; I can do what you tell me, but not much more.
I run it with
qemu-system-ppc64 -M pseries -cdrom
/tmp/grub2-ppc64le.iso-boot dAttached is screenshot of error.
And here is the difference in generated code in case it helps (one random module as example) ...
tmp/a2 renamed from tmp/a1 +36
-36@@ -1,5 +1,5 @@ -usr.ppc/lib/grub2/powerpc-ieee1275/ext2.mod: file format elf32-powerpc +usr.ppc64le/lib/grub2/powerpc-ieee1275/ext2.mod: file format elf32-powerpc Disassembly of section .text:@@ -18,15 +18,15 @@ Disassembly of section .text: 28: 38 21 00 10 addi r1,r1,16 2c: 7c 08 03 a6 mtlr r0 30: 4e 80 00 20 blr - 34: 94 21 ff a0 stwu r1,-96(r1) + 34: 94 21 ff 90 stwu r1,-112(r1) 38: 38 e3 00 28 addi r7,r3,40 3c: 7d 80 00 26 mfcr r12 40: 39 23 00 14 addi r9,r3,20 44: 7c 08 02 a6 mflr r0 48: 39 43 00 18 addi r10,r3,24 - 4c: bf 61 00 4c stmw r27,76(r1) - 50: 90 01 00 64 stw r0,100(r1) - 54: 91 81 00 48 stw r12,72(r1) + 4c: bf 61 00 5c stmw r27,92(r1) + 50: 90 01 00 74 stw r0,116(r1) + 54: 91 81 00 58 stw r12,88(r1) 58: 3b c4 ff ff addi r30,r4,-1 5c: 7c 7f 1b 78 mr r31,r3 60: 7c bc 2b 78 mr r28,r5@@ -103,10 +103,10 @@ Disassembly of section .text: 17c: 2f 83 00 00 cmpwi cr7,r3,0 180: 41 9e 00 08 beq cr7,188 <grub_mod_init-0xd50> 184: 81 3d 00 00 lwz r9,0(r29) - 188: 81 81 00 48 lwz r12,72(r1) - 18c: 39 61 00 60 addi r11,r1,96 + 188: 81 81 00 58 lwz r12,88(r1) + 18c: 39 61 00 70 addi r11,r1,112 190: 7d 23 4b 78 mr r3,r9 - 194: 7d 80 81 20 mtcrf 8,r12 + 194: 7d 90 81 20 mtocrf 8,r12 198: 48 00 00 00 b 198 <grub_mod_init-0xd40> 19c: 94 21 ff e0 stwu r1,-32(r1) 1a0: 7c 08 02 a6 mflr r0@@ -234,10 +234,10 @@ Disassembly of section .text: 388: 39 61 00 20 addi r11,r1,32 38c: 80 69 00 00 lwz r3,0(r9) 390: 48 00 00 00 b 390 <grub_mod_init-0xb48> - 394: 94 21 ff b0 stwu r1,-80(r1) + 394: 94 21 ff a0 stwu r1,-96(r1) 398: 7c 08 02 a6 mflr r0 - 39c: be 61 00 1c stmw r19,28(r1) - 3a0: 90 01 00 54 stw r0,84(r1) + 39c: be 61 00 2c stmw r19,44(r1) + 3a0: 90 01 00 64 stw r0,100(r1) 3a4: 7c df 33 78 mr r31,r6 3a8: 7c be 2b 78 mr r30,r5 3ac: 83 63 00 00 lwz r27,0(r3)@@ -489,12 +489,12 @@ Disassembly of section .text: 784: 48 00 00 0c b 790 <grub_mod_init-0x748> 788: 7f c3 f3 78 mr r3,r30 78c: 7f e4 fb 78 mr r4,r31 - 790: 39 61 00 50 addi r11,r1,80 + 790: 39 61 00 60 addi r11,r1,96 794: 48 00 00 00 b 794 <grub_mod_init-0x744> - 798: 94 21 ff e0 stwu r1,-32(r1) + 798: 94 21 ff d0 stwu r1,-48(r1) 79c: 7c 08 02 a6 mflr r0 - 7a0: bf a1 00 14 stmw r29,20(r1) - 7a4: 90 01 00 24 stw r0,36(r1) + 7a0: bf a1 00 24 stmw r29,36(r1) + 7a4: 90 01 00 34 stw r0,52(r1) 7a8: 3f a0 00 00 lis r29,0 7ac: 7c 9e 23 78 mr r30,r4 7b0: 83 e3 00 00 lwz r31,0(r3)@@ -525,7 +525,7 @@ Disassembly of section .text: 814: 7f e3 fb 78 mr r3,r31 818: 48 00 00 01 bl 818 <grub_mod_init-0x6c0> 81c: 3d 20 00 00 lis r9,0 - 820: 39 61 00 20 addi r11,r1,32 + 820: 39 61 00 30 addi r11,r1,48 824: 80 69 00 00 lwz r3,0(r9) 828: 48 00 00 00 b 828 <grub_mod_init-0x6b0> 82c: 94 21 ff e0 stwu r1,-32(r1)@@ -555,13 +555,13 @@ Disassembly of section .text: 88c: 39 61 00 20 addi r11,r1,32 890: 80 69 00 00 lwz r3,0(r9) 894: 48 00 00 00 b 894 <grub_mod_init-0x644> - 898: 94 21 ff d0 stwu r1,-48(r1) + 898: 94 21 ff c0 stwu r1,-64(r1) 89c: 7c 6b 1b 78 mr r11,r3 8a0: 7c 08 02 a6 mflr r0 8a4: 7c a6 2b 78 mr r6,r5 8a8: 38 ab 00 08 addi r5,r11,8 - 8ac: bf c1 00 28 stmw r30,40(r1) - 8b0: 90 01 00 34 stw r0,52(r1) + 8ac: bf c1 00 38 stmw r30,56(r1) + 8b0: 90 01 00 44 stw r0,68(r1) 8b4: 3b cb 00 70 addi r30,r11,112 8b8: 7c 80 23 78 mr r0,r4 8bc: 80 63 00 00 lwz r3,0(r3)@@ -584,7 +584,7 @@ Disassembly of section .text: 900: 7d 64 5b 78 mr r4,r11 904: 7c 05 03 78 mr r5,r0 908: 48 00 00 01 bl 908 <grub_mod_init-0x5d0> - 90c: 39 61 00 30 addi r11,r1,48 + 90c: 39 61 00 40 addi r11,r1,64 910: 48 00 00 00 b 910 <grub_mod_init-0x5c8> 914: 7c 68 1b 78 mr r8,r3 918: 80 63 00 44 lwz r3,68(r3)@@ -596,10 +596,10 @@ Disassembly of section .text: 930: 81 08 00 14 lwz r8,20(r8) 934: 38 63 01 5c addi r3,r3,348 938: 4b ff ff 60 b 898 <grub_mod_init-0x640> - 93c: 94 21 fe c0 stwu r1,-320(r1) + 93c: 94 21 fe b0 stwu r1,-336(r1) 940: 7c 08 02 a6 mflr r0 - 944: be c1 01 18 stmw r22,280(r1) - 948: 90 01 01 44 stw r0,324(r1) + 944: be c1 01 28 stmw r22,296(r1) + 948: 90 01 01 54 stw r0,340(r1) 94c: 7c 7f 1b 78 mr r31,r3 950: 7c 9a 23 78 mr r26,r4 954: 7c b9 2b 78 mr r25,r5@@ -715,7 +715,7 @@ Disassembly of section .text: b0c: 2f 83 00 00 cmpwi cr7,r3,0 b10: 41 9e fe b0 beq cr7,9c0 <grub_mod_init-0x518> b14: 38 60 00 01 li r3,1 - b18: 39 61 01 40 addi r11,r1,320 + b18: 39 61 01 50 addi r11,r1,336 b1c: 48 00 00 00 b b1c <grub_mod_init-0x3bc> b20: 94 21 ff d0 stwu r1,-48(r1) b24: 39 20 00 00 li r9,0@@ -769,10 +769,10 @@ Disassembly of section .text: be4: 39 61 00 30 addi r11,r1,48 be8: 80 7f 00 00 lwz r3,0(r31) bec: 48 00 00 00 b bec <grub_mod_init-0x2ec> - bf0: 94 21 ff f0 stwu r1,-16(r1) + bf0: 94 21 ff e0 stwu r1,-32(r1) bf4: 7c 08 02 a6 mflr r0 - bf8: bf c1 00 08 stmw r30,8(r1) - bfc: 90 01 00 14 stw r0,20(r1) + bf8: bf c1 00 18 stmw r30,24(r1) + bfc: 90 01 00 24 stw r0,36(r1) c00: 7c 7f 1b 78 mr r31,r3 c04: 81 23 00 88 lwz r9,136(r3) c08: 2f 89 00 00 cmpwi cr7,r9,0@@ -821,7 +821,7 @@ Disassembly of section .text: cb4: 7d 20 fc 2c lwbrx r9,0,r31 cb8: 7f c3 f3 78 mr r3,r30 cbc: 7d 5e 49 ae stbx r10,r30,r9 - cc0: 39 61 00 10 addi r11,r1,16 + cc0: 39 61 00 20 addi r11,r1,32 cc4: 48 00 00 00 b cc4 <grub_mod_init-0x214> cc8: 94 21 ff d0 stwu r1,-48(r1) ccc: 7c 08 02 a6 mflr r0@@ -878,14 +878,14 @@ Disassembly of section .text: d98: 4e 80 04 21 bctrl d9c: 39 61 00 30 addi r11,r1,48 da0: 48 00 00 00 b da0 <grub_mod_init-0x138> - da4: 94 21 ff d0 stwu r1,-48(r1) + da4: 94 21 ff c0 stwu r1,-64(r1) da8: 39 20 00 00 li r9,0 dac: 7c 08 02 a6 mflr r0 - db0: bf 41 00 18 stmw r26,24(r1) + db0: bf 41 00 28 stmw r26,40(r1) db4: 3f a0 00 00 lis r29,0 db8: 7c 7f 1b 78 mr r31,r3 dbc: 80 7d 00 00 lwz r3,0(r29) - dc0: 90 01 00 34 stw r0,52(r1) + dc0: 90 01 00 44 stw r0,68(r1) dc4: 7c 9a 23 78 mr r26,r4 dc8: 91 21 00 08 stw r9,8(r1) dcc: 48 00 00 01 bl dcc <grub_mod_init-0x10c>@@ -953,23 +953,23 @@ Disassembly of section .text: ec4: 80 7b 00 00 lwz r3,0(r27) ec8: 48 00 00 01 bl ec8 <grub_mod_init-0x10> ecc: 7f a3 eb 78 mr r3,r29 - ed0: 39 61 00 30 addi r11,r1,48 + ed0: 39 61 00 40 addi r11,r1,64 ed4: 48 00 00 00 b ed4 <grub_mod_init-0x4> 00000ed8 <grub_mod_init>: - ed8: 94 21 ff f0 stwu r1,-16(r1) + ed8: 94 21 ff e0 stwu r1,-32(r1) edc: 3c 80 00 00 lis r4,0 ee0: 7c 08 02 a6 mflr r0 ee4: 38 84 00 00 addi r4,r4,0 - ee8: 93 e1 00 0c stw r31,12(r1) + ee8: 93 e1 00 1c stw r31,28(r1) eec: 7c 7f 1b 78 mr r31,r3 ef0: 3c 60 00 00 lis r3,0 - ef4: 90 01 00 14 stw r0,20(r1) + ef4: 90 01 00 24 stw r0,36(r1) ef8: 38 63 00 00 addi r3,r3,0 efc: 48 00 00 01 bl efc <grub_mod_init+0x24> f00: 3d 20 00 00 lis r9,0 f04: 93 e9 00 00 stw r31,0(r9) - f08: 39 61 00 10 addi r11,r1,16 + f08: 39 61 00 20 addi r11,r1,32 f0c: 48 00 00 00 b f0c <grub_mod_init+0x34> 00000f10 <grub_mod_fini>:
Quoted 4 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Hi Andrei,
I find out that VSX was the culprit. Can you please take a look at this patch?
http://lists.gnu.org/archive/html/grub-devel/2014-09/msg00077.html
Signature · 2 lines
Paulo Flabiano Smorigo IBM Linux Technology Center
В Thu, 25 Sep 2014 19:48:04 -0300
Paulo Flabiano Smorigo <[email protected]> пишет:
Quoted 270 lines
Quoted 261 lines · Andrei Borzenkov
В Sun, 21 Sep 2014 17:58:44 +0400
Andrei Borzenkov <[email protected]> пишет:Quoted 40 lines
В Thu, 28 Aug 2014 16:56:02 -0300
Paulo Flabiano Smorigo <[email protected]> пишет:Quoted 17 lines
From: Paulo Flabiano Smorigo <[email protected]>
Hi,
At the beginning of the year we provide a patchset that enabled GRUB for little-endian PowerPC. Our approach at the time was to build GRUB itself and its tools in 64-bit little-endian. One of the reasons of build in 64-bit is to avoid 32-bit dependencies in the distro and build a system entirely 64-bit.
This patchset was not welcomed at the time because it would bring a high-maintainance-cost, without real gain since it could just be cross-compiled.
After that, Brent Baude, Vladmir (phcoder) and I started to work in a solution that would cross-compile but without 32-bit dependencies. This patchset is the result of this new approach. It's based on the work of Brent Baude, Vladimir (phcoder), and Tomohiro.
Quoted 9 lines
It can be devided in two parts:
1) Skip libgcc dependency just for ppc64el (patch 1 and 2);
2) Check elf endianess and byteswap if necessary (patch 3);The result is GRUB itself in 32-bit BE and its tools in 64-bit LE. This solution satisfies the needs of the distros. I tested it in three different distros, in both endianess and it's fine.
Unfortunately I'm still not able to boot this version on QEMU. I build on openSUSE for three acrhs - ppc, ppc64, ppc64le. First two are OK and boot successfully. Third one does not work - it ends up in exception. I get initial GRUB greeting and that's all.
Same problem I got with Vladimir libgcc patch series.
It could be toolkit issue of course; but still it would need fixing before we can merge it.
Quoted 10 lines
Could you help in debugging this issue? I have near to zero experience with PPC; I can do what you tell me, but not much more.
I run it with
qemu-system-ppc64 -M pseries -cdrom
/tmp/grub2-ppc64le.iso-boot dAttached is screenshot of error.
And here is the difference in generated code in case it helps (one random module as example) ...
tmp/a2 renamed from tmp/a1 +36
-36@@ -1,5 +1,5 @@ -usr.ppc/lib/grub2/powerpc-ieee1275/ext2.mod: file format elf32-powerpc +usr.ppc64le/lib/grub2/powerpc-ieee1275/ext2.mod: file format elf32-powerpc Disassembly of section .text:@@ -18,15 +18,15 @@ Disassembly of section .text: 28: 38 21 00 10 addi r1,r1,16 2c: 7c 08 03 a6 mtlr r0 30: 4e 80 00 20 blr - 34: 94 21 ff a0 stwu r1,-96(r1) + 34: 94 21 ff 90 stwu r1,-112(r1) 38: 38 e3 00 28 addi r7,r3,40 3c: 7d 80 00 26 mfcr r12 40: 39 23 00 14 addi r9,r3,20 44: 7c 08 02 a6 mflr r0 48: 39 43 00 18 addi r10,r3,24 - 4c: bf 61 00 4c stmw r27,76(r1) - 50: 90 01 00 64 stw r0,100(r1) - 54: 91 81 00 48 stw r12,72(r1) + 4c: bf 61 00 5c stmw r27,92(r1) + 50: 90 01 00 74 stw r0,116(r1) + 54: 91 81 00 58 stw r12,88(r1) 58: 3b c4 ff ff addi r30,r4,-1 5c: 7c 7f 1b 78 mr r31,r3 60: 7c bc 2b 78 mr r28,r5@@ -103,10 +103,10 @@ Disassembly of section .text: 17c: 2f 83 00 00 cmpwi cr7,r3,0 180: 41 9e 00 08 beq cr7,188 <grub_mod_init-0xd50> 184: 81 3d 00 00 lwz r9,0(r29) - 188: 81 81 00 48 lwz r12,72(r1) - 18c: 39 61 00 60 addi r11,r1,96 + 188: 81 81 00 58 lwz r12,88(r1) + 18c: 39 61 00 70 addi r11,r1,112 190: 7d 23 4b 78 mr r3,r9 - 194: 7d 80 81 20 mtcrf 8,r12 + 194: 7d 90 81 20 mtocrf 8,r12 198: 48 00 00 00 b 198 <grub_mod_init-0xd40> 19c: 94 21 ff e0 stwu r1,-32(r1) 1a0: 7c 08 02 a6 mflr r0@@ -234,10 +234,10 @@ Disassembly of section .text: 388: 39 61 00 20 addi r11,r1,32 38c: 80 69 00 00 lwz r3,0(r9) 390: 48 00 00 00 b 390 <grub_mod_init-0xb48> - 394: 94 21 ff b0 stwu r1,-80(r1) + 394: 94 21 ff a0 stwu r1,-96(r1) 398: 7c 08 02 a6 mflr r0 - 39c: be 61 00 1c stmw r19,28(r1) - 3a0: 90 01 00 54 stw r0,84(r1) + 39c: be 61 00 2c stmw r19,44(r1) + 3a0: 90 01 00 64 stw r0,100(r1) 3a4: 7c df 33 78 mr r31,r6 3a8: 7c be 2b 78 mr r30,r5 3ac: 83 63 00 00 lwz r27,0(r3)@@ -489,12 +489,12 @@ Disassembly of section .text: 784: 48 00 00 0c b 790 <grub_mod_init-0x748> 788: 7f c3 f3 78 mr r3,r30 78c: 7f e4 fb 78 mr r4,r31 - 790: 39 61 00 50 addi r11,r1,80 + 790: 39 61 00 60 addi r11,r1,96 794: 48 00 00 00 b 794 <grub_mod_init-0x744> - 798: 94 21 ff e0 stwu r1,-32(r1) + 798: 94 21 ff d0 stwu r1,-48(r1) 79c: 7c 08 02 a6 mflr r0 - 7a0: bf a1 00 14 stmw r29,20(r1) - 7a4: 90 01 00 24 stw r0,36(r1) + 7a0: bf a1 00 24 stmw r29,36(r1) + 7a4: 90 01 00 34 stw r0,52(r1) 7a8: 3f a0 00 00 lis r29,0 7ac: 7c 9e 23 78 mr r30,r4 7b0: 83 e3 00 00 lwz r31,0(r3)@@ -525,7 +525,7 @@ Disassembly of section .text: 814: 7f e3 fb 78 mr r3,r31 818: 48 00 00 01 bl 818 <grub_mod_init-0x6c0> 81c: 3d 20 00 00 lis r9,0 - 820: 39 61 00 20 addi r11,r1,32 + 820: 39 61 00 30 addi r11,r1,48 824: 80 69 00 00 lwz r3,0(r9) 828: 48 00 00 00 b 828 <grub_mod_init-0x6b0> 82c: 94 21 ff e0 stwu r1,-32(r1)@@ -555,13 +555,13 @@ Disassembly of section .text: 88c: 39 61 00 20 addi r11,r1,32 890: 80 69 00 00 lwz r3,0(r9) 894: 48 00 00 00 b 894 <grub_mod_init-0x644> - 898: 94 21 ff d0 stwu r1,-48(r1) + 898: 94 21 ff c0 stwu r1,-64(r1) 89c: 7c 6b 1b 78 mr r11,r3 8a0: 7c 08 02 a6 mflr r0 8a4: 7c a6 2b 78 mr r6,r5 8a8: 38 ab 00 08 addi r5,r11,8 - 8ac: bf c1 00 28 stmw r30,40(r1) - 8b0: 90 01 00 34 stw r0,52(r1) + 8ac: bf c1 00 38 stmw r30,56(r1) + 8b0: 90 01 00 44 stw r0,68(r1) 8b4: 3b cb 00 70 addi r30,r11,112 8b8: 7c 80 23 78 mr r0,r4 8bc: 80 63 00 00 lwz r3,0(r3)@@ -584,7 +584,7 @@ Disassembly of section .text: 900: 7d 64 5b 78 mr r4,r11 904: 7c 05 03 78 mr r5,r0 908: 48 00 00 01 bl 908 <grub_mod_init-0x5d0> - 90c: 39 61 00 30 addi r11,r1,48 + 90c: 39 61 00 40 addi r11,r1,64 910: 48 00 00 00 b 910 <grub_mod_init-0x5c8> 914: 7c 68 1b 78 mr r8,r3 918: 80 63 00 44 lwz r3,68(r3)@@ -596,10 +596,10 @@ Disassembly of section .text: 930: 81 08 00 14 lwz r8,20(r8) 934: 38 63 01 5c addi r3,r3,348 938: 4b ff ff 60 b 898 <grub_mod_init-0x640> - 93c: 94 21 fe c0 stwu r1,-320(r1) + 93c: 94 21 fe b0 stwu r1,-336(r1) 940: 7c 08 02 a6 mflr r0 - 944: be c1 01 18 stmw r22,280(r1) - 948: 90 01 01 44 stw r0,324(r1) + 944: be c1 01 28 stmw r22,296(r1) + 948: 90 01 01 54 stw r0,340(r1) 94c: 7c 7f 1b 78 mr r31,r3 950: 7c 9a 23 78 mr r26,r4 954: 7c b9 2b 78 mr r25,r5@@ -715,7 +715,7 @@ Disassembly of section .text: b0c: 2f 83 00 00 cmpwi cr7,r3,0 b10: 41 9e fe b0 beq cr7,9c0 <grub_mod_init-0x518> b14: 38 60 00 01 li r3,1 - b18: 39 61 01 40 addi r11,r1,320 + b18: 39 61 01 50 addi r11,r1,336 b1c: 48 00 00 00 b b1c <grub_mod_init-0x3bc> b20: 94 21 ff d0 stwu r1,-48(r1) b24: 39 20 00 00 li r9,0@@ -769,10 +769,10 @@ Disassembly of section .text: be4: 39 61 00 30 addi r11,r1,48 be8: 80 7f 00 00 lwz r3,0(r31) bec: 48 00 00 00 b bec <grub_mod_init-0x2ec> - bf0: 94 21 ff f0 stwu r1,-16(r1) + bf0: 94 21 ff e0 stwu r1,-32(r1) bf4: 7c 08 02 a6 mflr r0 - bf8: bf c1 00 08 stmw r30,8(r1) - bfc: 90 01 00 14 stw r0,20(r1) + bf8: bf c1 00 18 stmw r30,24(r1) + bfc: 90 01 00 24 stw r0,36(r1) c00: 7c 7f 1b 78 mr r31,r3 c04: 81 23 00 88 lwz r9,136(r3) c08: 2f 89 00 00 cmpwi cr7,r9,0@@ -821,7 +821,7 @@ Disassembly of section .text: cb4: 7d 20 fc 2c lwbrx r9,0,r31 cb8: 7f c3 f3 78 mr r3,r30 cbc: 7d 5e 49 ae stbx r10,r30,r9 - cc0: 39 61 00 10 addi r11,r1,16 + cc0: 39 61 00 20 addi r11,r1,32 cc4: 48 00 00 00 b cc4 <grub_mod_init-0x214> cc8: 94 21 ff d0 stwu r1,-48(r1) ccc: 7c 08 02 a6 mflr r0@@ -878,14 +878,14 @@ Disassembly of section .text: d98: 4e 80 04 21 bctrl d9c: 39 61 00 30 addi r11,r1,48 da0: 48 00 00 00 b da0 <grub_mod_init-0x138> - da4: 94 21 ff d0 stwu r1,-48(r1) + da4: 94 21 ff c0 stwu r1,-64(r1) da8: 39 20 00 00 li r9,0 dac: 7c 08 02 a6 mflr r0 - db0: bf 41 00 18 stmw r26,24(r1) + db0: bf 41 00 28 stmw r26,40(r1) db4: 3f a0 00 00 lis r29,0 db8: 7c 7f 1b 78 mr r31,r3 dbc: 80 7d 00 00 lwz r3,0(r29) - dc0: 90 01 00 34 stw r0,52(r1) + dc0: 90 01 00 44 stw r0,68(r1) dc4: 7c 9a 23 78 mr r26,r4 dc8: 91 21 00 08 stw r9,8(r1) dcc: 48 00 00 01 bl dcc <grub_mod_init-0x10c>@@ -953,23 +953,23 @@ Disassembly of section .text: ec4: 80 7b 00 00 lwz r3,0(r27) ec8: 48 00 00 01 bl ec8 <grub_mod_init-0x10> ecc: 7f a3 eb 78 mr r3,r29 - ed0: 39 61 00 30 addi r11,r1,48 + ed0: 39 61 00 40 addi r11,r1,64 ed4: 48 00 00 00 b ed4 <grub_mod_init-0x4> 00000ed8 <grub_mod_init>: - ed8: 94 21 ff f0 stwu r1,-16(r1) + ed8: 94 21 ff e0 stwu r1,-32(r1) edc: 3c 80 00 00 lis r4,0 ee0: 7c 08 02 a6 mflr r0 ee4: 38 84 00 00 addi r4,r4,0 - ee8: 93 e1 00 0c stw r31,12(r1) + ee8: 93 e1 00 1c stw r31,28(r1) eec: 7c 7f 1b 78 mr r31,r3 ef0: 3c 60 00 00 lis r3,0 - ef4: 90 01 00 14 stw r0,20(r1) + ef4: 90 01 00 24 stw r0,36(r1) ef8: 38 63 00 00 addi r3,r3,0 efc: 48 00 00 01 bl efc <grub_mod_init+0x24> f00: 3d 20 00 00 lis r9,0 f04: 93 e9 00 00 stw r31,0(r9) - f08: 39 61 00 10 addi r11,r1,16 + f08: 39 61 00 20 addi r11,r1,32 f0c: 48 00 00 00 b f0c <grub_mod_init+0x34> 00000f10 <grub_mod_fini>:Quoted 4 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-develHi Andrei,
Quoted 5 lines
I find out that VSX was the culprit. Can you please take a look at this patch?
http://lists.gnu.org/archive/html/grub-devel/2014-09/msg00077.html
With this patch it works. I'm really surprised - the same sources built on different platform (ppc BE) did work without problems. I do not understand how this can be possible if the problem was in specific CPU mode. It should have been the same in both cases ...
Quoted 281 lines · Andrei Borzenkov
В Thu, 25 Sep 2014 19:48:04 -0300
Paulo Flabiano Smorigo <[email protected]> пишет:Quoted 270 lines
Quoted 261 lines · Andrei Borzenkov
В Sun, 21 Sep 2014 17:58:44 +0400
Andrei Borzenkov <[email protected]> пишет:Quoted 40 lines
В Thu, 28 Aug 2014 16:56:02 -0300
Paulo Flabiano Smorigo <[email protected]> пишет:Quoted 17 lines
From: Paulo Flabiano Smorigo <[email protected]>
Hi,
At the beginning of the year we provide a patchset that enabled GRUB for little-endian PowerPC. Our approach at the time was to build GRUB itself and its tools in 64-bit little-endian. One of the reasons of build in 64-bit is to avoid 32-bit dependencies in the distro and build a system entirely 64-bit.
This patchset was not welcomed at the time because it would bring a high-maintainance-cost, without real gain since it could just be cross-compiled.
After that, Brent Baude, Vladmir (phcoder) and I started to work in a solution that would cross-compile but without 32-bit dependencies. This patchset is the result of this new approach. It's based on the work of Brent Baude, Vladimir (phcoder), and Tomohiro.
Quoted 9 lines
It can be devided in two parts:
1) Skip libgcc dependency just for ppc64el (patch 1 and 2);
2) Check elf endianess and byteswap if necessary (patch 3);The result is GRUB itself in 32-bit BE and its tools in 64-bit LE. This solution satisfies the needs of the distros. I tested it in three different distros, in both endianess and it's fine.
Unfortunately I'm still not able to boot this version on QEMU. I build on openSUSE for three acrhs - ppc, ppc64, ppc64le. First two are OK and boot successfully. Third one does not work - it ends up in exception. I get initial GRUB greeting and that's all.
Same problem I got with Vladimir libgcc patch series.
It could be toolkit issue of course; but still it would need fixing before we can merge it.
Quoted 10 lines
Could you help in debugging this issue? I have near to zero experience with PPC; I can do what you tell me, but not much more.
I run it with
qemu-system-ppc64 -M pseries -cdrom
/tmp/grub2-ppc64le.iso-boot dAttached is screenshot of error.
And here is the difference in generated code in case it helps (one random module as example) ...
tmp/a2 renamed from tmp/a1 +36
-36@@ -1,5 +1,5 @@ -usr.ppc/lib/grub2/powerpc-ieee1275/ext2.mod: file format elf32-powerpc +usr.ppc64le/lib/grub2/powerpc-ieee1275/ext2.mod: file format elf32-powerpc Disassembly of section .text:@@ -18,15 +18,15 @@ Disassembly of section .text: 28: 38 21 00 10 addi r1,r1,16 2c: 7c 08 03 a6 mtlr r0 30: 4e 80 00 20 blr - 34: 94 21 ff a0 stwu r1,-96(r1) + 34: 94 21 ff 90 stwu r1,-112(r1) 38: 38 e3 00 28 addi r7,r3,40 3c: 7d 80 00 26 mfcr r12 40: 39 23 00 14 addi r9,r3,20 44: 7c 08 02 a6 mflr r0 48: 39 43 00 18 addi r10,r3,24 - 4c: bf 61 00 4c stmw r27,76(r1) - 50: 90 01 00 64 stw r0,100(r1) - 54: 91 81 00 48 stw r12,72(r1) + 4c: bf 61 00 5c stmw r27,92(r1) + 50: 90 01 00 74 stw r0,116(r1) + 54: 91 81 00 58 stw r12,88(r1) 58: 3b c4 ff ff addi r30,r4,-1 5c: 7c 7f 1b 78 mr r31,r3 60: 7c bc 2b 78 mr r28,r5@@ -103,10 +103,10 @@ Disassembly of section .text: 17c: 2f 83 00 00 cmpwi cr7,r3,0 180: 41 9e 00 08 beq cr7,188 <grub_mod_init-0xd50> 184: 81 3d 00 00 lwz r9,0(r29) - 188: 81 81 00 48 lwz r12,72(r1) - 18c: 39 61 00 60 addi r11,r1,96 + 188: 81 81 00 58 lwz r12,88(r1) + 18c: 39 61 00 70 addi r11,r1,112 190: 7d 23 4b 78 mr r3,r9 - 194: 7d 80 81 20 mtcrf 8,r12 + 194: 7d 90 81 20 mtocrf 8,r12 198: 48 00 00 00 b 198 <grub_mod_init-0xd40> 19c: 94 21 ff e0 stwu r1,-32(r1) 1a0: 7c 08 02 a6 mflr r0@@ -234,10 +234,10 @@ Disassembly of section .text: 388: 39 61 00 20 addi r11,r1,32 38c: 80 69 00 00 lwz r3,0(r9) 390: 48 00 00 00 b 390 <grub_mod_init-0xb48> - 394: 94 21 ff b0 stwu r1,-80(r1) + 394: 94 21 ff a0 stwu r1,-96(r1) 398: 7c 08 02 a6 mflr r0 - 39c: be 61 00 1c stmw r19,28(r1) - 3a0: 90 01 00 54 stw r0,84(r1) + 39c: be 61 00 2c stmw r19,44(r1) + 3a0: 90 01 00 64 stw r0,100(r1) 3a4: 7c df 33 78 mr r31,r6 3a8: 7c be 2b 78 mr r30,r5 3ac: 83 63 00 00 lwz r27,0(r3)@@ -489,12 +489,12 @@ Disassembly of section .text: 784: 48 00 00 0c b 790 <grub_mod_init-0x748> 788: 7f c3 f3 78 mr r3,r30 78c: 7f e4 fb 78 mr r4,r31 - 790: 39 61 00 50 addi r11,r1,80 + 790: 39 61 00 60 addi r11,r1,96 794: 48 00 00 00 b 794 <grub_mod_init-0x744> - 798: 94 21 ff e0 stwu r1,-32(r1) + 798: 94 21 ff d0 stwu r1,-48(r1) 79c: 7c 08 02 a6 mflr r0 - 7a0: bf a1 00 14 stmw r29,20(r1) - 7a4: 90 01 00 24 stw r0,36(r1) + 7a0: bf a1 00 24 stmw r29,36(r1) + 7a4: 90 01 00 34 stw r0,52(r1) 7a8: 3f a0 00 00 lis r29,0 7ac: 7c 9e 23 78 mr r30,r4 7b0: 83 e3 00 00 lwz r31,0(r3)@@ -525,7 +525,7 @@ Disassembly of section .text: 814: 7f e3 fb 78 mr r3,r31 818: 48 00 00 01 bl 818 <grub_mod_init-0x6c0> 81c: 3d 20 00 00 lis r9,0 - 820: 39 61 00 20 addi r11,r1,32 + 820: 39 61 00 30 addi r11,r1,48 824: 80 69 00 00 lwz r3,0(r9) 828: 48 00 00 00 b 828 <grub_mod_init-0x6b0> 82c: 94 21 ff e0 stwu r1,-32(r1)@@ -555,13 +555,13 @@ Disassembly of section .text: 88c: 39 61 00 20 addi r11,r1,32 890: 80 69 00 00 lwz r3,0(r9) 894: 48 00 00 00 b 894 <grub_mod_init-0x644> - 898: 94 21 ff d0 stwu r1,-48(r1) + 898: 94 21 ff c0 stwu r1,-64(r1) 89c: 7c 6b 1b 78 mr r11,r3 8a0: 7c 08 02 a6 mflr r0 8a4: 7c a6 2b 78 mr r6,r5 8a8: 38 ab 00 08 addi r5,r11,8 - 8ac: bf c1 00 28 stmw r30,40(r1) - 8b0: 90 01 00 34 stw r0,52(r1) + 8ac: bf c1 00 38 stmw r30,56(r1) + 8b0: 90 01 00 44 stw r0,68(r1) 8b4: 3b cb 00 70 addi r30,r11,112 8b8: 7c 80 23 78 mr r0,r4 8bc: 80 63 00 00 lwz r3,0(r3)@@ -584,7 +584,7 @@ Disassembly of section .text: 900: 7d 64 5b 78 mr r4,r11 904: 7c 05 03 78 mr r5,r0 908: 48 00 00 01 bl 908 <grub_mod_init-0x5d0> - 90c: 39 61 00 30 addi r11,r1,48 + 90c: 39 61 00 40 addi r11,r1,64 910: 48 00 00 00 b 910 <grub_mod_init-0x5c8> 914: 7c 68 1b 78 mr r8,r3 918: 80 63 00 44 lwz r3,68(r3)@@ -596,10 +596,10 @@ Disassembly of section .text: 930: 81 08 00 14 lwz r8,20(r8) 934: 38 63 01 5c addi r3,r3,348 938: 4b ff ff 60 b 898 <grub_mod_init-0x640> - 93c: 94 21 fe c0 stwu r1,-320(r1) + 93c: 94 21 fe b0 stwu r1,-336(r1) 940: 7c 08 02 a6 mflr r0 - 944: be c1 01 18 stmw r22,280(r1) - 948: 90 01 01 44 stw r0,324(r1) + 944: be c1 01 28 stmw r22,296(r1) + 948: 90 01 01 54 stw r0,340(r1) 94c: 7c 7f 1b 78 mr r31,r3 950: 7c 9a 23 78 mr r26,r4 954: 7c b9 2b 78 mr r25,r5@@ -715,7 +715,7 @@ Disassembly of section .text: b0c: 2f 83 00 00 cmpwi cr7,r3,0 b10: 41 9e fe b0 beq cr7,9c0 <grub_mod_init-0x518> b14: 38 60 00 01 li r3,1 - b18: 39 61 01 40 addi r11,r1,320 + b18: 39 61 01 50 addi r11,r1,336 b1c: 48 00 00 00 b b1c <grub_mod_init-0x3bc> b20: 94 21 ff d0 stwu r1,-48(r1) b24: 39 20 00 00 li r9,0@@ -769,10 +769,10 @@ Disassembly of section .text: be4: 39 61 00 30 addi r11,r1,48 be8: 80 7f 00 00 lwz r3,0(r31) bec: 48 00 00 00 b bec <grub_mod_init-0x2ec> - bf0: 94 21 ff f0 stwu r1,-16(r1) + bf0: 94 21 ff e0 stwu r1,-32(r1) bf4: 7c 08 02 a6 mflr r0 - bf8: bf c1 00 08 stmw r30,8(r1) - bfc: 90 01 00 14 stw r0,20(r1) + bf8: bf c1 00 18 stmw r30,24(r1) + bfc: 90 01 00 24 stw r0,36(r1) c00: 7c 7f 1b 78 mr r31,r3 c04: 81 23 00 88 lwz r9,136(r3) c08: 2f 89 00 00 cmpwi cr7,r9,0@@ -821,7 +821,7 @@ Disassembly of section .text: cb4: 7d 20 fc 2c lwbrx r9,0,r31 cb8: 7f c3 f3 78 mr r3,r30 cbc: 7d 5e 49 ae stbx r10,r30,r9 - cc0: 39 61 00 10 addi r11,r1,16 + cc0: 39 61 00 20 addi r11,r1,32 cc4: 48 00 00 00 b cc4 <grub_mod_init-0x214> cc8: 94 21 ff d0 stwu r1,-48(r1) ccc: 7c 08 02 a6 mflr r0@@ -878,14 +878,14 @@ Disassembly of section .text: d98: 4e 80 04 21 bctrl d9c: 39 61 00 30 addi r11,r1,48 da0: 48 00 00 00 b da0 <grub_mod_init-0x138> - da4: 94 21 ff d0 stwu r1,-48(r1) + da4: 94 21 ff c0 stwu r1,-64(r1) da8: 39 20 00 00 li r9,0 dac: 7c 08 02 a6 mflr r0 - db0: bf 41 00 18 stmw r26,24(r1) + db0: bf 41 00 28 stmw r26,40(r1) db4: 3f a0 00 00 lis r29,0 db8: 7c 7f 1b 78 mr r31,r3 dbc: 80 7d 00 00 lwz r3,0(r29) - dc0: 90 01 00 34 stw r0,52(r1) + dc0: 90 01 00 44 stw r0,68(r1) dc4: 7c 9a 23 78 mr r26,r4 dc8: 91 21 00 08 stw r9,8(r1) dcc: 48 00 00 01 bl dcc <grub_mod_init-0x10c>@@ -953,23 +953,23 @@ Disassembly of section .text: ec4: 80 7b 00 00 lwz r3,0(r27) ec8: 48 00 00 01 bl ec8 <grub_mod_init-0x10> ecc: 7f a3 eb 78 mr r3,r29 - ed0: 39 61 00 30 addi r11,r1,48 + ed0: 39 61 00 40 addi r11,r1,64 ed4: 48 00 00 00 b ed4 <grub_mod_init-0x4> 00000ed8 <grub_mod_init>: - ed8: 94 21 ff f0 stwu r1,-16(r1) + ed8: 94 21 ff e0 stwu r1,-32(r1) edc: 3c 80 00 00 lis r4,0 ee0: 7c 08 02 a6 mflr r0 ee4: 38 84 00 00 addi r4,r4,0 - ee8: 93 e1 00 0c stw r31,12(r1) + ee8: 93 e1 00 1c stw r31,28(r1) eec: 7c 7f 1b 78 mr r31,r3 ef0: 3c 60 00 00 lis r3,0 - ef4: 90 01 00 14 stw r0,20(r1) + ef4: 90 01 00 24 stw r0,36(r1) ef8: 38 63 00 00 addi r3,r3,0 efc: 48 00 00 01 bl efc <grub_mod_init+0x24> f00: 3d 20 00 00 lis r9,0 f04: 93 e9 00 00 stw r31,0(r9) - f08: 39 61 00 10 addi r11,r1,16 + f08: 39 61 00 20 addi r11,r1,32 f0c: 48 00 00 00 b f0c <grub_mod_init+0x34> 00000f10 <grub_mod_fini>:Quoted 4 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-develHi Andrei,
Quoted 5 lines
I find out that VSX was the culprit. Can you please take a look at this patch?
http://lists.gnu.org/archive/html/grub-devel/2014-09/msg00077.html
Quoted 4 lines
With this patch it works. I'm really surprised - the same sources built on different platform (ppc BE) did work without problems. I do not understand how this can be possible if the problem was in specific CPU mode. It should have been the same in both cases ...
Check "gcc -v" for --with-cpu=power7. That flag enables VSX and Altivec.
Quoted 5 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Paulo Flabiano Smorigo IBM Linux Technology Center
В Thu, 28 Aug 2014 16:56:02 -0300
Paulo Flabiano Smorigo <[email protected]> пишет:
Quoted 12 lines
From: Paulo Flabiano Smorigo <[email protected]>
Hi,
At the beginning of the year we provide a patchset that enabled GRUB for little-endian PowerPC. Our approach at the time was to build GRUB itself and its tools in 64-bit little-endian. One of the reasons of build in 64-bit is to avoid 32-bit dependencies in the distro and build a system entirely 64-bit.
This patchset was not welcomed at the time because it would bring a high-maintainance-cost, without real gain since it could just be cross-compiled.
Quoted 8 lines
After that, Brent Baude, Vladmir (phcoder) and I started to work in a solution that would cross-compile but without 32-bit dependencies. This patchset is the result of this new approach. It's based on the work of Brent Baude, Vladimir (phcoder), and Tomohiro.
It can be devided in two parts:
1) Skip libgcc dependency just for ppc64el (patch 1 and 2);
This is now default for all platforms
Quoted 2 lines
2) Check elf endianess and byteswap if necessary (patch 3);
That's still pending.
Quoted 8 lines
The result is GRUB itself in 32-bit BE and its tools in 64-bit LE. This solution satisfies the needs of the distros. I tested it in three different distros, in both endianess and it's fine.
If thoses patches were accepted we will have an official solution. Nowadays, distros are taking diffrent approachs. Some of then are using the original solutions and others are using cross-compiler.
Could you resend missing bits rebased to current head?
Quoted 22 lines · Andrei Borzenkov
В Thu, 28 Aug 2014 16:56:02 -0300
Paulo Flabiano Smorigo <[email protected]> пишет:Quoted 19 lines
From: Paulo Flabiano Smorigo <[email protected]>
Hi,
At the beginning of the year we provide a patchset that enabled GRUB for little-endian PowerPC. Our approach at the time was to build GRUB itself and its tools in 64-bit little-endian. One of the reasons of build in 64-bit is to avoid 32-bit dependencies in the distro and build a system entirely 64-bit.
This patchset was not welcomed at the time because it would bring a high-maintainance-cost, without real gain since it could just be cross-compiled.
After that, Brent Baude, Vladmir (phcoder) and I started to work in a solution that would cross-compile but without 32-bit dependencies. This patchset is the result of this new approach. It's based on the work of Brent Baude, Vladimir (phcoder), and Tomohiro.
It can be devided in two parts:
Quoted 8 lines
Quoted 1 line
1) Skip libgcc dependency just for ppc64el (patch 1 and 2);
This is now default for all platforms
Quoted 2 lines
2) Check elf endianess and byteswap if necessary (patch 3);
That's still pending.
Yes, I'm aware of that. :)
Quoted 5 lines
Quoted 5 lines
The result is GRUB itself in 32-bit BE and its tools in 64-bit LE. This solution satisfies the needs of the distros. I tested it in three different distros, in both endianess and it's fine.
Quoted 7 lines
Quoted 4 lines
If thoses patches were accepted we will have an official solution. Nowadays, distros are taking diffrent approachs. Some of then are using the original solutions and others are using cross-compiler.
Could you resend missing bits rebased to current head?
Sure thing. I'll review it once more and send it to the ML later this week.
Signature · 2 lines
Paulo Flabiano Smorigo IBM Linux Technology Center