Aliasing text and data segments of a process
Doug Gwyn
gwyn at brl-smoke.ARPA
Sat Jan 30 07:37:01 AEST 1988
In article <459 at minya.UUCP> jc at minya.UUCP (John Chambers) writes:
>> From: Doug Gwyn <gwyn at brl-smoke.arpa>
>> > This cannot possibly work on an architecture that enforces the
>> > distinction between Instruction and Data spaces.
>I tried it out on a PDP-11/75 that I had handy. The machine definitely had
>separate I and D spaces, and the program quite definitely worked. I didn't
>tell the compiler anything special, and I doubt the linker recognized that
>_main was special and belonged in I space. But neither the compiler nor the
>linker was fazed by having main as a data array.
You don't listen very well, do you? Just because the underlying hardware
CAN enforce the distinction between I&D space doesn't mean that it always
DOES so. In fact, the usual UNIX C implementation for a PDP-11 defaults
to a single shared address space, and only programs that need more space
(such as the f77 compiler) request split I&D spaces by specifying the
cc -i option when linking. Try running these example programs with I&D
separation enforced, AS I SPECIFIED, and see what happens.
As someone (rbj?) said, the PDP-11 isn't the best example, due to its being
possible to set it up to blur the I&D distinction by default. (Some cheaper
models couldn't be set up to enforce the distinction!) I used the PDP-11 as
an example because it seemed the machine you were most likely to have access
to. I have seen segment-based architectures (Burroughs B5500 comes to mind)
where the default behavior is to enforce the distinction, and I would be
very surprised if IBM's System/38 or the H-P 3000 didn't also do so.
The way to understand an issue is not to resort to blind experiments.
More information about the Comp.unix.wizards
mailing list