specify load address for shared objects on solaris

Hi all
On NT you can use the Rebase tool for specifiying a default loading address for dlls. This can speedup startup time because the dlls don't have to be rebased.
Is there anything similar on solaris.
Who is Participating?
elfieConnect With a Mentor Commented:
What do mean by shorter startup time?

There are at least two things to consider

First: What it the time it takes to execute the very first statement in your source? If this takes to long time to execute, may be you must think about splitting up your code into different programs, or -just remembered it while writing this.

vvv solution in next lines ??? vvv

When you use shared libraries, make ABSOLUTELY SURE that the file permissions for all users are set the same. The best possible setting is r-xr-xr-x. If the setting are different eg. rwxr-xr-x, then when the owner is executing the code, and another user wants to execute the same code a whole lot of checkings must be done to see if the page has not been changed, and a lot of other stuff. If you set all to r-xr-xr-x, just some simple tests are performed. If set to something like r-xr-x---, even then a lot test are (were?) done to verify that the pages, when in memory, are still valid.

So first try setting all used shared libraries to file permission  555 (r-xr-xr-x).

Second: it's also possible that the program starts fast enough, but that the first part of the user code, before seeing some user screen takes too long. In this case check the used algorithms.

In older unix version the sticky bit could be used for keeping programs/libraries in memory, but since swapping and paging has been improved i'm not aware of any systems (unix) that still uses this kind of stuff.
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

gadiiAuthor Commented:
There are two stages two this problem.
1. How do I create the shared object so all the funtion calls
and variable refrences will be relative to an address I want
2. After the shared object is created how do I load it and execute the code at that specific area.

1. if there are variable references, you have to adjust them yourself
2. mmap()

How it works please refer to  man mmap.
As far as I understand, what you want to do is simply using static libraries.
Dynamic libs only make sense if you use PIC, but that's what you not want, so
fall back to static libs, which won't have the performance penalty at startup.
If on Unix you are using libraries, the usage is transparent.

If you use static libraries, the code is put inside your program, and the  place where variables are put depends on where your program is loaded. If you're using shared libraries, it depends on how your 'dynamic linking' mechanism works.
I know on HP they are working with a TLB (Transition Lookaside Buffer) that assign to each object running/loaded object a logical address that will be translated in the TLB into real memory addresses. So here program can 'see' the same logocal address, but still can have different physical addresses.

Can explain why you want to know the addresses?
If you want to store addresses of functions, or pass them between processes, DON'T. If you still want to do it, you must be very well aware that each os system (and every release) uses his own method. If you just want to creat shared object, compile with the option PIC (check your compiler for Position Independent Code), and then build your library with the ld command, using the correct options (-b on HP i believe)
would be nice to see a comment when rejecting
gadiiAuthor Commented:
yes I am sorry, for not adding a comment.
I was just hopping there was some automated way to this
which woldn't require lots of code chages. Some linker option
or some post link utility that exists on NT.

some of us is missunderstanding something: you don't need to change code if you use static libs (static and dynamic shared objects are compiled from the same code on UNIX).
gadiiAuthor Commented:
The problem is we can't easly switch to static libraries,
we need a solution which reduces the startup time for shared

If some one knows for a fact that this is a dead end route or knows about any other ways to shorten startup time please speak up.

Regards Gadi
If you just care about startup time of your program *and* you're shure that it is
because of the shared libs, then check fiollowing (elfie's answer still in mind):

  1) check your LD_LIBRARY_PATH; reduce to necessary dirs only or unset
  2) make shure your shared libs are on a local filesystem
  3) read man-page of ld, especially following options:
       -b -i -B symbolic -R path -Y P,dirlist
gadiiAuthor Commented:
Ok thanks alot guys I will try this out.
and let you know how it worked out

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.