From 4cc20e23f5262fdeb667bbc6bd4ba57c92aac8e4 Mon Sep 17 00:00:00 2001 From: James Cowgill Date: Mon, 19 Jun 2017 21:37:14 +0200 Subject: [PATCH] Fix ELF definitions for PowerPC in local-elf.h * ppc64el defines both __powerpc__ and __powerpc64__ but since the __powerpc64__ #elif is below the __powerpc__ one, it will never be hit. * Both assumed that powerpc* was big-endian. Fixes: https://bugs.debian.org/865091 Signed-off-by: Guillem Jover --- src/local-elf.h | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/local-elf.h b/src/local-elf.h index 84a6540..3abbe70 100644 --- a/src/local-elf.h +++ b/src/local-elf.h @@ -140,17 +140,29 @@ #define ELF_TARG_CLASS ELFCLASS32 #define ELF_TARG_DATA ELFDATA2LSB -#elif defined(__powerpc__) - -#define ELF_TARG_MACH EM_PPC -#define ELF_TARG_CLASS ELFCLASS32 -#define ELF_TARG_DATA ELFDATA2MSB - #elif defined(__powerpc64__) #define ELF_TARG_MACH EM_PPC64 #define ELF_TARG_CLASS ELFCLASS64 +#if defined(__LITTLE_ENDIAN__) +#define ELF_TARG_DATA ELFDATA2LSB +#elif defined(__BIG_ENDIAN__) #define ELF_TARG_DATA ELFDATA2MSB +#else +#error Unknown PowerPC64 endianness +#endif + +#elif defined(__powerpc__) + +#define ELF_TARG_MACH EM_PPC +#define ELF_TARG_CLASS ELFCLASS32 +#if defined(__LITTLE_ENDIAN__) +#define ELF_TARG_DATA ELFDATA2LSB +#elif defined(__BIG_ENDIAN__) +#define ELF_TARG_DATA ELFDATA2MSB +#else +#error Unknown PowerPC endianness +#endif #elif defined(__riscv)