-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
As things stand, std.elf could be used to parse ELF files at comptime, if not for the argument types of std.elf.Header.iterateSectionHeaders
and std.elf.Header.iterateProgramHeaders
. Both functions require a *std.fs.File.Reader
, which can only be created from an actual file. This prevents their use in comptime contexts.
The only real blocker is the seekTo
requirement. If the code accepted a generic reader instead, it could be used independently of files and work at comptime as well.
I have a concrete use case: I'm writing a BPF program loader where the BPF program itself is written and compiled in Zig. If the loader could read the resulting ELF at comptime, it could extract BTF info and generate types from it during compilation.
I'm willing to submit a PR if this change is accepted, but I’d need guidance, mainly on whether a generic seekable reader abstraction exists, or how that should be represented.