From bdf43a642d2c5fd519fb6b76a8def9e3e90e65c4 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Sat, 5 Dec 2020 19:05:40 +0100 Subject: [PATCH] ELF: Improve GetSections() accuracy when only PHT is available --- Il2CppInspector.Common/FileFormatReaders/ElfReader.cs | 6 +++--- .../FileFormatReaders/FormatLayouts/Elf.cs | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Il2CppInspector.Common/FileFormatReaders/ElfReader.cs b/Il2CppInspector.Common/FileFormatReaders/ElfReader.cs index 73eb519..66c192d 100644 --- a/Il2CppInspector.Common/FileFormatReaders/ElfReader.cs +++ b/Il2CppInspector.Common/FileFormatReaders/ElfReader.cs @@ -473,9 +473,9 @@ namespace Il2CppInspector ImageEnd = (uint) conv.Int(p.p_offset) + (uint) conv.Int(p.p_filesz) - 1, // Not correct but probably the best we can do - IsData = (Elf) p.p_type == Elf.PT_LOAD, - IsExec = (Elf) p.p_type == Elf.PT_LOAD, - IsBSS = (Elf) p.p_type == Elf.PT_LOAD, + IsData = ((Elf) p.p_flags & Elf.PF_R) != 0, + IsExec = ((Elf) p.p_flags & Elf.PF_X) != 0, + IsBSS = conv.Int(p.p_filesz) == 0, Name = string.Empty }); diff --git a/Il2CppInspector.Common/FileFormatReaders/FormatLayouts/Elf.cs b/Il2CppInspector.Common/FileFormatReaders/FormatLayouts/Elf.cs index 2f1b8b8..8134e9d 100644 --- a/Il2CppInspector.Common/FileFormatReaders/FormatLayouts/Elf.cs +++ b/Il2CppInspector.Common/FileFormatReaders/FormatLayouts/Elf.cs @@ -35,6 +35,8 @@ namespace Il2CppInspector DT_PLTGOT = 3, PF_X = 1, + PF_W = 2, + PF_R = 4, // SHTs SHT_PROGBITS = 1,