[comp.lang.c] Jumping to data

iwm@asun3.ic.ac.uk (Ian Moor) (09/13/88)

execute permission on your files. 
Think of generate executable == setuid root (sort of).

Do your programs actually poke binary opcodes into memory and jump to
them, or do they have structures with pointers to functions ?  I'm
sure that the compiler will allow pointers to functions that it 
knows it has compiled. If you are actually poking code, have you
considered what happens when you have to move to another machine ?
(I am contemplating trying to debug a program with 'asm' statements
scattered through it -- thats bad enough!)
 

iwm@asun3.ic.ac.uk (Ian Moor) (09/13/88)

>>What's to stop you from doing the following:

>>	Generate code in an array.
>>	Jump to the beginning of the array. *

>IF you can't do this, an entire class of programs
>becomes absolutely impossible: incremental compilers. It would prohibit
>a Turbo C or Quick C clone, for example. All of my programs I have designed
>for teaching chemistry and physics wouldn't work.

There is almost certainly an extended compiler for producing
trusted programs like compilers and protection to stop you setting
execute permission on your files. 
Think of generate executable == setuid root (sort of).

Do your programs actually poke binary opcodes into memory and jump to
them, or do they have structures with pointers to functions ?  I'm
sure that the compiler will allow pointers to functions that it 
knows it has compiled. If you are actually poking code, have you
considered what happens when you have to move to another machine ?
(I am contemplating trying to debug a program with 'asm' statements
scattered through it -- thats bad enough!)
 

peter@ficc.uu.net (Peter da Silva) (09/16/88)

In article <IWM.88Sep13103434@asun3.ic.ac.uk>, iwm@asun3.ic.ac.uk
	(Ian Moor) writes:
> If you are actually poking code, have you
> considered what happens when you have to move to another machine ?

I have poked code in the past, though not in 'C'. I've done it in Fortran
via Forth running under Fortran. If I switch to another environment,
of course, the problems caused by poking code are nothing compared to
redoing the Forth inner interpreter.

And, of course, there's Henry Spencer's famous BitBlt example.
-- 
Peter da Silva  `-_-'  Ferranti International Controls Corporation.
"Have you hugged  U  your wolf today?"            peter@ficc.uu.net