Operating System - HP-UX
1833324 Members
3199 Online
110051 Solutions
New Discussion

ld fails when shared lib code is not position independent

 
Geoff Hartnell
Advisor

ld fails when shared lib code is not position independent

I'm trying to install Apache on HP-UX 11 using the openssl module.

Apache make fails with:
ld -L/omg/apache22/openssl-0.9.6b -b -o libssl.so mod_ssl.lo ssl_engine_config.lo ssl_engine_compat.lo ssl_engine_ds.lo ssl_engine_dh.lo ssl_engine_init.lo ssl_engine_kernel.lo ssl_engine_rand.lo ssl_engine_io.lo ssl_engine_log.lo ssl_engine_mutex.lo ssl_engine_pphrase.lo ssl_engine_vars.lo ssl_engine_ext.lo ssl_scache.lo ssl_scache_dbm.lo ssl_scache_shmht.lo ssl_scache_shmcb.lo ssl_expr.lo ssl_expr_scan.lo ssl_expr_parse.lo ssl_expr_eval.lo ssl_util.lo ssl_util_ssl.lo ssl_util_sdbm.lo ssl_util_table.lo -ldbm -lssl -lcrypto -L/usr/local/lib/gcc-lib/hppa1.1-hp-hpux11.00/2.9-hppa-991112 -lgcc
ld: DP relative code in file /omg/apache22/openssl-0.9.6b/libssl.a(s2_srvr.o) - shared library must be position
independent. Use +z or +Z to recompile.

BUT ....
I've compiled the code in /omg/apache22/openssl-0.9.6b/libssl.a with
a) +z
b) +Z
c) -fpic
d) -fPIC
- and in each case the Apache make fails

Does anyone have any idea what else to try ?
Thanks
4 REPLIES 4
Steven Gillard_2
Honored Contributor

Re: ld fails when shared lib code is not position independent

Make sure that *every* object file is being compiled with +z. In your case the linker is complaining about s2_srvr.o.

Did you run make clean before recompiling? Are you positive that this has removed all of the object files?

Regards,
Steve
Geoff Hartnell
Advisor

Re: ld fails when shared lib code is not position independent

Steve,

Thanks for the suggestion
I tee'd the make command into a log file and can see the file being built
gcc -I../crypto -I../include -DTHREADS -DDSO_DL -DCFLAGS=+z -D_REENTRANT -O3 -DB_ENDIAN -DBN_DIV2W -c s2_srvr.c

I can also confirm that after a make clean, the .o file is not there and that doing ls -l after make shows the recently built file.

Please feel free to make any other suggestions as it's often the obvious that gets overlooked

Thanks

Geoff

Steven Gillard_2
Honored Contributor

Re: ld fails when shared lib code is not position independent

The build command you've given isn't right:

gcc -I../crypto -I../include -DTHREADS -DDSO_DL -DCFLAGS=+z -D_REENTRANT -O3 -DB_ENDIAN -DBN_DIV2W -c s2_srvr.c

Firstly, the +z flag should be a separate argument to the compiler. Above its given as a CFLAGS macro through -D which is wrong. Secondly, you're using gcc which does not recognise +z/+Z (these are the arguments to use with the HP compilers). With gcc you should be using -fPIC.

The correct command line should be:

gcc -I../crypto -I../include -DTHREADS -DDSO_DL -D_REENTRANT -O3 -DB_ENDIAN -DBN_DIV2W -fPIC -c s2_srvr.c

Regards,
Steve
Geoff Hartnell
Advisor

Re: ld fails when shared lib code is not position independent

Achieved a solution to this problem by doing the following:

1) configure and compile openssl:
cd openss1-0.9.6b
config -DCFLAGS=+z
make
make install

2) install and configure mod_ssl (obtain mod_ssl-2.8.5-1.3.22.tar .gz, gzip -d and tar xvf)
cd ../mod_ssl-2.8.5-1.3.22
./configure --with-apache=/apache_1.3.22 --with-ssl=/openssl-0.9.6b --prefix=/apache_1.3.22 --enable-module=so --enable-rule=SHARED_CORE

3) build Apache
cd ../apache_1.3.22
make

4) Make the certificate
make certificate TYPE=

5) Install Apache
make install