author | Alberto Bertogli
<albertito@blitiri.com.ar> 2018-06-30 19:29:00 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2018-06-30 19:29:00 UTC |
parent | 059ca8b35895bbc63de1cb765a4c3d4671bf60d3 |
preload/posix/Makefile | +5 | -1 |
preload/posix/build-libccheck.c | +8 | -0 |
diff --git a/preload/posix/Makefile b/preload/posix/Makefile index 0b07f90..a45477a 100644 --- a/preload/posix/Makefile +++ b/preload/posix/Makefile @@ -81,8 +81,12 @@ build-needlibdl: # ia64 and alpha use libc.so.6.1), so find which one to use at build-time. # Please note that the argument to ldd *must* start with "./", otherwise some # "ldd"s won't work (for example, the one in FreeBSD 8.1). +# To find out the soname, we build a dummy shared library against the libc, +# and use ldd to extract the version. This shared library must actually use +# something from libc, otherwise a smart compiler/linker (such as one using +# --as-needed) might not link it against libc. build-libcsoname: - @$(CC) -x c /dev/null -lc -shared -o build-libccheck.so + @$(CC) build-libccheck.c -lc -shared -fPIC -o build-libccheck.so @ldd ./build-libccheck.so | grep libc.so | awk '{ print $$1 }' > $@ @rm build-libccheck.so @test "`cat $@`" != "" || \ diff --git a/preload/posix/build-libccheck.c b/preload/posix/build-libccheck.c new file mode 100644 index 0000000..41fad24 --- /dev/null +++ b/preload/posix/build-libccheck.c @@ -0,0 +1,8 @@ +/* Dummy file used at build time to find out libc's soname. + * It must use something from libc. See the Makefile for details. */ + +#include <stdio.h> + +int use_printf(void) { + return printf("I'm using libc\n"); +}