This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Main in Lib


Hi Bharathi,

> What is need to create this two type of lib formats ?

To create libfoo.a from alpha.o beta.o gamma.o:

ar -r libfoo.a alpha.o beta.o gamma.o

To create libfoo.so from alpha.o beta.o gamma.o:

gcc -shared -o libfoo.so alpha.o beta.o gamma.o

> How to differentiate DSO and SSO ?

The application is linked against .so files with SSO.  You can see the
libraries via "ldd application" and it will display the SSO .so
dependencies.

The application explicitly opens (via dlopen) .so files with DSO.

> ( .so = DSO and .a = SSO  Correct ? )

No.  Both DSO and SSO are .so libraries.

> Objdump libfoo.so gave a start address. If it is ordinary program,
> the start address refer to main function. In lib start add refer
> to what ?

To the memory address that the shared object library file is located at,
that will probably need to be relocated.  That's why object files in a
shared object (.so) library should be compiled with -fpic or -fPIC, so that
they are easily relocatable.

> what is the use of _fini ,  _init , fini_dummy etc ?

I presume that _init (or INIT or .init) is used to initialize the shared
object library.  Such as calling any constructors that need constructing,
setting up the .bss and .data segments (or are those handled by the
loader?), et cetera.

And I presume that _fini (or FINI or .fini) is used to tear down the shared
object library.  Calling destructors on global and static objects, et
cetera.

I don't know what fini_dummy is used for.

Sincerely,
--Eljay


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]