Extracting native code from C

Lex Spoon lex at cc.gatech.edu
Thu Mar 14 04:12:20 UTC 2002


"Richard A. O'Keefe" <ok at cs.otago.ac.nz> wrote:
> Anthony Hannan <ajh18 at cornell.edu> wrote:
> 	Below is a small C program that copies some of its machine code to
> 	dynamic memory and executes it.
> 
> The code happens to work on *86 machines.  It will NOT work on most of
> the machines that GCC supports.  Issues include
>  - alignment; *86 code is NOT made of ints, it is made of bytes, but
>    the *86s have relatively cheap misaligned loads and stores.  Some
>    machines have code made of bytes or shorts, but no or expensive
>    misaligned int loads and stores.


A simple thing that would be widely portable is to compile a shared
library using libtool and gcc, and then to load the shared library using
the plugin mechanism.  It probably even works on MS Windows and Mac
OS/X.


-Lex



More information about the Squeak-dev mailing list