public DwarfReaderContext(DwarfElfContext elfContext) { if (elfContext == null) { throw new ArgumentNullException(nameof(elfContext)); } IsLittleEndian = elfContext.IsLittleEndian; AddressSize = elfContext.AddressSize; DebugLineStream = elfContext.LineTable?.Stream; DebugStringStream = elfContext.StringTable?.Stream; DebugAbbrevStream = elfContext.AbbreviationTable?.Stream; DebugInfoStream = elfContext.InfoSection?.Stream; DebugAddressRangeStream = elfContext.AddressRangeTable?.Stream; }
private static void CopyRelocationsX86_64(DwarfRelocatableSection dwarfRelocSection, DwarfElfContext elfContext, ElfRelocationTable relocTable) { relocTable.Entries.Clear(); foreach (var reloc in dwarfRelocSection.Relocations) { var relocType = reloc.Size == DwarfAddressSize.Bit64 ? ElfRelocationType.R_X86_64_64 : ElfRelocationType.R_X86_64_32; switch (reloc.Target) { case DwarfRelocationTarget.Code: relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, (uint)elfContext.CodeSectionSymbolIndex, (long)reloc.Addend)); break; case DwarfRelocationTarget.DebugString: relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, (uint)elfContext.StringTableSymbolIndex, (long)reloc.Addend)); break; case DwarfRelocationTarget.DebugAbbrev: relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, (uint)elfContext.AbbreviationTableSymbolIndex, (long)reloc.Addend)); break; case DwarfRelocationTarget.DebugInfo: relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, (uint)elfContext.InfoSectionSymbolIndex, (long)reloc.Addend)); break; default: throw new ArgumentOutOfRangeException(); } } }
public static void CopyRelocationsTo(this DwarfRelocatableSection dwarfRelocSection, DwarfElfContext elfContext, ElfRelocationTable relocTable) { if (elfContext == null) { throw new ArgumentNullException(nameof(elfContext)); } if (relocTable == null) { throw new ArgumentNullException(nameof(relocTable)); } switch (elfContext.Elf.Arch.Value) { case ElfArch.X86_64: CopyRelocationsX86_64(dwarfRelocSection, elfContext, relocTable); break; default: throw new NotImplementedException($"The relocation for architecture {relocTable.Parent.Arch} is not supported/implemented."); } }