Index: ELF/Arch/PPC64.cpp =================================================================== --- ELF/Arch/PPC64.cpp +++ ELF/Arch/PPC64.cpp @@ -94,7 +94,8 @@ // use 0x10000000 as the starting address. DefaultImageBase = 0x10000000; - TrapInstr = 0x7fe00008; + bool IsBE = Config->EKind != ELF64LEKind; + TrapInstr = IsBE == sys::IsBigEndianHost ? 0x7fe00008 : 0x0800e07f; } static uint32_t getEFlags(InputFile *File) { Index: test/ELF/fill-trap-ppc.s =================================================================== --- test/ELF/fill-trap-ppc.s +++ test/ELF/fill-trap-ppc.s @@ -3,12 +3,12 @@ # RUN: llvm-mc -filetype=obj -triple=powerpc64le-linux %s -o %t.o # RUN: ld.lld %t.o -o %t.ppc64le # RUN: llvm-readobj -program-headers %t.ppc64le | FileCheck %s -# RUN: od -Ax -t x4 -N16 -j0x10ff0 %t.ppc64le | FileCheck %s -check-prefix=FILL +# RUN: od -Ax -t x1 -N16 -j0x10ff0 %t.ppc64le | FileCheck %s -check-prefix=LE # RUN: llvm-mc -filetype=obj -triple=powerpc64-linux %s -o %t.o # RUN: ld.lld %t.o -o %t.ppc64 # RUN: llvm-readobj -program-headers %t.ppc64 | FileCheck %s -# RUN: od -Ax -t x4 -N16 -j0x10ff0 %t.ppc64 | FileCheck %s -check-prefix=FILL +# RUN: od -Ax -t x1 -N16 -j0x10ff0 %t.ppc64 | FileCheck %s -check-prefix=BE # CHECK: ProgramHeader { # CHECK: Type: PT_LOAD @@ -23,7 +23,8 @@ # CHECK-NEXT: ] ## Check that executable page is filled with traps at its end. -# FILL: 010ff0 7fe00008 7fe00008 7fe00008 7fe00008 +# LE: 010ff0 08 00 e0 7f 08 00 e0 7f 08 00 e0 7f 08 00 e0 7f +# BE: 010ff0 7f e0 00 08 7f e0 00 08 7f e0 00 08 7f e0 00 08 .globl _start _start: