Re:The earliest versions of the first C compiler known to exist
by aap_ on Monday March 24, 2025 @08:36AM
(#43460333)
It's an awkward way to reserve memory. The important detail here is that both compiler phases do this, and the way the programs are linked guarantees that the reserved region has the same address in both phases. Therefore an expression tree involving pointers can be passed to the second phase very succinctly. Not pretty, no, but hardware limitations force you to do come up with strange solutions sometimes.
[ Parent
| on HN ]
Re:The earliest versions of the first C compiler known to exist
by colejohnson66 on Monday March 24, 2025 @09:58AM
(#43461188)
Here's the actual code that references the 'ospace' from before 'waste': https://github.com/mortdeus/legacy-cc/blob/936e12cfc756773cb...
Re:The earliest versions of the first C compiler known to exist
by johnisgood on Monday March 24, 2025 @09:01AM
(#43460588)
Thank you! Is it relevant today at all, or is there an use-case for it today?
Re:The earliest versions of the first C compiler known to exist
by aap_ on Monday March 24, 2025 @09:07AM
(#43460634)
No, if you need fixed addresses i suppose a linker script would be the way to go? Or in this case you'd just serialize the data such that it doesn't contain any pointers in the first place.
Re:The earliest versions of the first C compiler known to exist
by ddulaney on Monday March 24, 2025 @03:36PM
(#43464648)
If you even can with ASLR. Most modern boxes would disable stuff like this.
Re:The earliest versions of the first C compiler known to exist
by mananaysiempre on Monday March 24, 2025 @06:49PM
(#43466212)
There are better tools to do this these days—with the GNU toolchain, for example, you’d use a linker script and make sure you’re building a non-position-independent static executable. Alternatively, you could use self-relative pointers: instead of having foo_t *foo and putting p there, have ptrdiff_t foo and put ((char *)p - (char *)&foo) there.