creating new shared object from existing shared objects ??

creating new shared object from existing shared objects ??

Post by Sandeep Grove » Wed, 15 May 2002 15:26:04



Hi all.

I have two existing shared objects (and no source code and .o for them)..
Can I create my new .so/.sl using the two already existing shared objects..

Thanks
Sandeep

--
What you do today is getting you closer
to what you want to be tommorow !

http://www.atrenta.com  // Streamlining Electronic Design

 
 
 

creating new shared object from existing shared objects ??

Post by Paul Pluzhniko » Wed, 15 May 2002 15:55:38



> I have two existing shared objects (and no source code and .o for them)..
> Can I create my new .so/.sl using the two already existing shared objects..

AFAIK, there does not exist a way to do this
on any UNIX except AIX (on which it is trivial -- just
relink the 2 shared objects together with proper export and
import definitions).

Cheers,

 
 
 

creating new shared object from existing shared objects ??

Post by Sandeep Grove » Wed, 15 May 2002 16:06:58


Quote:>>I have two existing shared objects (and no source code and .o for them)..
>>Can I create my new .so/.sl using the two already existing shared objects..

>AFAIK, there does not exist a way to do this
>on any UNIX except AIX (on which it is trivial -- just
>relink the 2 shared objects together with proper export and
>import definitions).

Is there some techincal issue involved in not supporing this ??

Quote:

>Cheers,

--
What you do today is getting you closer
to what you want to be tommorow !

http://www.atrenta.com  // Streamlining Electronic Design

 
 
 

creating new shared object from existing shared objects ??

Post by Paul Pluzhniko » Wed, 15 May 2002 23:37:53



> >>I have two existing shared objects (and no source code and .o for them)..
> >>Can I create my new .so/.sl using the two already existing shared objects..

> >AFAIK, there does not exist a way to do this
> >on any UNIX except AIX

> Is there some techincal issue involved in not supporing this ??

Yes. Doing this on e.g. ELF platform requires that
contents of numerous object file sections be merged
in non-trivial ways, hash tables rebuilt, etc.

All this work, and what is the gain?
Most of the time the builder of A.so and B.so has all the
objects available to him, so he can simply link AB.so from
them if desired.

Cheers,

 
 
 

1. Problem: shared object loading runs constructor of a static object, but static linkage does not.

(Platform:  Solaris with gmake and native Sun C++ compiler)

Problem:  If I create a shared object (.so file) and load it into a
executable, the loader correctly runs constructors of static objects in
the .so file.  But if I link the same code statically, with no shared
object, then the constructors don't run at all!

 Why??

Here's an example:

<file AnnounceConstruction.cpp>

#include <iostream> //for cout
#include <ostream>  //needed for cout linkage

class AnnounceConstruction
{
public:
   AnnounceConstruction()  { std::cout << "AnnounceConstruction
constructed." << std::endl;  }

AnnounceConstruction _static_AnnounceConstruction_instance; //The
static object

<file main.cpp>
#include <iostream> //for cout
#include <ostream>  //needed for cout linkage

int main()
{
    std::cout << "main() has run." << std::endl;

# Now I compile AnnounceConstruction.cpp into an archive, link
statically, and show that the constructor of AnnounceConstruction does
not run.

staticdynamic> CC -c  AnnounceConstruction.cpp -o
obj/AnnounceConstruction.o
staticdynamic> CC -xar -o AnnounceConstruction.a
obj/AnnounceConstruction.o
staticdynamic> CC main.cpp -Bstatic AnnounceConstruction.a -o test.out
staticdynamic> ./test.out
main() has run.
staticdynamic>

# This time, I compile AnnounceConstruction.cpp into a shared object,
link, and show that the constructor runs correctly.
staticdynamic> CC -G obj/AnnounceConstruction.o -o
AnnounceConstruction.so
staticdynamic> CC main.cpp -L. -Bdynamic AnnounceConstruction.so -o
test.out
staticdynamic> export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
staticdynamic> ./test.out
AnnounceConstruction constructed.
main() has run.
staticdynamic>

Can anyone explain this?   It seems as though the symbols of the .a
archive are not finding their way into the statically-linked
executable, but I don't understand why:

staticdynamic> dump -t test.out |grep Announce    #after statically
linking
staticdynamic> dump -t *.a |grep Announce
AnnounceConstruction.a[AnnounceConstruction.o]:
[1]      0x0         0        4         0       0       0xfff1
AnnounceConstruction.cpp
[5]      0x48        64       2         0       0       0x2
__1cUAnnounceConstruction2t6M_v_
[6]      0x48        64       2         0       0       0x2
__1cUAnnounceConstruction2t5B6M_v_
[14]     0x0         1        1         1       0       0x3
_static_AnnounceConstruction_instance
staticdynamic>

2. X on CD-GL6440 ?

3. error in loading shared libraries: libXmu.so.6: cannot open shared object

4. Teardrop Patch

5. semaphors & memory share & object share

6. NCSA httpd1.5.1 process owner

7. Diff between Shared Object & Shared Lib

8. Installing linux on UDMA66 hard drive

9. shared data section in shared objects on AIX

10. Can I add files to an existing shared object?

11. Linker error when creating shared objects under Solaris2.5

12. Creating Shared Libs Objects

13. creating a "closed" shared object