Solved

specify load address for shared objects on solaris

Posted on 1998-11-09
12
238 Views
Last Modified: 2013-12-27
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.
10xs,Gadi
0
Comment
Question by:gadii
  • 5
  • 4
  • 3
12 Comments
 
LVL 3

Expert Comment

by:elfie
ID: 2007704
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.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2007705
mmap()
0
 

Author Comment

by:gadii
ID: 2007706
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.

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2007707
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.
0
 
LVL 3

Expert Comment

by:elfie
ID: 2007708
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)
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2007709
would be nice to see a comment when rejecting
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:gadii
ID: 2007710
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.

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2007711
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).
0
 

Author Comment

by:gadii
ID: 2007712
The problem is we can't easly switch to static libraries,
we need a solution which reduces the startup time for shared
libraries.

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
0
 
LVL 3

Accepted Solution

by:
elfie earned 270 total points
ID: 2007713
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.



0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2007714
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
 
0
 

Author Comment

by:gadii
ID: 2007715
Ok thanks alot guys I will try this out.
and let you know how it worked out




0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now