lib/pe: Directory-less fixed PE32+ images are rejected
Problem
pe64_load() requires NumberOfRvaAndSizes to include at least the base-relocation directory before it examines either the import or relocation directory. A valid fixed-address, import-free PE32+ image can advertise zero data-directory entries, so Limine rejects it with:
panic: pe: NumberOfRvaAndSizes too small for import/reloc directories
The Microsoft PE specification states that the number of directories is not fixed and that loaders must check NumberOfRvaAndSizes before accessing each entry.
Reproduction
I built an import-free native PE32+ image with Clang and lld-link /fixed, then changed only NumberOfRvaAndSizes from 16 to 0. All directory entries were already zero, IMAGE_FILE_RELOCS_STRIPPED remained set, and llvm-readobj continued to recognise the image as COFF x86-64.
A harness including the current common/lib/pe.c produces:
NumberOfRvaAndSizes=16: loaded=1
NumberOfRvaAndSizes=0: panic: pe: NumberOfRvaAndSizes too small for import/reloc directories
Expected behaviour
Treat an import or relocation directory as absent when its index is outside the advertised count. Keep the existing validation whenever an entry is present.
Ownership check
Checked issue assignees and comments, linked and open/draft PRs, searches for NumberOfRvaAndSizes, pe64_load, directory-less PE images, imports and relocations, upstream and recent fork branches, recent commits touching common/lib/pe.c, and maintainer discussions. No matching issue, patch, branch, or active claim was found as of 2026-10-02. Repository Discussions are disabled and the project has no documented mailing-list patch workflow.