Re: Set soname for shared libraries

2017-11-13 Thread Philip Guenther
On Mon, Nov 13, 2017 at 12:25 PM, Mark Kettenis 
wrote:

> The diff below changes bsd.lib.mk such that we set the DT_SONAME entry
> for shared libraries to the name of the shared library.  This brings
> us in line with other ELF systems and allows us to use symlinks to
> tell the linker which shared libraries to link against.  That in turn
> would allow us to drop some OpenBSD-specific local modifications from
> our linkers.
>
> ok?
>

Looks good.  ok guenther@


Set soname for shared libraries

2017-11-13 Thread Mark Kettenis
The diff below changes bsd.lib.mk such that we set the DT_SONAME entry
for shared libraries to the name of the shared library.  This brings
us in line with other ELF systems and allows us to use symlinks to
tell the linker which shared libraries to link against.  That in turn
would allow us to drop some OpenBSD-specific local modifications from
our linkers.

ok?


Index: share/mk/bsd.lib.mk
===
RCS file: /cvs/src/share/mk/bsd.lib.mk,v
retrieving revision 1.91
diff -u -p -r1.91 bsd.lib.mk
--- share/mk/bsd.lib.mk 5 Nov 2017 10:29:24 -   1.91
+++ share/mk/bsd.lib.mk 13 Nov 2017 20:20:47 -
@@ -211,19 +211,19 @@ ${FULLSHLIBNAME}: ${SOBJS} ${DPADD}
@echo building shared ${LIB} library \(version 
${SHLIB_MAJOR}.${SHLIB_MINOR}\)
@rm -f ${.TARGET}
 .if defined(SYSPATCH_PATH)
-   ${CC} -shared ${PICFLAG} -o ${.TARGET} \
+   ${CC} -shared -Wl,-soname,${FULLSHLIBNAME} ${PICFLAG} -o ${.TARGET} \
`readelf -Ws ${SYSPATCH_PATH}${LIBDIR}/${.TARGET} | \
awk '/ FILE/{sub(".*/", "", $$NF); gsub(/\..*/, ".so", $$NF); print 
$$NF}' | \
egrep -v "(cmll-586|libgcc2|unwind-dw2|mul(d|s|x)c3)" | awk 
'!x[$$0]++'` ${LDADD}
 .else
-   ${CC} -shared ${PICFLAG} -o ${.TARGET} \
+   ${CC} -shared -Wl,-soname,${FULLSHLIBNAME} ${PICFLAG} -o ${.TARGET} \
`echo ${SOBJS} | tr ' ' '\n' | sort -R` ${LDADD}
 .endif
 
 ${FULLSHLIBNAME}.a: ${SOBJS}
@echo building shared ${LIB} library \(version 
${SHLIB_MAJOR}.${SHLIB_MINOR}\) ar
@rm -f ${.TARGET}
-   @echo ${PICFLAG} ${LDADD} > .ldadd
+   @echo -Wl,-soname,${FULLSHLIBNAME} ${PICFLAG} ${LDADD} > .ldadd
ar cqD ${FULLSHLIBNAME}.a ${SOBJS} .ldadd ${SYMBOLSMAP}
 
 # all .do files...