Path: utzoo!mnetor!uunet!husc6!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: <7175@brl-smoke.ARPA> Date: 24 Jan 88 23:54:07 GMT References: <202@sdti.UUCP> <730@umbc3.UMD.EDU> <7156@brl-smoke.ARPA> <452@minya.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 37 In article <452@minya.UUCP> jc@minya.UUCP (John Chambers) writes: >In article <7156@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes: >> In article <730@umbc3.UMD.EDU> alex@umbc3.UMD.EDU (Alex S. Crain) writes: >> >loads the .o file as data, and then branches to the start of the text area >> >of the .o file >> This cannot possibly work on an architecture that enforces the >> distinction between Instruction and Data spaces. >Jeez, why do they let such obvious non-wizards post responses to >unix.wizards? (:-) There have been far too many such comments from >people who obviously haven't RTFM, in this case K&R. This issue has nothing to do with K&R. It has to do with hardware realities. If the I&D space distinction is enforced, as it is for example using "cc -i" on PDP-11s, then it is indeed impossible to execute anything out of data space. In fact, for such PDP-11s, the same range of addresses mean two totally different things, depending on whether data is being accessed or an instruction is being fetched for execution. >Study the following program, which should work anywhere you have >a C compiler. Your example takes an I-space address, stashes it in a pointer (of inappropriate type, but that's not the issue here), then invokes an already-compiled function (which lives in I-space) using it. Of COURSE you can invoke an I-space function via a pointer. That is NOT AT ALL the same as what was requested, which was to invoke a portion of D-space as a function. THAT cannot be done on a split=I&D PDP-11, for example. Different physical memory locations correspond to an I-space virtual address and the SAME NUMERICAL VALUE as a D-space virtual address. If you still don't understand this, go find a split I&D PDP-11 and play with it for a while, or contact me for clarification, rather than spreading erroneous information across the net.