- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: lazyload of
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
Forums
Discussions
Discussions
Discussions
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
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
02-18-2004 08:40 AM - last edited on 03-29-2013 12:31 AM by Cathy_xu
02-18-2004 08:40 AM - last edited on 03-29-2013 12:31 AM by Cathy_xu
Assume the following shared library (testlib.c)
#include <STDIO.H>
#include <STDLIB.H>
extern int fct1(void);
int fct2(void);
int fct1() {
#ifdef x1
printf("x1\n");
#else
printf("x2\n");
#endif
return fct2();
}
int fct2() {
#ifdef x1
printf("x1\n");
return 11;
#else
printf("x2\n");
return 22;
#endif
}
> aCC +z -b -o x1 -Dx1 testlib.c
> aCC +z -b -o x2 testlib.c
and the following executable (testx.c)
/* testx.c */
#include <STDLIB.H>
#include <STDIO.H>
#include <STRINGS.H>
#include <UNISTD.H>
extern int fct1(void);
int main(int ArgC,char *ArgV[]) {
/*------------------------------------------*
! Remove existing copy of libx.so softlink !
*------------------------------------------*/
remove("libx.sl");
/*------------------------------------------*
! create new instance of libx.so softlink !
*------------------------------------------*/
symlink(((ArgC > 1) &&!strcmp("x1",ArgV[1])) ?
"x1" : "x2","libx.sl");
printf("fct2=%d\n",fct1());
}
> ln -fs x2 libx.sl
> aCC -o testx -L. -lx testx.c
If I build these same executables on a Sun 5.7 system using CC and specifying
> CC -o testx -zlazyload -L. -lx test.C
running "testx1 x1" will *always* produce the output
x1
x1
fct2=11
even if the softlink starts off as "libx.so -> x2", verifying that the lazyload binding for fct1() has indeed occured as expected (and as I
need it to).
However, under HP-UX, if the softlink again starts off as "libx.so -> x2", running "testx
x1" will initially result in
x2
x2
fct2=22
and then on subsequent runs
x1
x1
fct2=11
This appears to me that the lazyload binding of fct1() is *not* occuring; i.e. the new softlink for libx.so to x1 is not being picked up until
the next invocation of "testx x1".
According to the documention, lazyload binding should be the default; I've tried adding the -Wl,-Bdeferred" switch with the same results.
Am I missing something, or doing something wrong? Shouldn't this work as the same on Solaris and HP-UX?
Moved from HP-UX Technical Documentation to HP-UX > languages
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 12:38 AM
02-19-2004 12:38 AM
Re: lazyload of
#include
#include
extern int so_fct(void);
int main() {
system("sleep 30");
printf("so_fct=%d",so_fct);
}
> aCC -o testx -L. -z -Wl,-Bdeferred -lx testx.c
The function so_fct is part of the libx.sl shared library. According to my understanding of things, libx shouldn't be loaded until the so_fct is actually referenced. If I start this test program then issue an "fuser -u libx.sl" before the sleep expires, I get
libx.sl: ####m(userid)
showing that libx has already loaded *before* the reference to so_fct has occured. Isn't this counter to the way lazyload should work?
If I try this on a Solaris system, fuser shows that libx is not loaded until so_fct is actually referenced, which is what I want.
Am I misunderstanding how Lazyload should be working? Is there someway to resolve this (i.e. not have libx loaded until so_fct is
referenced)? I'm having the same problem on HP-UX, so perhaps Solaris is the *only* system that properly implements lazyload???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 01:00 AM
02-19-2004 01:00 AM
Solutionhttp://www.tek-tips.com/gviewthread.cfm/lev2/4/lev3/32/pid/208/qid/717549
Hope this helps,
Robert-Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 02:48 AM
02-19-2004 02:48 AM
Re: lazyload of
Much thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2004 12:30 AM
02-22-2004 12:30 AM
Re: lazyload of
You wrote:
According to the documention, lazyload binding should be the default; I've tried adding the -Wl,-Bdeferred" switch with the same results.
Which documentation did you refer to from http://docs.hp.com? Your feedback can help us improve the documentation.
Thanks,
Hemanth