What happens when linking and execution?

"JNLSeb" <jnlseb@earthlink.net>
Thu, 15 May 2008 19:28:33 -0400

          From comp.compilers

Related articles
What happens when linking and execution? jnlseb@earthlink.net (JNLSeb) (2008-05-15)
| List of all articles for this month |
From: "JNLSeb" <jnlseb@earthlink.net>
Newsgroups: comp.compilers
Date: Thu, 15 May 2008 19:28:33 -0400
Organization: Compilers Central
Keywords: linker, question
Posted-Date: 15 May 2008 20:16:26 EDT

Let's say I have a shared library (libmyFile1.so) that contains a
function myFunc1 and it is called by a application myApp1.


I build and link the application....
cc -o myApp1 myApp1.o -L/usr/source/lib -lmyFile1


Question 1
------------------
What does this linking actually do?
Does it copy the location of myFunc1 within the libmyFile1.so?




I know if doesn't copy the actual code from the shared library unless
I am linking statically. This leads me to my next question. Lets say
I make numerous changes to the underlying code within libmyFile1.so,
but no changes to the function name myFunc1 or any changes to the
parameters.


Question 2
-------------
Can I not just replace libmyFile1.so with a newly rebuilt one without
having to relink or rebuild the original application? Is there any
scenario where only the underlying code is modified that would require
a rebuild or relink of the application?
[1: ELF linkers just note the names of the symbols to be resolved and
the places in the executable where they're referenced. The actual locations
are resolved at dynamic link time when the executable starts.


2: So long as the interfaces don't change, i.e., number and types of
arguments, you should be able to build a new library and just use it.
If you change the code so that, e.g., an int argument changes to float,
you'll have to rebuild both sides.


See my book for more info. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.