Operating System - HP-UX
1829404 Members
1640 Online
109991 Solutions
New Discussion

Re: static linking libc on a itanium

 

static linking libc on a itanium

Hello,

I need to link with the static libc.a, but there is no libc.a available on the ia64 system.

It should be a shell which should reside in /sbin/ as /sbin/sh.

/sbin/sh is statically linked.

How can I do this.

Regards
Karl-Heinz
8 REPLIES 8
kobylka
Valued Contributor

Re: static linking libc on a itanium

Hello Karl-Heinz!


On "Integrity" there's only libc.so... }:|

The compiler flag used on this platform to use "minimally shared libs" is -minshared.


Greets back to Germany,

Kobylka

Re: static linking libc on a itanium

Exact that is my problem.

How do they compile the binaries in /sbin/ ??

They are all static linked.

Regards
Karl-Heinz

Re: static linking libc on a itanium

AFAIK the tools to create statically linked programs are available only to the HP-UX development team and specific partners who need to have stuff running in single user mode (like Veritas/Symantec).

If you want to do something like this I think you'll need to approach HP formally and ask the questions...

As to the reason why - I'm not sure - Dennis H will know and might chip in here later...

Why do you need to compile your own code that will run in single user mode???

I guess an alternative would be to figure out which shared libs you need and make sure they are located somewhere in the root filesystem as well... dynamic linking still *works* in single user mode - its just most of the libs aren't available...

HTH

Duncan

I am an HPE Employee
Accept or Kudo

Re: static linking libc on a itanium

The only libs we need are the libc.so.1, and with it, the libdl.so.1

So, as I understand you, if I copy these two libs to e.g. /etc, which is in the root partition, and link it with -l:/etc/libc.so -l:/etc/libdl.so this should work while booting into single user mode??

Dennis Handly
Acclaimed Contributor

Re: static linking libc on a itanium

This functionality isn't available for users.

>It should be a shell

The only real shell you should use is the posix shell, why would you need another?

>The only libs we need are the libc.so.1, and with it, the libdl.so.1

That's not enough and libdl.so.1 should really be used.

>... this should work while booting into single user mode?

No.

>Duncan: If you want to do something like this I think you'll need to approach HP formally

Right. Or explain what you are trying to do and perhaps there is a simpler command that can do what you want, while you stick with the real shell.

>As to the reason why

Because mixing shared vs archive versions of system libs caused problems.

>I guess an alternative would be to figure out which shared libs

That won't work since dld.so must be there too.

Re: static linking libc on a itanium

We have linked with this, to search for the libs in /etc/jets:
ld -o jetsh checkexp.o filebackup.o gethost.o privops.o vxsch.o js_md5.o clog.o +b /etc/jets -lc

libc is the only lib needed by the program.

If I set /etc/jets to SHLIB_PATH:
ldd jetsh
libc.so.1 => /etc/jets/libc.so.1
libdl.so.1 => /etc/jets/libdl.so.1

ls -la /etc/jets
total 10992
drwxr-xr-x 2 root sys 96 Sep 30 03:41 .
dr-xr-xr-x 31 bin bin 8192 Sep 29 10:00 ..
-r-xr-xr-x 1 root sys 925808 Sep 30 03:42 dld.so
-r-xr-xr-x 1 root sys 4600380 Sep 29 10:00 libc.so.1
-r-xr-xr-x 1 root sys 76704 Sep 29 10:00 libdl.so.1

With this programm we want to control the /sbin/sh.
mv /sbin/sh /sbin/jetsh_sh
cp jetsh /sbin/sh

jetsh (/sbin/sh) calls the /sbin/jetsh_sh and logs some things, set in a config file.

This runs well, but if we want to reboot, it does not work.

Dennis Handly
Acclaimed Contributor

Re: static linking libc on a itanium

>We have linked with this, to search for the libs in /etc/jets:

This isn't going to solve my statement:
That won't work since dld.so must be there too.
(You have dld.so but you need more than that. And you have to tell ld where you are placing dld.so.)

>If I set /etc/jets to SHLIB_PATH:

If you are using +b, you don't need that.
Also, you should really be copying the shlibs into a directory like:
/etc/jets/lib/hpux32/

>mv /sbin/sh /sbin/jetsh_sh

You absolutely don't want to move /sbin/sh, nor replace it!

>if we want to reboot, it does not work.

Of course, what you are trying to do isn't easy, nor safe. I would assume after your boot fails, you must reinstall/reignite the system?

Sysadmins need to know nobody has fiddled with /sbin/sh and replaced it with a look alike with unknown functionality.

Re: static linking libc on a itanium

We have found a way to do this (dirt but triky).

Thank you