3 ms·
Is there anything I can read to learn more about overlaying in C? I was reading, to my limited abilities' limits, 2.11 BSD source and there was a lot of refere
by cptnapalm 8y ago
Is there anything I can read to learn more about overlaying in C? I was reading, to my limited abilities' limits, 2.11 BSD source and there was a lot of references to overlaying.
- basementcat 8y agoOn a modern POSIX environment, you can hack together an approximation of an overlay by loading some code to an area of memory, mprotect( ptr, len, PROT_EXEC) the segment, ((int(*)())ptr)() to call the function and if you did everything right, you don't segfault too hard. Later, you can overwrite that area of memory with other code and repeat. This is similar to what actually goes on under the hood of the dynamic loader. http://tldp.org/HOWTO/Program-Library-HOWTO/dl-libraries.html http://tldp.org/HOWTO/Program-Library-HOWTO/dl-libraries.htm...
- burfog 8y agoThat is a different sort of overlay, a code overlay. The other example was data, with the compiler assisting by changing local variables to have fixed addresses that get carefully reused for different variables at different times.