HELP:cant call functions dynamically via nlist!?

HELP:cant call functions dynamically via nlist!?

Post by Keith Bedfo » Sat, 20 Mar 1993 16:33:54

I have some 'System V' code to port to the RS6000 that makes dynamic function
calls, ie it uses nlist(3) to search its own symbol table at run time for a
named function and directly calls the address returned by nlist.

This process fails because the RS6000 nlist appears to return a value for the
symbol that is an offset into the data segment (probably into the TOC), which
when dereferenced should give the address of the function. At least it does in

Unfortunately when my code dereferences the pointer I get 0, probably because
my address is treated as an offset from the beginning of segment 2 (private)
rather than from the origin of my data section?

I can find no answers in info, or the man pages or the system headers so does

1) Know how to call function addresses returned by nlist?


2) Know how to read explicit locations from the (local) data section?

Thanks in advance for any help.


  Bull Information Systems
  Maxted Road  -  UK03-HM14
  Hemel Hempstead
  Herts  HP2 7DZ                Tel:    +44-442-88 4250
  England                       Fax:    +44-442-88 4570

  "The future ain't what is used to be!"


1. dynamically calling functions

What I would like to do is be able to call a function in a library
without it being named in the
source file.  For example:

        printf("test> ");
        for(trav=str; (!isspace(*trav)); ++trav);
        strncpy(cmd, str, (trav - str));
        cmd[trav-str] = 0;
        strcpy(arg, trav + 1);
        /* command here */

when run:

test> puts hello

would dynamically find the function "puts" and call it to print out
I DO NOT want to put a switch with every system call in it.  I do not
if it is a non-portable solution such as manually look through a library
and write assembly to put the arguments on the stack.

Thank you


2. Lecteur CD-ROM

3. how to know the instruction address of calling function within called function?

4. S3 Virge/DX

5. Browser calls CGI C function which sets an env var and call a c function crashes

6. boot procedure: ethernet startup not working (pcmcia)

7. C programming question: Calling a variadic function where the args come in via an array

8. Offer for free network device monitoring NOT SPAM

9. nlist function.

10. Call function within a function

11. Tree of Functions calling Functions etc.

12. Main function calling another main function

13. Need utility to trap network function calls (socket calls) and save to log file