Advertisement

dynamic libraries in Linux

Started by November 26, 2003 05:03 AM
1 comment, last by Lorenzo 20 years, 10 months ago
Hi, I''m interested in know how exactly the dynamic libraries works in linux. When and how they are loaded, and expecially what the loader do (function address resolution, which section in the ELF file are read, how is the ELF for an .so organized...) Thank you, help is very appriciated
Hello Lorenzo,

You didn''t ask for enough

Well the way any UNIX that uses the ELF file format is.

Basic very Basic idea here is:

Stored in the share lib is a table of offset to all functions and objects.
When a program is compile against a share library it only get a reference name to the function or object which at runtime the linker will resolve for it.

At run time reference in the program will have the share library use, and the name wanted.
The linker is call to load in the share library into the program memory use.
All references to any functions or objects is resolved before any code is actual executed.

Then after the linker is done the program starts execution, first by initialize all static data members and then enters main function.

Well that the basic idea.

Lord Bart
Advertisement
quote: Original post by Lord Bart

Stored in the share lib is a table of offset to all functions and objects.
When a program is compile against a share library it only get a reference name to the function or object which at runtime the linker will resolve for it.

At run time reference in the program will have the share library use, and the name wanted.
The linker is call to load in the share library into the program memory use.
All references to any functions or objects is resolved before any code is actual executed.

Then after the linker is done the program starts execution, first by initialize all static data members and then enters main function.

Well that the basic idea.

Lord Bart


Ok thanks. Is pretty similar to win32 and to what I tought, execept some terms (dynamic linker vs loader, for example).

What I need to know is _were_ the table that stores the name - address (or name - stub for the function) is in the ELF file. Is it in the program header of the .so? does .so even have a program header?

In PE these infos are in the .export section. What is the equivalent for ELF files? where can I find references for the structs used?

Thanks again
Lorenzo

This topic is closed to new replies.

Advertisement