Skip to content

Commit b2b6500

Browse files
authored
Merge pull request #44 from LANControlSystems/FixesToSave
Fixes to ElfFile to be able to save a core file.
2 parents 1d110e2 + 84c9d6e commit b2b6500

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/LibObjectFile/Elf/ElfFile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ public sealed partial class ElfFile : ElfObject, IEnumerable<ElfContent>
3333
/// <summary>
3434
/// Creates a new instance with the default sections (null and a shadow program header table).
3535
/// </summary>
36-
public ElfFile(ElfArch arch) : this(arch, ElfFileClass.None, ElfEncoding.None)
36+
public ElfFile(ElfArch arch, bool addDefaultSections=true) : this(arch, ElfFileClass.None, ElfEncoding.None, addDefaultSections)
3737
{
3838
}
3939

4040
/// <summary>
4141
/// Creates a new instance with the default sections (null and a shadow program header table).
4242
/// </summary>
43-
public ElfFile(ElfArch arch, ElfFileClass fileClass, ElfEncoding encoding) : this(true)
43+
public ElfFile(ElfArch arch, ElfFileClass fileClass, ElfEncoding encoding,bool addDefaultSections=true) : this(addDefaultSections)
4444
{
4545
Arch = arch;
4646
switch (arch)

src/LibObjectFile/Elf/ElfProgramHeaderTable.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ public override void Verify(ElfVisitorContext context)
5959

6060
protected override unsafe void UpdateLayoutCore(ElfVisitorContext context)
6161
{
62+
var elf = Parent;
63+
if (elf != null)
64+
{
65+
_is32 = elf.FileClass == ElfFileClass.Is32;
66+
}
6267
Size = (ulong)(Parent!.Segments.Count * (AdditionalEntrySize + (_is32 ? sizeof(ElfNative.Elf32_Phdr) : sizeof(ElfNative.Elf64_Phdr))));
6368
}
6469

0 commit comments

Comments
 (0)