In major linux distributions, the slapd is copmiled as shared object. There are projects (nordugrid.org arc) for example) using slapd object to build custom grid related services. Is it possible to add the pie patch to openldap ebuild (taken from fedora), verified to work well on 2.4.17-r1?
Created attachment 206514 [details, diff] pie patch
This patch causes a compile fail. Please respin for 2.4.19 and verify that it works on 2.4.19. creating .libs/slapdS.c (cd .libs && x86_64-pc-linux-gnu-gcc -c -fno-builtin "slapdS.c") rm -f .libs/slapdS.c .libs/slapd.nm .libs/slapd.nmS .libs/slapd.nmT x86_64-pc-linux-gnu-gcc -march=nocona -O2 -pipe -g -D_GNU_SOURCE -Wl,-O1 .libs/slapdS.o -pie -Wl,-z -Wl,defs -o .libs/slapd main.o globals.o bconfig.o config.o daemon.o connection.o search.o filter.o add.o cr.o attr.o entry.o backend.o backends.o result.o operation.o dn.o compare.o modify.o delete.o modrdn.o ch_malloc.o value.o ava.o bind.o unbind.o abandon.o filterentry.o phonetic.o acl.o str2filter.o aclparse.o init.o user.o lock.o controls.o extended.o passwd.o schema.o schema_check.o schema_init.o schema_prep.o schemaparse.o ad.o at.o mr.o syntax.o oc.o saslauthz.o oidm.o starttls.o index.o sets.o referral.o root_dse.o sasl.o module.o mra.o mods.o sl_malloc.o zn_malloc.o limits.o operational.o matchedValues.o cancel.o syncrepl.o backglue.o backover.o ctxcsn.o ldapsync.o frontend.o slapadd.o slapcat.o slapcommon.o slapdn.o slapindex.o slappasswd.o slaptest.o slapauth.o slapacl.o component.o aci.o alock.o txn.o slapschema.o version.o -pthread -Wl,--export-dynamic libbackends.a liboverlays.a ../../libraries/liblunicode/liblunicode.a ../../libraries/librewrite/librewrite.a ../../libraries/liblutil/liblutil.a ../../libraries/libldap_r/.libs/libldap_r.so /dev/shm/portage/net-nds/openldap-2.4.19/work/openldap-2.4.19/libraries/liblber/.libs/liblber.so ../../libraries/liblber/.libs/liblber.so -luuid /usr/lib64/libdb-4.8.so -lpthread /usr/lib64/libslp.so -lnsl /usr/lib64/libsasl2.so -lssl -lcrypto -lcrypt -lresolv -pthread libslapi.a /usr/lib64/libltdl.so -ldl /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/../../../../x86_64-pc-linux-gnu/bin/ld: main.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC main.o: could not read symbols: Bad value collect2: ld returned 1 exit status make[2]: *** [slapd] Error 1 make[2]: Leaving directory `/dev/shm/portage/net-nds/openldap-2.4.19/work/openldap-2.4.19/servers/slapd' make[1]: *** [all-common] Error 1 make[1]: Leaving directory `/dev/shm/portage/net-nds/openldap-2.4.19/work/openldap-2.4.19/servers' make: *** [all-common] Error 1 * ERROR: net-nds/openldap-2.4.19 failed:
Reping
Well, I have forgotten about that. Seems some additional patches are needed to compile some of the code with fPIC. As a workaround I have created an additional ebuild to compile slapd only. Will take a look again at fedora spec file.
This pretty much timed out, right?
Well, it turned out it is much easier to build a custom slapd executable in a separate ebuild.