Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!nrl-cmf!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.unix.wizards Subject: Re: Aliasing text and data segments of a process Message-ID: <7208@brl-smoke.ARPA> Date: 29 Jan 88 21:37:01 GMT References: <11476@brl-adm.ARPA> <459@minya.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 26 In article <459@minya.UUCP> jc@minya.UUCP (John Chambers) writes: >> From: Doug Gwyn >> > 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.