In the process of writing an archiver (the llvm-ar) in Zig, I needed to iterate over an objectfiles Symbols, in order to create a Symboltable. While std.coff, std.elf and std.macho already provide most of the structs a programmer might need, the necessary functions were lacking in part. I started to wonder what functions and definitions std.coff, std.elf and std.macho are intended to provide and whats left for the programmer to implement themselves OR what simply is missing because nobody needed added it so far.
Let me explain by taking a look at std.coff.Coff:
std.coff.Coff already provides lots of methods for working with PE files, it even allows you to retrieve the StringTable, Symboltable and work with the data stored in a PE file. But also was a problem for me, because the objectfiles emitted by build-lib are not of that type.
So while I could learn from and adopt much of the logic used in std.coff.Coff, I also head to reimplement most of what I needed because straight up Header lead Coff files, were not supported by the std lib.
So I hastly wrote a workaround I am not proud of, featuring things like
fn getRvaPtr
fn getMachine
fn initSymtab
etc. by copying code I could not use directly. This is especially true for the SymboIterator
So what this question or post is about:
What kind of methods and structs are std.coff, std.elf and std.macho supposed to provide?
Is this a design decision around “just” providing a basis of structs.and leaving implementations of methods to users, OR has just nobody provided the PR’s to extend std in this area yet and such PR’s (providing SymbolIteration) would be welcome if they fit the required level of professionalism?