News for hackers. Stuff that matters.
Re:The earliest versions of the first C compiler known to exist by ChrisMarshallNY on Monday March 24, 2025 @08:07AM (#43460002)
Re:The earliest versions of the first C compiler known to exist by johnisgood on Monday March 24, 2025 @08:17AM (#43460102)
What is the point of it?
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.
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.
Re:The earliest versions of the first C compiler known to exist by fxtentacle on Monday March 24, 2025 @08:50AM (#43460471)
It's an obscure way to statically allocate memory for the ospace pointer.
Re:The earliest versions of the first C compiler known to exist by account42 on Tuesday March 25, 2025 @05:37AM (#43469437)
What's the advantage over an array though, which would allow you to better control the size without making assumptions about code generation.

edit: http://cm.bell-labs.co/who/dmr/primevalC.html (linked from another comment has the answer):

> A second, less noticeable, but astonishing peculiarity is the space allocation: temporary storage is allocated that deliberately overwrites the beginning of the program, smashing its initialization code to save space. The two compilers differ in the details in how they cope with this. In the earlier one, the start is found by naming a function; in the later, the start is simply taken to be 0. This indicates that the first compiler was written before we had a machine with memory mapping, so the origin of the program was not at location 0, whereas by the time of the second, we had a PDP-11 that did provide mapping. (See the Unix History paper). In one of the files (prestruct-c/c10.c) the kludgery is especially evident.

So I guess it has to be a function in order to be placed in front of main() so the buffer can overflow into the no longer needed code at the start of it.

Re:The earliest versions of the first C compiler known to exist by rasjani on Monday March 24, 2025 @08:28AM (#43460246)
Without actually knowing, i'd guess that would generate bytecode's that could be modified later by patching the resulting binary ?

I remember few buddies using similar pattern in ASM that just added n NOP's into code to allow patching and thus eliminating possible recompilation..

Re:The earliest versions of the first C compiler known to exist by ChrisMarshallNY on Monday March 24, 2025 @08:30AM (#43460284)
I suspect that’s it.

There was a lot of self-modification, going on, in those days. Old machine language stuff had very limited resources, so we often modified code, or reused code space.

Re:The earliest versions of the first C compiler known to exist by agumonkey on Monday March 24, 2025 @08:28AM (#43460247)
warm up the stack ? (no idea to be honest)
Re:The earliest versions of the first C compiler known to exist by tanelpoder on Monday March 24, 2025 @08:29AM (#43460262)
The C alternative for the hardware "halt and catch fire" instruction?
Re:The earliest versions of the first C compiler known to exist by kps on Monday March 24, 2025 @10:55AM (#43461816)
The C alternative for the Fortran COMMON block.
Re:The earliest versions of the first C compiler known to exist by Amlal on Monday March 24, 2025 @12:42PM (#43462947)
Ah, yes, was that because of a lack of inline assembly? I feel like these could be replaced by 'nop' operations.
Re:The earliest versions of the first C compiler known to exist by arp242 on Monday March 24, 2025 @04:06PM (#43464896)
Gotta love the user-friendliness of these old Unix tools:

  if (argc<4) {
      error("Arg count");
      exit(1);
  }
Re:The earliest versions of the first C compiler known to exist by Rendello on Monday March 24, 2025 @07:16PM (#43466423)
SQLite error messages are similarly spartan. I wrote a SQLite extension recently and didn't find it difficult to have detailed/dynamic error messages, so it may have just been a preference of the author.