- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- HP-UX 11.11, C-ANSI-C: LD_PRELOAD fails
Operating System - HP-UX
1753428
Members
4959
Online
108793
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО11-23-2003 11:20 PM
тАО11-23-2003 11:20 PM
Dear forum readers,
I need to preload a non-system shared library for some program execution, which I used to do on HP-UX 11.00 in the past and it worked like a charm but now it doesn't. I tried with a simple case (redefining gethostname() and trying it with the hostname command), and still no luck.
Here is what I did:
1) I wrote the following program, gethostname.c:
----- gethostname.c BEGIN -----
#include
#include
int gethostname(char *hostname, size_t size)
{
strncpy(hostname,"test",size);
return 0;
}
----- gethostname.c END -----
2) I compiled:
$ cc -b -o gethostname.sl gethostname.c
3) I ran:
$ LD_PRELOAD=/gethostname.sl hostname
4) It returned:
Instead of what I expected:
test
Tried with time() too, returning zero in the hope that the date command would return the start of the Epoch, no more luck. Tried by just putting an exit() into gethostname() in the hope that hostname would return nothing, didn't work. Tried to export LD_PRELOAD= before running the command. Carefully checked that the .sl is chmod 755.
I use HP-UX 11.11, and I compiled with the "HP C/ANSI C Compiler" (C-ANSI-C). Do you have any idea about why it does not work?
Thanks for your help!
Olivier ROBERT
I need to preload a non-system shared library for some program execution, which I used to do on HP-UX 11.00 in the past and it worked like a charm but now it doesn't. I tried with a simple case (redefining gethostname() and trying it with the hostname command), and still no luck.
Here is what I did:
1) I wrote the following program, gethostname.c:
----- gethostname.c BEGIN -----
#include
#include
int gethostname(char *hostname, size_t size)
{
strncpy(hostname,"test",size);
return 0;
}
----- gethostname.c END -----
2) I compiled:
$ cc -b -o gethostname.sl gethostname.c
3) I ran:
$ LD_PRELOAD=
4) It returned:
Instead of what I expected:
test
Tried with time() too, returning zero in the hope that the date command would return the start of the Epoch, no more luck. Tried by just putting an exit() into gethostname() in the hope that hostname would return nothing, didn't work. Tried to export LD_PRELOAD=
I use HP-UX 11.11, and I compiled with the "HP C/ANSI C Compiler" (C-ANSI-C). Do you have any idea about why it does not work?
Thanks for your help!
Olivier ROBERT
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-24-2003 01:51 AM
тАО11-24-2003 01:51 AM
Solution
Hi Olivier,
The LD_PRELOAD functionality on 11i was supplied in the linker patch PHSS_22535. I installed the later, recommended version, PHSS_26560, and got the desired results from your program. I was seeing my hostname too before installing this, no reboot is necessary. To find your current version use :
# swlist -l product|grep linker
Cheers,
James.
The LD_PRELOAD functionality on 11i was supplied in the linker patch PHSS_22535. I installed the later, recommended version, PHSS_26560, and got the desired results from your program. I was seeing my hostname too before installing this, no reboot is necessary. To find your current version use :
# swlist -l product|grep linker
Cheers,
James.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-24-2003 07:49 PM
тАО11-24-2003 07:49 PM
Re: HP-UX 11.11, C-ANSI-C: LD_PRELOAD fails
Thanks James, it worked perfectly!
Olivier
Olivier
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP