It only adds a few bytes and is nice for backward compatibility :-)
Details
Diff Detail
- Repository
- rLLD LLVM Linker
Event Timeline
COFF/Writer.cpp | ||
---|---|---|
64 | Maybe it's easier to make it always 64-byte long and use sizeof(DOSProgram) instead of alignTo() static unsigned char DOSProgram[64] = { ... }; | |
692–696 | It's perhaps better to expand this comment a bit so that the thing we are doing here is not important to understand the linker itself -- it's just a small DOS program at beginning of every PE/COFF executable to help DOS 2.0 (!) users that the program needs Windows. | |
700 | The buffer is a new mmap'ed file, so it is guaranteed to be zero-initialized. (The situation is different for ELF executable sections because we write INT3 or equivalent before writing anything to that regions, but that's not relevant here because this is COFF header.) |
COFF/Writer.cpp | ||
---|---|---|
64 | That seems wasteful since the program doesn't need 64 bytes (and it seems fragile in case it would ever change and require more than 64 bytes). A better idea I think would be to put an align 8, db 0 directive in the asm above to pad the program itself to a multiple of 8. That way we're not wasting bytes, it won't break if someone changes the program, and it simplifies the lld code a little. What do you think? |
Thanks! I'll make the change and commit.
COFF/Writer.cpp | ||
---|---|---|
692–696 | I've expanded the comment to explain. |
Grateful for ideas on how to format/do this better.