Aliasing text and data segments of a process

Doug Gwyn gwyn at brl-smoke.ARPA
Mon Jan 25 09:54:07 AEST 1988


In article <452 at minya.UUCP> jc at minya.UUCP (John Chambers) writes:
>In article <7156 at brl-smoke.ARPA>, gwyn at brl-smoke.ARPA (Doug Gwyn ) writes:
>> In article <730 at umbc3.UMD.EDU> alex at 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.



More information about the Comp.unix.wizards mailing list