Replacing libraries on HP-UX
HP-UX is very robust when it come to protecting the
running peice of code. If you were a library or a program writer and wanted
to patch a running binary or currently in use lib, you may have to shutdown
the system to single user and then do your
Question 1: Is it possible to replace a running code
on HP-UX? Like change a library that is being used, without killing the
process that is using it?
Question 2: How would you replace /usr/lib/libc.1? Even in single user mode it will be used by init and if you kill init, you shutdown the system, you cannot do it solaris way (boot from cd, mount root partition and replace files etc.) e.g.: Your job is to replace libc.1 either in single user mode or multi-user mode This is not a hard question to answer, given that you can dig and dig, dig, and dig lot deeper. Good luck and have fun.
Answer for question 1 is
Wrong!! Try again!!
Try something simple. Write a small C program that runs
infinitely, do fuser on it, note the proc id. Now do your mv opr, do the
Reason: Because you disassociated the vnode without the
running process knowing about it, next time the process need to
Nice try. You're close, keep trying. :
Hey!! that wont work.
any newer dlopen()s / dlsym()s from the running executable will load the new symbols from the new objs (new lib file). Well.. never tried this before..
Now, libfoo.so forms Ur new lib.
I guess same thing can be used for libc.so as well. Buttt.. /sbin/init is supposed to
be statically linked.
The LC_MONETARY-probl was solved within appln-scripts
itself.
*Oops* Sorry if I screwed up the
Revision control part of it. ie libfoo.so libfoo.so.1 and 2s and 3s etc
No cp will work in single user mode, but a proc is using a library, you'll be unable to cp. HINT: You need to duplicate the inode information, not
by creating it, by but referencing to it!!
LC_MONETETARY:: Glad to hear that.
Hey that hint was very close.
You meant to create a hard link. RIGHT?? Ok. It was very interesting.
Exactly my point. But do not use
the regular link. There is a static /etc/link, use that. If you use regular
link you will render
So.. /etc/link libc.2 libc.2.old
This will even patch a running program. Never knew of this /etc/link business at all. Goodie.
Can't we update the same lib using some ld / cc option?
How about appending the newcode.o onto the old lib libfoo.so
and retaining the name and the inode no as libfoo.so
HP-UX internals demand that shared executable not being used when changed. And generally for any .so/.sl or
shared object you cannot replace any .o's inside, since it is in ELF .so
format and is not a
Have fun
Have a Unix Problem
Unix Books :-
Return to : - Unix System Administration Hints and Tips (c) www.gotothings.com All material on this site is Copyright.
|