- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Overriding a function and .so priority setting.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2009 09:08 PM
тАО10-21-2009 09:08 PM
Q1)
Is there a way to override self written functions on HP ux 11.31 ia64?
for example:
in file.c suppose there is function hello()
now I want to override this function which I myself had written by another hello().
System calls can be overrided by using LD_PRELOAD and at run time calling our own .so library.
But the same does notseem work for overriding self written fucntions.
Reason for this:
a particular function was written quite a few years ago .. and now changes cannot be made to it cause many clients have the old version of the function.
So need is to develop a patch with our own new library which overrides the same function.
I have been tryign to fiddle around with "chatr" and using SHLIB_PATH (had got a hint this path might help) but am unable to get the desired results.
Q2)
suppose I have 2 .so
2)lib1.so
2)lib2.so
and the lets say calling function is call.cxx
when I create a executable using the command
gcc -g call.cxx lib1.so lib2.so -o executable
Is there a way to give lib1.so a higer priority than lib2.so so that if there are common functions in lib1.so and lib2.so with similar definitions but different implementations, the fucntion in lib1.so be used and not the lib2.so .
for example:
lib1.so ----> add() // returns 3
lib2.so ----> add() // returns 4
how can i make the executable so that the add() from lib1.so is used?
(trying to override the function this way too :) just an idea though)
Thank you all very much in advance :)
Regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2009 10:45 PM
тАО10-21-2009 10:45 PM
Re: Overriding a function and .so priority setting.
32-bit ELF executable
shared library dynamic path search:
LD_LIBRARY_PATH enabled first
SHLIB_PATH enabled second
embedded path enabled third /usr/local/lib/gcc/ia64-hp-hpux11.23/4.0.2:/usr/ccs/bin:/usr/ccs/lib:/usr/local/lib
shared library list:
./library.so
arbasic.so
libc.so.1
shared library binding:
deferred
global hash table disabled
global hash table size 1103
shared library mapped private disabled
shared library segment merging disabled
shared vtable support disabled
explicit unloading disabled
linkage table protection disabled
segments:
index type address flags size
8 text 04000000 z---c- D (default)
9 data 40010000 ---m-- D (default)
executable from stack: D (default)
kernel assisted branch prediction enabled
lazy swap allocation for dynamic segments disabled
nulptr dereferences trap enabled
address space model: default
caliper dynamic instrumentation disabled
new values:
32-bit ELF executable
shared library dynamic path search:
LD_LIBRARY_PATH enabled first
SHLIB_PATH enabled second
embedded path enabled third /usr/local/lib/gcc/ia64-hp-hpux11.23/4.0.2:/usr/ccs/bin:/usr/ccs/lib:/usr/local/lib
shared library list:
./library.so
arbasic.so
libc.so.1
shared library binding:
deferred
global hash table disabled
global hash table size 1103
shared library mapped private disabled
shared library segment merging disabled
shared vtable support disabled
explicit unloading disabled
linkage table protection disabled
segments:
index type address flags size
8 text 04000000 z---c- D (default)
9 data 40010000 ---m-- D (default)
executable from stack: D (default)
kernel assisted branch prediction enabled
lazy swap allocation for dynamic segments disabled
nulptr dereferences trap enabled
address space model: default
caliper dynamic instrumentation disabled
This is the page that i get when I set the SHLIB_PATH using
export SHLIB_PATH
and then do the
chatr enable +s final (on the ELF file final 32 bit)
but as you see against the SHLIB_PATH , nonew path is set even after setting the SHLIB_PATH.
any ideas why this might be happening?
Regards and thanks :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-22-2009 02:10 AM
тАО10-22-2009 02:10 AM
SolutionWhy not? Note: If your function is called from the same file, you can't override it.
>Is there a way to give lib1.so a higher priority than lib2.so
Only by ordering lib1 before lib2.
On Integrity, you should use LD_LIBRARY_PATH instead of SHLIB_PATH.
>but as you see against the SHLIB_PATH, no new path is set even after setting the SHLIB_PATH.
LD_LIBRARY_PATH amd SHLIB_PATH were already enabled, so chatr did nothing.
You need to export LD_LIBRARY_PATH and see what ldd shows you:
ldd final
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2009 01:24 AM
тАО10-23-2009 01:24 AM
Re: Overriding a function and .so priority setting.
I checked up creating ELf file by changing the order of the .so files and Viola it indeed did work :)
Thanks a bunch. This has made my headache soothe :D
Also LD_PRELOAD did work on hp ux..
Though on AIX LDR_PRELOAD or LDR_PRELOAD64 didnt seem to work.
( am doing the same thing on HP-UX 11.31 AIX 5.3 & solaris 10)
Could you explain the last part about exporting LD_LIBRARY_PATH in a bit more detail please? I didnt seem to get it right..
I had exported SHLIB_PATH.
thanks a lot again.
Was a great help :D
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2009 02:03 AM
тАО10-23-2009 02:03 AM
Re: Overriding a function and .so priority setting.
Which part? Basically SHLIB_PATH is the obsolete PA32 way of doing things whereas LD_LIBRARY_PATH is standard.
If you export them, ldd will tell you which shlibs it will use when you are running the application.
You can read all about ld, dld and shlibs in:
http://docs.hp.com/en/14640/OnlineHelp/linkhelp.html
>thanks a lot again. Was a great help :D
Pleased read the following about how to assign points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2009 02:08 AM
тАО10-23-2009 02:08 AM
Re: Overriding a function and .so priority setting.
:)
LD_LIBRARY_PATH des the trick..
Sorry I thought I had clicked on submit points after I had assignd points :|
Regards