Basic and Advance C Question:
Download Questions PDF

How can I read in an object file and jump to locations in it?

Answer:

You want a dynamic linker or loader. It may be possible to malloc some space and read in object files, but you have to know an awful lot about object file formats, relocation, etc., and this approach can't work if code and data reside in separate address spaces or if code is otherwise privileged.
Under BSD Unix, you could use system and ld -A to do the linking for you. Many versions of SunOS and System V have the -ldl library containing routines like dlopen and dlsym which allow object files to be dynamically loaded. Under VMS, use LIB$FIND_IMAGE_SYMBOL. GNU has a package called ``dld''.

Download C Programming Interview Questions And Answers PDF

Previous QuestionNext Question
How can I implement a delay, or time a users response, with sub-second resolution?Is exit(status) truly equivalent to returning the same status from main?