Partial application in C
Barnacle Wes
wes at obie.UUCP
Tue Jun 28 11:16:49 AEST 1988
>From article <3353 at cognos.UUCP>, by jimp at cognos.uucp (Jim Patterson):
> there are machines that don't allow you to execute data as
> code.
In article <619 at goofy.megatest.UUCP>, djones at megatest.UUCP (Dave Jones) replies:
% I began to wonder why such a restriction might be deemed necessary.
% Was it Big Brother engineering? -- Thou shalt not modify thy
% executable, for it is a Bad Thing. -- Or is there a valid technical
% reason behind it? I can see one possible rationale: You can have 128KB of
% memory in a sixteen bit machine, divided evenly between data and code,
% if you use all the addresses for both kinds of memory.
This is called `Split I & D space' in PDP-11 vernacular. Many other
machines have similar features - the '286 for instance.
Every segment on the 286 (in 286 mode, of course) has a descriptor.
Each descriptor has a byte, called the Access Rights Byte, that
contains protection bits for the segment. Bit 4 is the 'executable'
flag; if 0, this is a Data Segment Descriptor, if 1, this is a
Executable Code Segment Descriptor.
Now, if this is a Data Segment Descriptor, bit 1 describes whether
this segment is read-only (0), or read-write (1). If, on the other
tentacle, this is an Executable Code Segment Descriptor, bit 1
describes whether the segment can be read (1) or not (0). You cannot
write to an Executable Code Segment! The system, of course, loads a
program as data segments and then modifies the segment descriptors to
make them executable.
I hope this wasn't hopelessly overboard - looking a real data (even if
it is for a brain-dead cpu like the 286) makes things look a little
clearer to me.
--
{uwmcsd1, hpda}!sp7040!obie!wes | "If I could just be sick, I'd be fine."
+1 801 825 3468 | -- Joe Housely --
More information about the Comp.lang.c
mailing list