News for hackers. Stuff that matters.
Re:Zig's New Relationship with LLVM by wycy on Monday September 28, 2020 @10:26AM (#24616924)
Is a patched in-place binary identical to the binary that would be generated from a clean compilation?
Re:Zig's New Relationship with LLVM by alexnask on Monday September 28, 2020 @01:28PM (#24619095)
No, some parts of the binary file will be unused in the final executable if you keep updating it incrementally.

The linkers will do what they can to reuse all previously freed blocks of the file, but you can imagine a scenario where a function is updated but does not fit in the block that was previously allocated for it. In this case, a new block of the file will be allocated for this function.

If you then add a smaller function, it will occupy some portion of the old block. You can keep adding things into this block until some minimum amount of memory is reached (and as long as the declarations fit in there, obviously).

Repeating this process for all new declarations and for all the modifications of declarations, you can imagine some parts of the files will remain unused.

I hope this makes sense :)

Re:Zig's New Relationship with LLVM by kevsim on Monday September 28, 2020 @12:56PM (#24618717)
Doesn't sound like it. Seems like it appends the new versions of the functions and updates the global offset table.
Re:Zig's New Relationship with LLVM by alexnask on Monday September 28, 2020 @01:38PM (#24619220)
Not quite, the linkers (at least ELF and PE which I am familiar with) will "free" parts of the file (when a block needs to be reallocated because the decl code gets too big, or when a decl is removed) and reuse them when they can.

But in general, the final executable will not be the same, this is correct.

Re:Zig's New Relationship with LLVM by kevsim on Monday September 28, 2020 @02:41PM (#24619930)
Thanks for clarifying!