eloranta@tukki.jyu.fi (Jussi Eloranta) (12/23/89)
Hi, Couple of questions: 1) Is it possible to load executable code (one that is linked with ld option -A; at least with BSD systems) to running program and execute it? (I think it is, since KCL is probably doing something like this) 2) Could someone send me a simple example how to do this (on a BSD system; actually SUNOS 4.0.1). Nroff also does this kind of stuff with device driver tables, but in this case it's only data... jussi -- ============================================================================ Jussi Eloranta Internet(/Bitnet): University of Jyvaskyla, eloranta@tukki.jyu.fi Finland [128.214.7.5]
eloranta@tukki.jyu.fi (Jussi Eloranta) (12/27/89)
Thanks to everybody who responsed.
Here is a quick summary what to do (sunos; bsd without static stuff, I guess):
1) find the address of top of mem. (top = sbrk(0))
2) do: ld -Bstatic -N -x -A a.out -T top objfile.o -e _entry -o tmpfil libs.a\
-lc
(-T top specifies the address)
3) read tmpfil header (total size) and allocate space using sbrk(totsize)
4) read the tmpfil in.
5) call header.a_entry ()
If anoyone wants the examples I got I can mail those.
Jussi
--
============================================================================
Jussi Eloranta Internet(/Bitnet):
University of Jyvaskyla, eloranta@tukki.jyu.fi
Finland [128.214.7.5]