From f416e57339bd3315834e6c14d6476e63ccb363ff Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Mon, 2 May 2022 12:19:48 +0200 Subject: [lldb] Fix ppc64 detection in lldb Currently, ppc64le and ppc64 (defaulting to big endian) have the same descriptor, thus the linear scan always return ppc64le. Handle that through subtype. This is a recommit of f114f009486816ed4b3bf984f0fbbb8fc80914f6 with a new test setup that doesn't involves (unsupported) corefiles. Differential Revision: https://reviews.llvm.org/D124760 --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp') diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 684d070c54d2..28ccfbe3d6e6 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -310,9 +310,19 @@ static uint32_t riscvVariantFromElfFlags(const elf::ELFHeader &header) { } } +static uint32_t ppc64VariantFromElfFlags(const elf::ELFHeader &header) { + uint32_t endian = header.e_ident[EI_DATA]; + if (endian == ELFDATA2LSB) + return ArchSpec::eCore_ppc64le_generic; + else + return ArchSpec::eCore_ppc64_generic; +} + static uint32_t subTypeFromElfHeader(const elf::ELFHeader &header) { if (header.e_machine == llvm::ELF::EM_MIPS) return mipsVariantFromElfFlags(header); + else if (header.e_machine == llvm::ELF::EM_PPC64) + return ppc64VariantFromElfFlags(header); else if (header.e_machine == llvm::ELF::EM_RISCV) return riscvVariantFromElfFlags(header); -- cgit v1.2.3