Fix incorrect use of GlobalOffset in ELF (WARNING: breaks some binaries from resolving)
This commit is contained in:
@@ -184,11 +184,9 @@ namespace Il2CppInspector
|
|||||||
if (getProgramHeader(Elf.PT_DYNAMIC) is TPHdr PT_DYNAMIC)
|
if (getProgramHeader(Elf.PT_DYNAMIC) is TPHdr PT_DYNAMIC)
|
||||||
dynamic_table = ReadArray<elf_dynamic<TWord>>(math.Long(PT_DYNAMIC.p_offset), (int) (math.Long(PT_DYNAMIC.p_filesz) / Sizeof(typeof(elf_dynamic<TWord>))));
|
dynamic_table = ReadArray<elf_dynamic<TWord>>(math.Long(PT_DYNAMIC.p_offset), (int) (math.Long(PT_DYNAMIC.p_filesz) / Sizeof(typeof(elf_dynamic<TWord>))));
|
||||||
|
|
||||||
// Get global offset table
|
// Get offset of code section
|
||||||
var _GLOBAL_OFFSET_TABLE_ = getDynamic(Elf.DT_PLTGOT)?.d_un;
|
var codeSegment = program_header_table.First(x => ((Elf) x.p_flags & Elf.PF_X) == Elf.PF_X);
|
||||||
if (_GLOBAL_OFFSET_TABLE_ == null)
|
GlobalOffset = math.ULong(math.Sub(codeSegment.p_vaddr, codeSegment.p_offset));
|
||||||
throw new InvalidOperationException("Unable to get GLOBAL_OFFSET_TABLE from PT_DYNAMIC");
|
|
||||||
GlobalOffset = math.ULong((TWord) _GLOBAL_OFFSET_TABLE_);
|
|
||||||
|
|
||||||
// Find all relocations; target address => (rela header (rels are converted to rela), symbol table base address, is rela?)
|
// Find all relocations; target address => (rela header (rels are converted to rela), symbol table base address, is rela?)
|
||||||
var rels = new HashSet<ElfReloc>();
|
var rels = new HashSet<ElfReloc>();
|
||||||
|
|||||||
@@ -5,10 +5,12 @@
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
using NoisyCowStudios.Bin2Object;
|
using NoisyCowStudios.Bin2Object;
|
||||||
|
|
||||||
namespace Il2CppInspector
|
namespace Il2CppInspector
|
||||||
{
|
{
|
||||||
|
[Flags]
|
||||||
public enum Elf : uint
|
public enum Elf : uint
|
||||||
{
|
{
|
||||||
// elf_header.m_dwFormat
|
// elf_header.m_dwFormat
|
||||||
@@ -28,6 +30,8 @@ namespace Il2CppInspector
|
|||||||
PT_DYNAMIC = 2,
|
PT_DYNAMIC = 2,
|
||||||
DT_PLTGOT = 3,
|
DT_PLTGOT = 3,
|
||||||
|
|
||||||
|
PF_X = 1,
|
||||||
|
|
||||||
// SHTs
|
// SHTs
|
||||||
SHT_SYMTAB = 2,
|
SHT_SYMTAB = 2,
|
||||||
SHT_STRTAB = 3,
|
SHT_STRTAB = 3,
|
||||||
@@ -122,6 +126,7 @@ namespace Il2CppInspector
|
|||||||
TWord p_offset { get; }
|
TWord p_offset { get; }
|
||||||
TWord p_filesz { get; }
|
TWord p_filesz { get; }
|
||||||
TWord p_vaddr { get; }
|
TWord p_vaddr { get; }
|
||||||
|
uint p_flags { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class elf_32_phdr : Ielf_phdr<uint>
|
internal class elf_32_phdr : Ielf_phdr<uint>
|
||||||
@@ -130,6 +135,7 @@ namespace Il2CppInspector
|
|||||||
public uint p_offset => f_p_offset;
|
public uint p_offset => f_p_offset;
|
||||||
public uint p_filesz => f_p_filesz;
|
public uint p_filesz => f_p_filesz;
|
||||||
public uint p_vaddr => f_p_vaddr;
|
public uint p_vaddr => f_p_vaddr;
|
||||||
|
public uint p_flags => f_p_flags;
|
||||||
|
|
||||||
public uint f_p_type;
|
public uint f_p_type;
|
||||||
public uint f_p_offset;
|
public uint f_p_offset;
|
||||||
@@ -137,7 +143,7 @@ namespace Il2CppInspector
|
|||||||
public uint p_paddr;
|
public uint p_paddr;
|
||||||
public uint f_p_filesz;
|
public uint f_p_filesz;
|
||||||
public uint p_memsz;
|
public uint p_memsz;
|
||||||
public uint p_flags;
|
public uint f_p_flags;
|
||||||
public uint p_align;
|
public uint p_align;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,9 +153,10 @@ namespace Il2CppInspector
|
|||||||
public ulong p_offset => f_p_offset;
|
public ulong p_offset => f_p_offset;
|
||||||
public ulong p_filesz => f_p_filesz;
|
public ulong p_filesz => f_p_filesz;
|
||||||
public ulong p_vaddr => f_p_vaddr;
|
public ulong p_vaddr => f_p_vaddr;
|
||||||
|
public uint p_flags => f_p_flags;
|
||||||
|
|
||||||
public uint f_p_type;
|
public uint f_p_type;
|
||||||
public uint p_flags;
|
public uint f_p_flags;
|
||||||
public ulong f_p_offset;
|
public ulong f_p_offset;
|
||||||
public ulong f_p_vaddr;
|
public ulong f_p_vaddr;
|
||||||
public ulong p_paddr;
|
public ulong p_paddr;
|
||||||
|
|||||||
Reference in New Issue
Block a user