4 ms·
The fixed-location variable allocation strategy the author mentions is called overlaying or compile-time stack[0]. It's still very much alive today, thanks to a
by kosma 8y ago
The fixed-location variable allocation strategy the author mentions is called overlaying or compile-time stack[0]. It's still very much alive today, thanks to architectures like 8051 that are not really stack-friendly (even though they do have a stack).
> The Keil C51 C Compiler works with the LX51 Linker to store function arguments and local variables in fixed memory locations using well-defined names
[0] http://www.keil.com/support/man/docs/bl51/bl51_overlaying.htm http://www.keil.com/support/man/docs/bl51/bl51_overlaying.ht...
- cptnapalm 8y agoIs 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.
- chaosite 8y agoMaybe this weird strategy exists elsewhere, but he's supposedly teaching Borland Turbo C with the small memory model. That compiler uses a run-time call stack.