diff --git a/lld/ELF/Arch/PPC64.cpp b/lld/ELF/Arch/PPC64.cpp index 22392db1a2d8..26acb269678c 100644 --- a/lld/ELF/Arch/PPC64.cpp +++ b/lld/ELF/Arch/PPC64.cpp @@ -97,10 +97,17 @@ PPC64::PPC64() { static uint32_t getEFlags(InputFile *File) { // Get the e_flag from the input file and issue an error if incompatible // e_flag encountered. - - uint32_t EFlags = Config->IsLE ? - cast>(File)->getObj().getHeader()->e_flags : - cast>(File)->getObj().getHeader()->e_flags; + uint32_t EFlags; + switch (Config->EKind) { + case ELF64BEKind: + EFlags = cast>(File)->getObj().getHeader()->e_flags; + break; + case ELF64LEKind: + EFlags = cast>(File)->getObj().getHeader()->e_flags; + break; + default: + llvm_unreachable("unknown Config->EKind"); + } if (EFlags > 2) { error("incompatible e_flags: " + toString(File)); return 0;