3 ms·
> If you append data to an executable there is no guarantee it's actually going to end up mapped in memory for you. I didn't state it clearly enough, but I did
by kazinator 7y ago
> If you append data to an executable there is no guarantee it's actually going to end up mapped in memory for you.
I didn't state it clearly enough, but I didn't say anything about it being mapped. It almost certainly isn't mapped. Loaders do not blindly map the whole thing to memory; then you would end up with debug info unconditionally mapped.
Even if it were mapped, the program wouldn't easily find it with the latter approach I described: the offset given in the structure is measured from the start of the file, not from some address in memory.
> ask the linker
It is not portable either. For instance, it doesn't work with Microsoft's linker which is called link.exe.