ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
33.61k stars 2.46k forks source link

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

Open Peppy3 opened 4 months ago

Peppy3 commented 4 months ago

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.

kubkon commented 3 months ago

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

alexrp commented 3 months ago

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

Peppy3 commented 3 months ago

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.

alexrp commented 3 months ago

The actually useful e_ident fields are exposed.

EI_OSABI and EI_ABIVERSION both seem missing?