Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

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.


On 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.htm...


That 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: