Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/LibObjectFile/Elf/ElfFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public sealed partial class ElfFile : ElfObject, IEnumerable<ElfContent>
/// <summary>
/// Creates a new instance with the default sections (null and a shadow program header table).
/// </summary>
public ElfFile(ElfArch arch) : this(arch, ElfFileClass.None, ElfEncoding.None)
public ElfFile(ElfArch arch, bool addDefaultSections=true) : this(arch, ElfFileClass.None, ElfEncoding.None, addDefaultSections)
{
}

/// <summary>
/// Creates a new instance with the default sections (null and a shadow program header table).
/// </summary>
public ElfFile(ElfArch arch, ElfFileClass fileClass, ElfEncoding encoding) : this(true)
public ElfFile(ElfArch arch, ElfFileClass fileClass, ElfEncoding encoding,bool addDefaultSections=true) : this(addDefaultSections)
{
Arch = arch;
switch (arch)
Expand Down
5 changes: 5 additions & 0 deletions src/LibObjectFile/Elf/ElfProgramHeaderTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public override void Verify(ElfVisitorContext context)

protected override unsafe void UpdateLayoutCore(ElfVisitorContext context)
{
var elf = Parent;
if (elf != null)
{
_is32 = elf.FileClass == ElfFileClass.Is32;
}
Size = (ulong)(Parent!.Segments.Count * (AdditionalEntrySize + (_is32 ? sizeof(ElfNative.Elf32_Phdr) : sizeof(ElfNative.Elf64_Phdr))));
}

Expand Down