Dynamic Loading

Gil Tene devil at techunix.BITNET
Sat Sep 8 08:21:36 AEST 1990


In article <HALLETT.90Sep6142725 at enterprise.positron.gemed.ge.com> hallettJ at geme
d.ge.com writes:
>
>I'm interested in doing something funky.  I have a shell running that
>basically interprets user commands and then calls a procedure to
>handle the command.  Each command is self-contained.  Now, I want to
>allow a user to add commands.  The mechanism I would like to try is to
>have the user create a .o file with the compiled code in it, then,
>when he enters his command into the shell, have the shell load the .o
>file and execute the code in it.  The only problem is that I don't
>have a clue where to look to figure out how to do this.
>

Look up the "-A" option in the ld(1) man page. This option lets
you take a .o file, and link it to an existing a.out format file
(executable). The result is a code file that you can load into
memory, and jump into. I have some example code (not well commented)
that does this, if you are interested.

Beware : some unix systems DO NOT have this feature. I am sure it
works in BSD and SunOS, but I have checked DG/UX on an Aviion
(as an example), and it has no -A option to ld.

BTW : This ld -A option is called "incremental" loading. "Dynamic"
loading is a term used concerning run-time and shared library loads.
(At least that's the BSD and SunOS terminology).

Hope this helps,

Gil.
--
--------------------------------------------------------------------
| Gil Tene                      "Some days it just doesn't pay     |
| devil at techunix.technion.ac.il   to go to sleep in the morning."  |
--------------------------------------------------------------------



More information about the Comp.unix.programmer mailing list