zig icon indicating copy to clipboard operation
zig copied to clipboard

Standard library not exposing the type of elf in std.elf.Header

Open Peppy3 opened this issue 1 year ago • 4 comments

As stated in the title, std.elf.Header does not expose the type of the elf file. I think it would be generally useful to expose it in the struct as programs might not be able to use all the types elf provide.

For example, I'm making what I like to call "The Tempinator" (in true Dr. Doofenshmirtz fashion). It injects the use of the temporary registers on RiscV. Both GCC and LLVM does not emit machine code with the temp registers at all (GCC at least tries to but fails with optimizations turned on). The program runs on an object file and a given yaml file with all of the function definitions.

It would be generally useful to have the type of the elf file be exposed in std.elf.Header as it already has a small parsing routine and I wouldn't imagine it being too difficult to add even though some types are OS and ARCH specific.

Peppy3 avatar May 01 '24 13:05 Peppy3

It is not clear to me from the description provided what the issue is.

kubkon avatar May 22 '24 10:05 kubkon

From a quick glance, I guess the issue is that e_type and various e_ident values aren't exposed?

alexrp avatar May 22 '24 10:05 alexrp

From a quick glance, I guess the issue is that e_type and various e_ident values aren't exposed?

The actually useful e_ident fields are exposed. e_type is not though. If anyone wants the raw e_ident they could just parse the file themselves.

Peppy3 avatar May 22 '24 11:05 Peppy3

The actually useful e_ident fields are exposed.

EI_OSABI and EI_ABIVERSION both seem missing?

alexrp avatar May 22 '24 11:05 alexrp