4 ms·
This isn't portable. Executable files aren't binary blobs, they're a structured format. If you append data to an executable there is no guarantee it's actually
by marcan_42 7y ago
This isn't portable. Executable files aren't binary blobs, they're a structured format. If you append data to an executable there is no guarantee it's actually going to end up mapped in memory for you. You'd have to put it into an actual ELF segment, and at that point you're back to using the linker.
It's a lot more sensible to ask the linker to do this as in OP than to hack together something like you've described.
- 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.