import os
import pathlib
import time
+import typing
from ctypes import (
c_char,
c_uint8,
def convert_elf_relocations(
elf: ELFFile, opt: PeOptionalHeader, sections: list[PeSection]
-) -> PeSection:
+) -> typing.Optional[PeSection]:
dynamic = elf.get_section_by_name(".dynamic")
if dynamic is None:
raise RuntimeError("ELF .dynamic section is missing.")
elf, reloc_table, opt.ImageBase, sections, pe_reloc_blocks
)
+ if len(pe_reloc_blocks) == 0:
+ return None
+
data = bytearray()
for rva in sorted(pe_reloc_blocks):
block = pe_reloc_blocks[rva]
opt.SizeOfHeapCommit = 0x001000
opt.NumberOfRvaAndSizes = N_DATA_DIRECTORY_ENTRIES
- opt.BaseRelocationTable = PeDataDirectory(
- pe_reloc_s.VirtualAddress, pe_reloc_s.VirtualSize
- )
+ if pe_reloc_s:
+ opt.BaseRelocationTable = PeDataDirectory(
+ pe_reloc_s.VirtualAddress, pe_reloc_s.VirtualSize
+ )
write_pe(args.PE, coff, opt, sections)