Add remaining parts for ppc64le environment
cover Add remaining parts for ppc64le environment
It's almost the same as the one that I sent in the beginning of the year. The only difference is that the I remove a flag from the first patch.
Paulo Flabiano Smorigo (2):
Add powerpc little-endian (ppc64le) flags
Suport for bi-endianess in elf file
configure.ac | 8 ++++++ grub-core/kern/elf.c | 60 +++++++++++++++++++++++++++++++++++++++-- grub-core/kern/elfXX.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 139 insertions(+), 2 deletions(-)
Signature · 1 line
2.1.0
PATCH 1/2 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 | 8 ++++++++ 1 file changed, 8 insertions(+)
configure.ac +8 -0
@@ -116,6 +116,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 ;;
@@ -138,6 +139,7 @@ case "$target_cpu"-"$platform" in x86_64-none) ;; 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.
@@ -601,6 +603,12 @@ if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then TARGET_CFLAGS="$TARGET_CFLAGS -march=i386" fi +if test x$target_cpu = xpowerpc; then + 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
2.1.0
PATCH 2/2 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
2.1.0
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
In reply to Paulo Flabiano SmorigoWhich compilers support these flags? I'm concerned of breaking old compilers
Quoted 52 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 | 8 ++++++++ 1 file changed, 8 insertions(+)configure.ac +2
-0@@ -116,6 +116,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 ;;@@ -138,6 +139,7 @@ case "$target_cpu"-"$platform" in x86_64-none) ;; 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.@@ -601,6 +603,12 @@ if test "x$target_cpu" = xi386 && test "x$platform"!= xemu; then
TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
ficonfigure.ac +6
-1+if test x$target_cpu = xpowerpc; then + 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" --2.1.0
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
Quoted 2 lines · Vladimir 'phcoder' Serbinenko
Which compilers support these flags? I'm concerned of breaking old compilers
-static and -mbig-endian are listed in gcc 2.95.3 documentation for PPC.
Quoted 61 lines
Quoted 48 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 | 8 ++++++++ 1 file changed, 8 insertions(+)configure.ac +2
-0@@ -116,6 +116,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 ;;@@ -138,6 +139,7 @@ case "$target_cpu"-"$platform" in x86_64-none) ;; 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.@@ -601,6 +603,12 @@ if test "x$target_cpu" = xi386 && test "x$platform"!= xemu; then
TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
ficonfigure.ac +6
-1+if test x$target_cpu = xpowerpc; then + 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" --2.1.0
Quoted 4 lines
_______________________________________________
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
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
What about clang?
Quoted 75 lines · Andrei Borzenkov
Quoted 1 line · Vladimir 'phcoder' Serbinenko
Which compilers support these flags? I'm concerned of breaking old
compilers
Quoted 1 line
-static and -mbig-endian are listed in gcc 2.95.3 documentation for PPC.
Quoted 50 lines
Quoted 48 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 | 8 ++++++++ 1 file changed, 8 insertions(+)configure.ac +2
-0@@ -116,6 +116,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 ;;@@ -138,6 +139,7 @@ case "$target_cpu"-"$platform" in x86_64-none) ;; 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.@@ -601,6 +603,12 @@ if test "x$target_cpu" = xi386 && test "x$platform"!= xemu; then
TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
ficonfigure.ac +6
-1+if test x$target_cpu = xpowerpc; then + 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" --2.1.0
Quoted 11 lines
Quoted 4 lines
_______________________________________________
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_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
In reply to Andrei BorzenkovQuoted 6 lines · Andrei Borzenkov
Quoted 2 lines · Vladimir 'phcoder' Serbinenko
Which compilers support these flags? I'm concerned of breaking old compilers
-static and -mbig-endian are listed in gcc 2.95.3 documentation for PPC.
I asked some toolchain folks and this flag is really old. IIUC even before GCC 2.95, which was released at March 16, 2001.
Quoted 63 lines
Quoted 62 lines
Quoted 48 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 | 8 ++++++++ 1 file changed, 8 insertions(+)configure.ac +2
-0@@ -116,6 +116,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 ;;@@ -138,6 +139,7 @@ case "$target_cpu"-"$platform" in x86_64-none) ;; 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.@@ -601,6 +603,12 @@ if test "x$target_cpu" = xi386 && test "x$platform"!= xemu; then
TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"fi
configure.ac +6
-1+if test x$target_cpu = xpowerpc; then + 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" --2.1.0
Quoted 4 lines
_______________________________________________
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
Signature · 2 lines
Paulo Flabiano Smorigo IBM Linux Technology Center
Re: [PATCH 2/2] Suport for bi-endianess in elf file
In reply to Paulo Flabiano SmorigoDid you intentionally ignore my comments to previous version?
Отправлено с iPhone
Quoted 204 lines
30 июня 2015 г., в 15:56, Paulo Flabiano Smorigo <[email protected]> написал(а):
*
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 +5
-0@@ -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_tgrub_elf_check_header(grub_elf_telf)grub-core/kern/elf.c +40
-2@@ -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 */grub-core/kern/elf.c +13
-0@@ -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@@ -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; + +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); + 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) + { + 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); + } + } +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_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 ; +}Signature · 7 lines
2.1.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
In reply to Vladimir 'phcoder' SerbinenkoQuoted 1 line · Vladimir 'phcoder' Serbinenko
What about clang?
Not good news about clang support. This is what the toolchain team said about it:
The -mbig-endian option was added around April 10th, 2014. Unfortunately, those who implemented it only implemented it for ARM and one other architecture.
The option is currently accepted on Power systems, but does not have any affect on the code generation for Power.
So, what can we do here? Maybe add a constrain in the configure file saying that it's not possible to build GRUB in a LE environment using clang.
Quoted 90 lines
Le 30 juin 2015 16:30, "Andrei Borzenkov" <[email protected] <mailto:[email protected]>> a écrit :
On Tue, Jun 30, 2015 at 5:03 PM, Vladimir 'phcoder' Serbinenko <[email protected] <mailto:[email protected]>> wrote: > Which compilers support these flags? I'm concerned of breaking old compilers > -static and -mbig-endian are listed in gcc 2.95.3 documentation for PPC. > Le 30 juin 2015 14:57, "Paulo Flabiano Smorigo" > <[email protected] <mailto:[email protected]>> a écrit : >> >> libgcc dependency was removed *just* for this target because >> the distros that use ppc64el doesn't have 32-bit support on it. >> >> * configure.ac <http://configure.ac>: Add targets for powerpc64el and skip libgcc. >> * Makefile.am: Likewise. >> --- >> configure.ac <http://configure.ac> | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/configure.ac <http://configure.ac> b/configure.ac <http://configure.ac> >> index fd8a62e..0a79fad 100644 >> --- a/configure.ac <http://configure.ac> >> +++ b/configure.ac <http://configure.ac> >> @@ -116,6 +116,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 ;; >> @@ -138,6 +139,7 @@ case "$target_cpu"-"$platform" in >> x86_64-none) ;; >> 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. >> @@ -601,6 +603,12 @@ if test "x$target_cpu" = xi386 && test "x$platform" >> != xemu; then >> TARGET_CFLAGS="$TARGET_CFLAGS -march=i386" >> fi >> >> +if test x$target_cpu = xpowerpc; then >> + 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" >> -- >> 2.1.0 >> >> >> _______________________________________________ >> Grub-devel mailing list >> [email protected] <mailto:[email protected]> >> https://lists.gnu.org/mailman/listinfo/grub-devel > > > _______________________________________________ > Grub-devel mailing list > [email protected] <mailto:[email protected]> > https://lists.gnu.org/mailman/listinfo/grub-devel > _______________________________________________ Grub-devel mailing list [email protected] <mailto:[email protected]> https://lists.gnu.org/mailman/listinfo/grub-devel_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Paulo Flabiano Smorigo IBM Linux Technology Center
Re: [PATCH 2/2] Suport for bi-endianess in elf file
In reply to Andrei BorzenkovQuoted 1 line · Andrei Borzenkov
Did you intentionally ignore my comments to previous version?
OH no, sorry, I will take a look.
Quoted 213 lines
Отправлено с iPhone
Quoted 200 lines
30 июня 2015 г., в 15:56, Paulo Flabiano Smorigo <[email protected]> написал(а):
*
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 +5
-0@@ -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_tgrub_elf_check_header(grub_elf_telf)grub-core/kern/elf.c +40
-2@@ -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 */grub-core/kern/elf.c +13
-0@@ -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
-1@@ -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; + +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); + 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) + { + 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); + } + } +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_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 ; +} --2.1.0
Quoted 4 lines
_______________________________________________
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
Signature · 2 lines
Paulo Flabiano Smorigo IBM Linux Technology Center
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
In reply to Paulo Flabiano SmorigoВ Tue, 30 Jun 2015 15:05:46 -0300
Paulo Flabiano Smorigo <[email protected]> пишет:
Quoted 10 lines · Vladimir 'phcoder' Serbinenko
Quoted 1 line
What about clang?
Not good news about clang support. This is what the toolchain team said about it:
The -mbig-endian option was added around April 10th, 2014. Unfortunately, those who implemented it only implemented it for ARM and one other architecture.
Quoted 6 lines
The option is currently accepted on Power systems, but does not have any affect on the code generation for Power.
So, what can we do here? Maybe add a constrain in the configure file saying that it's not possible to build GRUB in a LE environment using clang.
If I understand it correctly, it is possible to build for big-endian PowerPC using
clang -target=powerpc
but then we depend on clang being built with BE target support; and e.g. openSUSE builds it with
cmake -G "Ninja" \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLVM_TARGETS_TO_BUILD=host \
-DCMAKE_C_FLAGS="-O0" \
-DCMAKE_CXX_FLAGS="-O0" \
-DLLVM_HOST_TRIPLE=%{host_triple} \so as I understand on ppc64le it does not build support for any other target. Actually openSUSE does not even build clang on ppc at all.
Quoted 92 lines
Quoted 90 lines
Le 30 juin 2015 16:30, "Andrei Borzenkov" <[email protected] <mailto:[email protected]>> a écrit :
On Tue, Jun 30, 2015 at 5:03 PM, Vladimir 'phcoder' Serbinenko <[email protected] <mailto:[email protected]>> wrote: > Which compilers support these flags? I'm concerned of breaking old compilers > -static and -mbig-endian are listed in gcc 2.95.3 documentation for PPC. > Le 30 juin 2015 14:57, "Paulo Flabiano Smorigo" > <[email protected] <mailto:[email protected]>> a écrit : >> >> libgcc dependency was removed *just* for this target because >> the distros that use ppc64el doesn't have 32-bit support on it. >> >> * configure.ac <http://configure.ac>: Add targets for powerpc64el and skip libgcc. >> * Makefile.am: Likewise. >> --- >> configure.ac <http://configure.ac> | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/configure.ac <http://configure.ac> b/configure.ac <http://configure.ac> >> index fd8a62e..0a79fad 100644 >> --- a/configure.ac <http://configure.ac> >> +++ b/configure.ac <http://configure.ac> >> @@ -116,6 +116,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 ;; >> @@ -138,6 +139,7 @@ case "$target_cpu"-"$platform" in >> x86_64-none) ;; >> 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. >> @@ -601,6 +603,12 @@ if test "x$target_cpu" = xi386 && test "x$platform" >> != xemu; then >> TARGET_CFLAGS="$TARGET_CFLAGS -march=i386" >> fi >> >> +if test x$target_cpu = xpowerpc; then >> + 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" >> -- >> 2.1.0 >> >> >> _______________________________________________ >> Grub-devel mailing list >> [email protected] <mailto:[email protected]> >> https://lists.gnu.org/mailman/listinfo/grub-devel > > > _______________________________________________ > Grub-devel mailing list > [email protected] <mailto:[email protected]> > https://lists.gnu.org/mailman/listinfo/grub-devel > _______________________________________________ Grub-devel mailing list [email protected] <mailto:[email protected]> https://lists.gnu.org/mailman/listinfo/grub-devel_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
I think those flags disable only runtime libraries, not the code generation
Quoted 143 lines · Andrei Borzenkov
В Tue, 30 Jun 2015 15:05:46 -0300
Paulo Flabiano Smorigo <[email protected]> пишет:Quoted 10 lines · Vladimir 'phcoder' Serbinenko
Quoted 1 line
What about clang?
Not good news about clang support. This is what the toolchain team said about it:
The -mbig-endian option was added around April 10th, 2014. Unfortunately, those who implemented it only implemented it for ARM and one other architecture.
Quoted 6 lines
The option is currently accepted on Power systems, but does not have any affect on the code generation for Power.
So, what can we do here? Maybe add a constrain in the configure file saying that it's not possible to build GRUB in a LE environment using
clang.
If I understand it correctly, it is possible to build for big-endian PowerPC using
clang -target=powerpc
but then we depend on clang being built with BE target support; and e.g. openSUSE builds it with
cmake -G "Ninja" \ -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_ASSERTIONS=OFF \ -DLLVM_TARGETS_TO_BUILD=host \ -DCMAKE_C_FLAGS="-O0" \ -DCMAKE_CXX_FLAGS="-O0" \ -DLLVM_HOST_TRIPLE=%{host_triple} \so as I understand on ppc64le it does not build support for any other target. Actually openSUSE does not even build clang on ppc at all.
Quoted 11 lines
Quoted 11 lines
Le 30 juin 2015 16:30, "Andrei Borzenkov" <[email protected] <mailto:[email protected]>> a écrit :
On Tue, Jun 30, 2015 at 5:03 PM, Vladimir 'phcoder' Serbinenko <[email protected] <mailto:[email protected]>> wrote:
> Which compilers support these flags? I'm concerned of breaking
old compilers
>-static and -mbig-endian are listed in gcc 2.95.3 documentation
for PPC.
Quoted 74 lines
Quoted 74 lines
> Le 30 juin 2015 14:57, "Paulo Flabiano Smorigo" > <[email protected] <mailto:[email protected]>> a écrit : >> >> libgcc dependency was removed *just* for this target because >> the distros that use ppc64el doesn't have 32-bit support on it. >> >> * configure.ac <http://configure.ac>: Add targets for powerpc64el and skip libgcc. >> * Makefile.am: Likewise. >> --- >> configure.ac <http://configure.ac> | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/configure.ac <http://configure.ac> b/configure.ac <http://configure.ac> >> index fd8a62e..0a79fad 100644 >> --- a/configure.ac <http://configure.ac> >> +++ b/configure.ac <http://configure.ac> >> @@ -116,6 +116,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 ;; >> @@ -138,6 +139,7 @@ case "$target_cpu"-"$platform" in >> x86_64-none) ;; >> 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. >> @@ -601,6 +603,12 @@ if test "x$target_cpu" = xi386 && test "x$platform" >> != xemu; then >> TARGET_CFLAGS="$TARGET_CFLAGS -march=i386" >> fi >> >> +if test x$target_cpu = xpowerpc; then >> + 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" >> -- >> 2.1.0 >> >> >> _______________________________________________ >> Grub-devel mailing list >> [email protected] <mailto:[email protected]> >> https://lists.gnu.org/mailman/listinfo/grub-devel > > > _______________________________________________ > Grub-devel mailing list > [email protected] <mailto:[email protected]> > https://lists.gnu.org/mailman/listinfo/grub-devel > _______________________________________________ Grub-devel mailing list [email protected] <mailto:[email protected]> https://lists.gnu.org/mailman/listinfo/grub-develQuoted 7 lines
Quoted 5 lines
_______________________________________________
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
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
В Tue, 30 Jun 2015 21:34:10 +0200
"Vladimir 'phcoder' Serbinenko" <[email protected]> пишет:
Quoted 1 line
I think those flags disable only runtime libraries, not the code generation
Yes, you are right. Clang seems to be built for the whole family, i.e. PowerPC, which seems to automatically include all three versions (ppc, ppc64, ppc64le)
See below for details.
Quoted 11 lines · Andrei Borzenkov
Quoted 10 lines
В Tue, 30 Jun 2015 15:05:46 -0300
Paulo Flabiano Smorigo <[email protected]> пишет:Quoted 6 lines · Vladimir 'phcoder' Serbinenko
Quoted 1 line
What about clang?
Not good news about clang support. This is what the toolchain team said about it:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
The -mbig-endian option was added around April 10th, 2014. Unfortunately, those who implemented it only implemented it for ARM and one other architecture.
The option is currently accepted on Power systems, but does not have any affect on the code generation for Power.
Support for it looks rather trivial; see attached patch. Anyone has good connection to clang development community?
Using this patch the
clang --target=powerpc64le -mbig-endian -m32 produces code for PPC32 BE, so just works:
bor@opensuse:~/build/clang-ppc/bin> ./clang --target=powerpc64le -c -mbig-endian -m32 /tmp/foo.c/tmp/foo.c:1:1: warning: type specifier missing, defaults to 'int'
[-Wimplicit-int]foo()
^
1 warning generated.
bor@opensuse:~/build/clang-ppc/bin> file foo.o
foo.o: ELF 32-bit MSB relocatable, PowerPC or cisco 4500, version 1 (SYSV), not stripped
The problem is that in this case we do not really have any way to test if it works in configure, so no way to fail gracefully.
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
So, what can we do here? Maybe add a constrain in the configure file saying that it's not possible to build GRUB in a LE environment using
clang.
Quoted 8 lines
Quoted 8 lines
If I understand it correctly, it is possible to build for big-endian PowerPC using
clang -target=powerpc
but then we depend on clang being built with BE target support; and e.g. openSUSE builds it with
Yes, that works too. But I'm not sure how we can test for it. Brute force would of course be
$TARGET_CC --version | grep clang && TARGET_CFLAGS=--target=powerpc
Comments? I'm inclined to use this workaround. This still may have issues when using external assembler, but here we can simply mandate support for clang 3.6 at the minimum, which should use integrated assembler on PPC by default.
From: Andrei Borzenkov <[email protected]>
Subject: [PATCH] support -big-endian/-mlittle-endian on PowerPC64
--- lib/Driver/Driver.cpp | 4 ++++ 1 file changed, 4 insertions(+)
lib/Driver/Driver.cpp +4 -0
@@ -1947,6 +1947,8 @@ static llvm::Triple computeTargetTriple(StringRef DefaultTargetTriple, Target.setArch(llvm::Triple::mips64el); else if (Target.getArch() == llvm::Triple::aarch64_be) Target.setArch(llvm::Triple::aarch64); + else if (Target.getArch() == llvm::Triple::ppc64) + Target.setArch(llvm::Triple::ppc64le); } else { if (Target.getArch() == llvm::Triple::mipsel) Target.setArch(llvm::Triple::mips);
@@ -1954,6 +1956,8 @@ static llvm::Triple computeTargetTriple(StringRef DefaultTargetTriple, Target.setArch(llvm::Triple::mips64); else if (Target.getArch() == llvm::Triple::aarch64) Target.setArch(llvm::Triple::aarch64_be); + else if (Target.getArch() == llvm::Triple::ppc64le) + Target.setArch(llvm::Triple::ppc64); } }
Signature · 1 line
tg: (76af433..) e/ppc-mendian (depends on: master)
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
В Sat, 4 Jul 2015 09:46:59 +0300
Andrei Borzenkov <[email protected]> пишет:
Quoted 67 lines
В Tue, 30 Jun 2015 21:34:10 +0200
"Vladimir 'phcoder' Serbinenko" <[email protected]> пишет:Quoted 1 line
I think those flags disable only runtime libraries, not the code generation
Yes, you are right. Clang seems to be built for the whole family, i.e. PowerPC, which seems to automatically include all three versions (ppc, ppc64, ppc64le)
See below for details.
Quoted 11 lines · Andrei Borzenkov
Quoted 10 lines
В Tue, 30 Jun 2015 15:05:46 -0300
Paulo Flabiano Smorigo <[email protected]> пишет:Quoted 6 lines · Vladimir 'phcoder' Serbinenko
Quoted 1 line
What about clang?
Not good news about clang support. This is what the toolchain team said about it:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
The -mbig-endian option was added around April 10th, 2014. Unfortunately, those who implemented it only implemented it for ARM and one other architecture.
The option is currently accepted on Power systems, but does not have any affect on the code generation for Power.
Support for it looks rather trivial; see attached patch. Anyone has good connection to clang development community?
Using this patch the
clang --target=powerpc64le -mbig-endian -m32 produces code for PPC32 BE, so just works:
bor@opensuse:~/build/clang-ppc/bin> ./clang --target=powerpc64le -c -mbig-endian -m32
/tmp/foo.c/tmp/foo.c:1:1: warning: type specifier missing, defaults to 'int'
[-Wimplicit-int]foo()
^
1 warning generated.
bor@opensuse:~/build/clang-ppc/bin> file foo.o
foo.o: ELF 32-bit MSB relocatable, PowerPC or cisco 4500, version 1 (SYSV), not strippedThe problem is that in this case we do not really have any way to test if it works in configure, so no way to fail gracefully.
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
So, what can we do here? Maybe add a constrain in the configure file saying that it's not possible to build GRUB in a LE environment using
clang.
Quoted 8 lines
Quoted 8 lines
If I understand it correctly, it is possible to build for big-endian PowerPC using
clang -target=powerpc
but then we depend on clang being built with BE target support; and e.g. openSUSE builds it with
Yes, that works too. But I'm not sure how we can test for it. Brute force would of course be
Quoted 6 lines
$TARGET_CC --version | grep clang && TARGET_CFLAGS=--target=powerpc
Comments? I'm inclined to use this workaround. This still may have issues when using external assembler, but here we can simply mandate support for clang 3.6 at the minimum, which should use integrated assembler on PPC by default.
Unfortunately it fails to link. clang does not pass any explicit endian flag to linker; endianness is property of target and clang expects to have tool chain for each target. This is exactly what we want to avoid (we want to avoid having ppc32 toolchaing on ppc64le), so clang falls back to generic gcc as linker and it attempts to produce LE output from BE objects and fails.
I thinks it is clang deficiency. It should pass endianness flags just as it does currently for -m32/-m64.
It is possible to compile using "--target=powerpc -Wl,-EB" - this works on all three ppc, ppc64 and ppc64le, but this means hardcoding GNU ld dependency.
So I'd rather try to produce patch for proper support of -mbig-endian/-mlittle-endian (including passing it onto gcc linker) and until then declared clang on ppc64le having limited support (i.e. support for automatic detection by configure).
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
In reply to Andrei BorzenkovQuoted 17 lines · Andrei Borzenkov
В Tue, 30 Jun 2015 15:05:46 -0300
Paulo Flabiano Smorigo <[email protected]> пишет:Quoted 14 lines · Vladimir 'phcoder' Serbinenko
Quoted 1 line
What about clang?
Not good news about clang support. This is what the toolchain team said about it:
The -mbig-endian option was added around April 10th, 2014. Unfortunately, those who implemented it only implemented it for ARM and one other architecture.
The option is currently accepted on Power systems, but does not have any affect on the code generation for Power.
Quoted 8 lines
Quoted 2 lines
So, what can we do here? Maybe add a constrain in the configure file saying that it's not possible to build GRUB in a LE environment using clang.
If I understand it correctly, it is possible to build for big-endian PowerPC using
clang -target=powerpc
@pfsmorigo. Please try attached patch
Quoted 111 lines
but then we depend on clang being built with BE target support; and e.g. openSUSE builds it with
cmake -G "Ninja" \ -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_ASSERTIONS=OFF \ -DLLVM_TARGETS_TO_BUILD=host \ -DCMAKE_C_FLAGS="-O0" \ -DCMAKE_CXX_FLAGS="-O0" \ -DLLVM_HOST_TRIPLE=%{host_triple} \so as I understand on ppc64le it does not build support for any other target. Actually openSUSE does not even build clang on ppc at all.
Quoted 85 lines
Quoted 85 lines
Le 30 juin 2015 16:30, "Andrei Borzenkov" <[email protected] <mailto:[email protected]>> a écrit :
On Tue, Jun 30, 2015 at 5:03 PM, Vladimir 'phcoder' Serbinenko <[email protected] <mailto:[email protected]>> wrote: > Which compilers support these flags? I'm concerned of breaking old compilers > -static and -mbig-endian are listed in gcc 2.95.3 documentation for PPC. > Le 30 juin 2015 14:57, "Paulo Flabiano Smorigo" > <[email protected] <mailto:[email protected]>> a écrit : >> >> libgcc dependency was removed *just* for this target because >> the distros that use ppc64el doesn't have 32-bit support on it. >> >> * configure.ac <http://configure.ac>: Add targets for powerpc64el and skip libgcc. >> * Makefile.am: Likewise. >> --- >> configure.ac <http://configure.ac> | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/configure.ac <http://configure.ac> b/configure.ac <http://configure.ac> >> index fd8a62e..0a79fad 100644 >> --- a/configure.ac <http://configure.ac> >> +++ b/configure.ac <http://configure.ac> >> @@ -116,6 +116,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 ;; >> @@ -138,6 +139,7 @@ case "$target_cpu"-"$platform" in >> x86_64-none) ;; >> 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. >> @@ -601,6 +603,12 @@ if test "x$target_cpu" = xi386 && test "x$platform" >> != xemu; then >> TARGET_CFLAGS="$TARGET_CFLAGS -march=i386" >> fi >> >> +if test x$target_cpu = xpowerpc; then >> + 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" >> -- >> 2.1.0 >> >> >> _______________________________________________ >> Grub-devel mailing list >> [email protected] <mailto:[email protected]> >> https://lists.gnu.org/mailman/listinfo/grub-devel > > > _______________________________________________ > Grub-devel mailing list > [email protected] <mailto:[email protected]> > https://lists.gnu.org/mailman/listinfo/grub-devel > _______________________________________________ Grub-devel mailing list [email protected] <mailto:[email protected]> https://lists.gnu.org/mailman/listinfo/grub-develQuoted 7 lines
Quoted 5 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 5 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
configure.ac +29 -0
@@ -116,6 +116,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 ;;
@@ -138,6 +139,7 @@ case "$target_cpu"-"$platform" in x86_64-none) ;; 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.
@@ -601,6 +603,33 @@ if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then TARGET_CFLAGS="$TARGET_CFLAGS -march=i386" fi +if test x$target_cpu = xpowerpc; then + AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [ + grub_cv_target_cc_big_endian=no + for cand in "-target powerpc" \ + "-mbig-endian"; do + if test x"$grub_cv_target_cc_big_endian" != xno ; then + break + fi + CFLAGS="$TARGET_CFLAGS $cand -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__) +#error still little endian +#endif +]], [[]])], + [grub_cv_target_cc_big_endian="$cand"], []) + done + ]) + + if test x"$grub_cv_target_cc_big_endian" = xno ; then + AC_MSG_ERROR([could not force big-endian]) + fi + + TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_big_endian" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_big_endian" + TARGET_LDFLAGS="$TARGET_LDFLAGS -static $grub_cv_target_cc_big_endian" +fi + if test "x$target_m32" = x1; then # Force 32-bit mode. TARGET_CFLAGS="$TARGET_CFLAGS -m32"
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
In reply to Andrei BorzenkovQuoted 26 lines · Andrei Borzenkov
В Tue, 30 Jun 2015 21:34:10 +0200
"Vladimir 'phcoder' Serbinenko" <[email protected]> пишет:Quoted 1 line
I think those flags disable only runtime libraries, not the code generation
Yes, you are right. Clang seems to be built for the whole family, i.e. PowerPC, which seems to automatically include all three versions (ppc, ppc64, ppc64le)
See below for details.
Quoted 15 lines · Andrei Borzenkov
Quoted 14 lines
В Tue, 30 Jun 2015 15:05:46 -0300
Paulo Flabiano Smorigo <[email protected]> пишет:Quoted 10 lines · Vladimir 'phcoder' Serbinenko
Quoted 1 line
What about clang?
Not good news about clang support. This is what the toolchain team said about it:
The -mbig-endian option was added around April 10th, 2014. Unfortunately, those who implemented it only implemented it for ARM and one other architecture.
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
The option is currently accepted on Power systems, but does not have any affect on the code generation for Power.
Support for it looks rather trivial; see attached patch. Anyone has good connection to clang development community?
Just send it to their ML. They usually have good response. If this patch is accepted we can probably simplify it in our code
Quoted 14 lines
Using this patch the
clang --target=powerpc64le -mbig-endian -m32 produces code for PPC32 BE, so just works:
bor@opensuse:~/build/clang-ppc/bin> ./clang --target=powerpc64le -c -mbig-endian -m32
/tmp/foo.c/tmp/foo.c:1:1: warning: type specifier missing, defaults to 'int'
[-Wimplicit-int]foo()
^
1 warning generated.
bor@opensuse:~/build/clang-ppc/bin> file foo.o
foo.o: ELF 32-bit MSB relocatable, PowerPC or cisco 4500, version 1 (SYSV), not stripped
Quoted 3 lines
The problem is that in this case we do not really have any way to test if it works in configure, so no way to fail gracefully.
Just check the defines.
Quoted 24 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
So, what can we do here? Maybe add a constrain in the configure file saying that it's not possible to build GRUB in a LE environment using
clang.
Quoted 8 lines
Quoted 8 lines
If I understand it correctly, it is possible to build for big-endian PowerPC using
clang -target=powerpc
but then we depend on clang being built with BE target support; and e.g. openSUSE builds it with
Yes, that works too. But I'm not sure how we can test for it. Brute force would of course be
$TARGET_CC --version | grep clang && TARGET_CFLAGS=--target=powerpc
Comments? I'm inclined to use this workaround. This still may have issues when using external assembler, but here we can simply mandate support for clang 3.6 at the minimum, which should use integrated assembler on PPC by default.
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
In reply to Andrei BorzenkovQuoted 5 lines
It is possible to compile using "--target=powerpc -Wl,-EB" - this works on all three ppc, ppc64 and ppc64le, but this means hardcoding GNU ld dependency.
Thanks for this info.
See attached patch
Quoted 5 lines
So I'd rather try to produce patch for proper support of -mbig-endian/-mlittle-endian (including passing it onto gcc linker) and until then declared clang on ppc64le having limited support (i.e. support for automatic detection by configure).
I agree that this is a better approach in long term. But if we can get some support for current tools with little work (see patch) and without risks of breaking other tools I see no reason not to go for it in short term
Quoted 1 line
configure.ac +33 -0
@@ -116,6 +116,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 ;;
@@ -138,6 +139,7 @@ case "$target_cpu"-"$platform" in x86_64-none) ;; 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.
@@ -601,6 +603,37 @@ if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then TARGET_CFLAGS="$TARGET_CFLAGS -march=i386" fi +if test x$target_cpu = xpowerpc; then + AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [ + grub_cv_target_cc_big_endian=no + for cand in "-target powerpc -Wl,-EB" "-target powerpc" \ + "-mbig-endian"; do + if test x"$grub_cv_target_cc_big_endian" != xno ; then + break + fi + CFLAGS="$TARGET_CFLAGS $cand -Werror" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__) +#error still little endian +#endif +asm (".globl start; start:"); +void __main (void); +void __main (void) {} +int main (void); +]], [[]])], + [grub_cv_target_cc_big_endian="$cand"], []) + done + ]) + + if test x"$grub_cv_target_cc_big_endian" = xno ; then + AC_MSG_ERROR([could not force big-endian]) + fi + + TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_big_endian" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_big_endian" + TARGET_LDFLAGS="$TARGET_LDFLAGS -static $grub_cv_target_cc_big_endian" +fi + if test "x$target_m32" = x1; then # Force 32-bit mode. TARGET_CFLAGS="$TARGET_CFLAGS -m32"
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
В Wed, 15 Jul 2015 19:42:39 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:
Quoted 7 lines
Quoted 5 lines
It is possible to compile using "--target=powerpc -Wl,-EB" - this works on all three ppc, ppc64 and ppc64le, but this means hardcoding GNU ld dependency.
Thanks for this info.
See attached patch
Test has to come before asm tests (so that we are sure to compile for the right target).
But real problem is that -Wl,-EB has to be added to TARGET_LDFLAGS only
[ 106s] configure:24950: clang -c -v -Wall -W -Wshadow
-Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -target powerpc -Wl,-EB -m32 -msoft-float -Werror -Wall -W -DGRUB_MACHINE_IEEE1275=1 -DGRUB_MACHINE=POWERPC_IEEE1275 conftest.c >&5 [ 106s] clang version 3.6.1 (tags/RELEASE_361/final 238133)
[ 106s] Target: powerpc [ 106s] Thread model: posix [ 106s] clang-3.6: error: -Wl,-EB: 'linker' input unused
Quoted 10 lines
Quoted 5 lines
So I'd rather try to produce patch for proper support of -mbig-endian/-mlittle-endian (including passing it onto gcc linker) and until then declared clang on ppc64le having limited support (i.e. support for automatic detection by configure).
I agree that this is a better approach in long term. But if we can get some support for current tools with little work (see patch) and without risks of breaking other tools I see no reason not to go for it in short term
Quoted 1 line
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
Quoted 8 lines · Andrei Borzenkov
В Wed, 15 Jul 2015 19:42:39 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:Quoted 5 lines
Quoted 5 lines
It is possible to compile using "--target=powerpc -Wl,-EB" - this works on all three ppc, ppc64 and ppc64le, but this means hardcoding GNU ld dependency.
Quoted 8 lines
Quoted 2 lines
Thanks for this info.
See attached patchTest has to come before asm tests (so that we are sure to compile for the right target).
But real problem is that -Wl,-EB has to be added to
TARGET_LDFLAGSonly
Yes, discovered it already and updated the patch
Quoted 2 lines
[ 106s] configure:24950: clang -c -v -Wall -W -Wshadow
-Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -target powerpc -Wl,-EB -m32 -msoft-float -W
error -Wall -W -DGRUB_MACHINE_IEEE1275=1 -DGRUB_MACHINE=POWERPC_IEEE1275 conftest.c >&5 [ 106s] clang version 3.6.1 (tags/RELEASE_361/final 238133)
Quoted 16 lines
[ 106s] Target: powerpc [ 106s] Thread model: posix [ 106s] clang-3.6: error: -Wl,-EB: 'linker' input unusedQuoted 10 lines
Quoted 5 lines
So I'd rather try to produce patch for proper support of -mbig-endian/-mlittle-endian (including passing it onto gcc linker) and until then declared clang on ppc64le having limited support (i.e. support for automatic detection by configure).
I agree that this is a better approach in long term. But if we can get some support for current tools with little work (see patch) and without risks of breaking other tools I see no reason not to go for it in short term
Quoted 1 line
configure.ac +37 -0
@@ -116,6 +116,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 ;;
@@ -138,6 +139,7 @@ case "$target_cpu"-"$platform" in x86_64-none) ;; 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.
@@ -560,6 +562,41 @@ AC_COMPILE_IFELSE( ]])], [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])]) +if test x$target_cpu = xpowerpc; then + AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [ + grub_cv_target_cc_big_endian=no + for cand in "-target powerpc -Wl,-EB" "-target powerpc" \ + "-target powerpc-linux-gnu -Wl,-EB" "-target powerpc-linux-gnu" \ + "-mbig-endian"; do + if test x"$grub_cv_target_cc_big_endian" != xno ; then + break + fi + CFLAGS="$TARGET_CFLAGS $cand -Werror" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__) +#error still little endian +#endif +asm (".globl start; start:"); +void __main (void); +void __main (void) {} +int main (void); +]], [[]])], + [grub_cv_target_cc_big_endian="$cand"], []) + done + ]) + + if test x"$grub_cv_target_cc_big_endian" = xno ; then + AC_MSG_ERROR([could not force big-endian]) + fi + + skip_linkflags="$(echo "$grub_cv_target_cc_big_endian"|sed 's@-Wl,-EB@@')" + + TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags" + TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags" + TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian" +fi + AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [ test_program= case "x$target_cpu-$platform" in
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
В Thu, 16 Jul 2015 21:05:07 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:
Quoted 12 lines · Andrei Borzenkov
Quoted 11 lines
В Wed, 15 Jul 2015 19:42:39 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:Quoted 7 lines
Quoted 5 lines
It is possible to compile using "--target=powerpc -Wl,-EB" - this works on all three ppc, ppc64 and ppc64le, but this means hardcoding GNU ld dependency.
Thanks for this info.
See attached patch
Quoted 6 lines
Quoted 5 lines
Test has to come before asm tests (so that we are sure to compile for the right target).
But real problem is that -Wl,-EB has to be added to
TARGET_LDFLAGSonlyYes, discovered it already and updated the patch
Yes, this version builds OK both in native PPC environment as well as cross-compiling.
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
Quoted 19 lines · Andrei Borzenkov
В Thu, 16 Jul 2015 21:05:07 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:Quoted 8 lines · Andrei Borzenkov
Quoted 7 lines
В Wed, 15 Jul 2015 19:42:39 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:Quoted 4 lines
Quoted 4 lines
It is possible to compile using "--target=powerpc -Wl,-EB" - this works on all three ppc, ppc64 and ppc64le, but this means hardcoding GNU ld dependency.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Thanks for this info.
See attached patchTest has to come before asm tests (so that we are sure to compile for the right target).
But real problem is that -Wl,-EB has to be added to
TARGET_LDFLAGSonlyYes, discovered it already and updated the patch
Quoted 8 lines
Yes, this version builds OK both in native PPC environment as well as cross-compiling.
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Here works too. Both native and cross-compiled.
Signature · 2 lines
Paulo Flabiano Smorigo IBM Linux Technology Center
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
In reply to Vladimir 'φ-coder/phcoder' SerbinenkoВ Wed, 15 Jul 2015 19:42:39 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:
Quoted 7 lines
Quoted 5 lines
It is possible to compile using "--target=powerpc -Wl,-EB" - this works on all three ppc, ppc64 and ppc64le, but this means hardcoding GNU ld dependency.
Thanks for this info.
See attached patch
I do not think it was right to commit this patch without bi-endian ELF support; this makes GRUB compile of ppc64le but it still cannot load kernel.
Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
Quoted 8 lines · Andrei Borzenkov
В Wed, 15 Jul 2015 19:42:39 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:Quoted 5 lines
Quoted 5 lines
It is possible to compile using "--target=powerpc -Wl,-EB" - this works on all three ppc, ppc64 and ppc64le, but this means hardcoding GNU ld dependency.
Quoted 6 lines
Quoted 2 lines
Thanks for this info.
See attached patchI do not think it was right to commit this patch without bi-endian ELF support; this makes GRUB compile of ppc64le but it still cannot load kernel.
Yes, you are right. Let me finish the changes on the second patch so we can commit both.
Quoted 8 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