From ff53a0284adb5c18b65eb86279cd85b4ff562861 Mon Sep 17 00:00:00 2001 From: Vincent Danjean Date: Thu, 21 Jun 2012 10:01:00 +0200 Subject: Use automake support to install docs It is shorter, cleaner and "make uninstall" support comes for free --- Makefile.am | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 4bb3279..aa0d513 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,6 +4,4 @@ EXTRA_DIST = COPYING README patchelf.spec version $(man1_MANS) man1_MANS = patchelf.1 -install-data-local: - $(INSTALL) -d $(DESTDIR)$(docdir) - $(INSTALL_DATA) $(top_srcdir)/README $(DESTDIR)$(docdir)/ +doc_DATA = README -- cgit v0.12 From a47966515893d9ddf720bbbb001735a5756b6f6b Mon Sep 17 00:00:00 2001 From: Vincent Danjean Date: Thu, 21 Jun 2012 10:03:31 +0200 Subject: fix build *and check* out of tree - use Makefile variables $< (and $@) so that sources are found correctly - use ${srcdir} in test scripts to find the sources This allows "make distcheck" to successfully pass --- tests/Makefile.am | 8 ++++---- tests/no-rpath.sh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 9d9b6bc..aa9e22b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -18,7 +18,7 @@ main-scoped: main.o libfoo-scoped.so LD_LIBRARY_PATH=. gcc -Wl,--enable-new-dtags -o main-scoped main.o -L . -lfoo-scoped main.o: main.c - $(CC) -fpic -o main.o -c main.c + $(CC) -fpic -o $@ -c $< libfoo.so: foo.o libbar.so NIX_DONT_SET_RPATH=1 $(CC) -Wl,--disable-new-dtags -shared -o libfoo.so foo.o -L . -lbar @@ -27,7 +27,7 @@ libfoo-scoped.so: foo.o libbar-scoped.so NIX_DONT_SET_RPATH=1 $(CC) -Wl,--enable-new-dtags -shared -o libfoo-scoped.so foo.o -L . -lbar-scoped foo.o: foo.c - $(CC) -fpic -o foo.o -c foo.c + $(CC) -fpic -o $@ -c $< libbar.so: bar.o NIX_DONT_SET_RPATH=1 $(CC) -Wl,--disable-new-dtags -shared -o libbar.so bar.o -L . -Wl,-rpath,`pwd`/no-such-path @@ -36,7 +36,7 @@ libbar-scoped.so: bar.o NIX_DONT_SET_RPATH=1 $(CC) -Wl,--enable-new-dtags -shared -o libbar-scoped.so bar.o bar.o: bar.c - $(CC) -fpic -o bar.o -c bar.c + $(CC) -fpic -o $@ -c $< big_dynstr_SOURCES = big-dynstr.c @@ -45,7 +45,7 @@ big-dynstr: big-dynstr.o libfoo.so LD_LIBRARY_PATH=. gcc -Wl,--disable-new-dtags -o big-dynstr big-dynstr.o -L . -lfoo big-dynstr.c: main.c - cat main.c > big-dynstr.c + cat $< > big-dynstr.c for i in $$(seq 1 2000); do echo "void f$$i(void) { };" >> big-dynstr.c; done diff --git a/tests/no-rpath.sh b/tests/no-rpath.sh index c253952..7245317 100755 --- a/tests/no-rpath.sh +++ b/tests/no-rpath.sh @@ -3,7 +3,7 @@ rm -rf scratch mkdir -p scratch -cp no-rpath scratch/ +cp ${srcdir}/no-rpath scratch/ oldRPath=$(../src/patchelf --print-rpath scratch/no-rpath) if test -n "$oldRPath"; then exit 1; fi -- cgit v0.12 From eefa2c9d0fd755634478072040e49259c3f458c3 Mon Sep 17 00:00:00 2001 From: Vincent Danjean Date: Thu, 21 Jun 2012 11:26:31 +0200 Subject: Use autoreconf to bootstrap the project This avoid to manually list all autotool programs required --- bootstrap.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index 3302c9f..ba2bee2 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,5 +1,2 @@ #! /bin/sh -e -aclocal -#autoheader -automake --add-missing --copy --foreign -autoconf --force +autoreconf --verbose --install --force --warnings=all -- cgit v0.12 From 8d6a477b990285b4fba3f3e27cefe6da40fe77a1 Mon Sep 17 00:00:00 2001 From: Vincent Danjean Date: Thu, 21 Jun 2012 11:43:57 +0200 Subject: Allow parallel execution of tests Each test use its own subdirectory in scratch/ --- tests/big-dynstr.sh | 23 ++++++++++++----------- tests/no-rpath.sh | 15 ++++++++------- tests/set-interpreter-long.sh | 17 +++++++++-------- tests/set-interpreter-short.sh | 11 ++++++----- tests/set-rpath-library.sh | 33 +++++++++++++++++---------------- tests/set-rpath.sh | 23 ++++++++++++----------- tests/shrink-rpath.sh | 15 ++++++++------- 7 files changed, 72 insertions(+), 65 deletions(-) diff --git a/tests/big-dynstr.sh b/tests/big-dynstr.sh index bb95366..19adad1 100755 --- a/tests/big-dynstr.sh +++ b/tests/big-dynstr.sh @@ -1,24 +1,25 @@ #! /bin/sh -e +SCRATCH=scratch/$(basename $0 .sh) -rm -rf scratch -mkdir -p scratch -mkdir -p scratch/libsA -mkdir -p scratch/libsB +rm -rf ${SCRATCH} +mkdir -p ${SCRATCH} +mkdir -p ${SCRATCH}/libsA +mkdir -p ${SCRATCH}/libsB -cp big-dynstr scratch/ -cp libfoo.so scratch/libsA/ -cp libbar.so scratch/libsB/ +cp big-dynstr ${SCRATCH}/ +cp libfoo.so ${SCRATCH}/libsA/ +cp libbar.so ${SCRATCH}/libsB/ -oldRPath=$(../src/patchelf --print-rpath scratch/big-dynstr) +oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/big-dynstr) if test -z "$oldRPath"; then oldRPath="/oops"; fi -../src/patchelf --force-rpath --set-rpath $oldRPath:$(pwd)/scratch/libsA:$(pwd)/scratch/libsB scratch/big-dynstr +../src/patchelf --force-rpath --set-rpath $oldRPath:$(pwd)/${SCRATCH}/libsA:$(pwd)/${SCRATCH}/libsB ${SCRATCH}/big-dynstr if test "$(uname)" = FreeBSD; then - export LD_LIBRARY_PATH=$(pwd)/scratch/libsB + export LD_LIBRARY_PATH=$(pwd)/${SCRATCH}/libsB fi exitCode=0 -cd scratch && ./big-dynstr || exitCode=$? +cd ${SCRATCH} && ./big-dynstr || exitCode=$? if test "$exitCode" != 46; then echo "bad exit code!" diff --git a/tests/no-rpath.sh b/tests/no-rpath.sh index 7245317..20c720c 100755 --- a/tests/no-rpath.sh +++ b/tests/no-rpath.sh @@ -1,22 +1,23 @@ #! /bin/sh -e +SCRATCH=scratch/$(basename $0 .sh) -rm -rf scratch -mkdir -p scratch +rm -rf ${SCRATCH} +mkdir -p ${SCRATCH} -cp ${srcdir}/no-rpath scratch/ +cp ${srcdir}/no-rpath ${SCRATCH}/ -oldRPath=$(../src/patchelf --print-rpath scratch/no-rpath) +oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath) if test -n "$oldRPath"; then exit 1; fi ../src/patchelf \ --set-interpreter "$(../src/patchelf --print-interpreter ../src/patchelf)" \ - --set-rpath /foo:/bar:/xxxxxxxxxxxxxxx scratch/no-rpath + --set-rpath /foo:/bar:/xxxxxxxxxxxxxxx ${SCRATCH}/no-rpath -newRPath=$(../src/patchelf --print-rpath scratch/no-rpath) +newRPath=$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath) if ! echo "$newRPath" | grep -q '/foo:/bar'; then echo "incomplete RPATH" exit 1 fi if [ "$(uname -m)" = i686 -a "$(uname -s)" = Linux ]; then - cd scratch && ./no-rpath + cd ${SCRATCH} && ./no-rpath fi diff --git a/tests/set-interpreter-long.sh b/tests/set-interpreter-long.sh index 55ced77..058ccd2 100755 --- a/tests/set-interpreter-long.sh +++ b/tests/set-interpreter-long.sh @@ -1,4 +1,5 @@ #! /bin/sh -e +SCRATCH=scratch/$(basename $0 .sh) ./simple @@ -10,24 +11,24 @@ if test "$(uname)" = Linux; then "$oldInterpreter" ./simple fi -rm -rf scratch -mkdir -p scratch +rm -rf ${SCRATCH} +mkdir -p ${SCRATCH} -newInterpreter=$(pwd)/scratch/iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii -cp simple scratch/ -../src/patchelf --set-interpreter "$newInterpreter" scratch/simple +newInterpreter=$(pwd)/${SCRATCH}/iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii +cp simple ${SCRATCH}/ +../src/patchelf --set-interpreter "$newInterpreter" ${SCRATCH}/simple echo "running with missing interpreter..." -if scratch/simple; then +if ${SCRATCH}/simple; then echo "simple works, but it shouldn't" exit 1 fi echo "running with new interpreter..." ln -s "$oldInterpreter" "$newInterpreter" -scratch/simple +${SCRATCH}/simple if test "$(uname)" = Linux; then echo "running with explicit interpreter..." - "$oldInterpreter" scratch/simple + "$oldInterpreter" ${SCRATCH}/simple fi diff --git a/tests/set-interpreter-short.sh b/tests/set-interpreter-short.sh index 62990c9..2c9f4eb 100755 --- a/tests/set-interpreter-short.sh +++ b/tests/set-interpreter-short.sh @@ -1,18 +1,19 @@ #! /bin/sh -e +SCRATCH=scratch/$(basename $0 .sh) ./simple oldInterpreter=$(../src/patchelf --print-interpreter ./simple) echo "current interpreter is $oldInterpreter" -rm -rf scratch -mkdir -p scratch +rm -rf ${SCRATCH} +mkdir -p ${SCRATCH} -cp simple scratch/ -../src/patchelf --set-interpreter /oops scratch/simple +cp simple ${SCRATCH}/ +../src/patchelf --set-interpreter /oops ${SCRATCH}/simple echo "running with missing interpreter..." -if scratch/simple; then +if ${SCRATCH}/simple; then echo "simple works, but it shouldn't" exit 1 fi diff --git a/tests/set-rpath-library.sh b/tests/set-rpath-library.sh index 50e58b8..dd1381f 100755 --- a/tests/set-rpath-library.sh +++ b/tests/set-rpath-library.sh @@ -1,27 +1,28 @@ #! /bin/sh -e +SCRATCH=scratch/$(basename $0 .sh) if test "$(uname)" = FreeBSD; then echo "skipping on FreeBSD" exit 0 fi -rm -rf scratch -mkdir -p scratch -mkdir -p scratch/libsA -mkdir -p scratch/libsB +rm -rf ${SCRATCH} +mkdir -p ${SCRATCH} +mkdir -p ${SCRATCH}/libsA +mkdir -p ${SCRATCH}/libsB -cp main-scoped scratch/ -cp libfoo-scoped.so scratch/libsA/ -cp libbar-scoped.so scratch/libsB/ +cp main-scoped ${SCRATCH}/ +cp libfoo-scoped.so ${SCRATCH}/libsA/ +cp libbar-scoped.so ${SCRATCH}/libsB/ -oldRPath=$(../src/patchelf --print-rpath scratch/main-scoped) +oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/main-scoped) if test -z "$oldRPath"; then oldRPath="/oops"; fi -../src/patchelf --set-rpath $oldRPath:$(pwd)/scratch/libsA:$(pwd)/scratch/libsB scratch/main-scoped +../src/patchelf --set-rpath $oldRPath:$(pwd)/${SCRATCH}/libsA:$(pwd)/${SCRATCH}/libsB ${SCRATCH}/main-scoped # "main" contains libbar in its RUNPATH, but that's ignored when # resolving libfoo. So libfoo won't find libbar and this will fail. exitCode=0 -(cd scratch && ./main-scoped) || exitCode=$? +(cd ${SCRATCH} && ./main-scoped) || exitCode=$? if test "$exitCode" = 46; then echo "expected failure" @@ -29,12 +30,12 @@ if test "$exitCode" = 46; then fi # So set an RUNPATH on libfoo as well. -oldRPath=$(../src/patchelf --print-rpath scratch/libsA/libfoo-scoped.so) +oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/libsA/libfoo-scoped.so) if test -z "$oldRPath"; then oldRPath="/oops"; fi -../src/patchelf --set-rpath $oldRPath:$(pwd)/scratch/libsB scratch/libsA/libfoo-scoped.so +../src/patchelf --set-rpath $oldRPath:$(pwd)/${SCRATCH}/libsB ${SCRATCH}/libsA/libfoo-scoped.so exitCode=0 -(cd scratch && ./main-scoped) || exitCode=$? +(cd ${SCRATCH} && ./main-scoped) || exitCode=$? if test "$exitCode" != 46; then echo "bad exit code!" @@ -42,15 +43,15 @@ if test "$exitCode" != 46; then fi # Remove the libbar PATH from main using --shrink-rpath. -../src/patchelf --shrink-rpath scratch/main-scoped -if ../src/patchelf --print-rpath scratch/main-scoped | grep /libsB; then +../src/patchelf --shrink-rpath ${SCRATCH}/main-scoped +if ../src/patchelf --print-rpath ${SCRATCH}/main-scoped | grep /libsB; then echo "shrink failed" exit 1 fi # And it should still run. exitCode=0 -(cd scratch && ./main-scoped) || exitCode=$? +(cd ${SCRATCH} && ./main-scoped) || exitCode=$? if test "$exitCode" != 46; then echo "bad exit code!" diff --git a/tests/set-rpath.sh b/tests/set-rpath.sh index b797017..90452f9 100755 --- a/tests/set-rpath.sh +++ b/tests/set-rpath.sh @@ -1,24 +1,25 @@ #! /bin/sh -e +SCRATCH=scratch/$(basename $0 .sh) -rm -rf scratch -mkdir -p scratch -mkdir -p scratch/libsA -mkdir -p scratch/libsB +rm -rf ${SCRATCH} +mkdir -p ${SCRATCH} +mkdir -p ${SCRATCH}/libsA +mkdir -p ${SCRATCH}/libsB -cp main scratch/ -cp libfoo.so scratch/libsA/ -cp libbar.so scratch/libsB/ +cp main ${SCRATCH}/ +cp libfoo.so ${SCRATCH}/libsA/ +cp libbar.so ${SCRATCH}/libsB/ -oldRPath=$(../src/patchelf --print-rpath scratch/main) +oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/main) if test -z "$oldRPath"; then oldRPath="/oops"; fi -../src/patchelf --force-rpath --set-rpath $oldRPath:$(pwd)/scratch/libsA:$(pwd)/scratch/libsB scratch/main +../src/patchelf --force-rpath --set-rpath $oldRPath:$(pwd)/${SCRATCH}/libsA:$(pwd)/${SCRATCH}/libsB ${SCRATCH}/main if test "$(uname)" = FreeBSD; then - export LD_LIBRARY_PATH=$(pwd)/scratch/libsB + export LD_LIBRARY_PATH=$(pwd)/${SCRATCH}/libsB fi exitCode=0 -(cd scratch && ./main) || exitCode=$? +(cd ${SCRATCH} && ./main) || exitCode=$? if test "$exitCode" != 46; then echo "bad exit code!" diff --git a/tests/shrink-rpath.sh b/tests/shrink-rpath.sh index e0c82c1..3adc846 100755 --- a/tests/shrink-rpath.sh +++ b/tests/shrink-rpath.sh @@ -1,4 +1,5 @@ #! /bin/sh -e +SCRATCH=scratch/$(basename $0 .sh) rpath=$(../src/patchelf --print-rpath ./libbar.so) echo "RPATH before: $rpath" @@ -7,22 +8,22 @@ if ! echo "$rpath" | grep -q /no-such-path; then exit 1 fi -rm -rf scratch -mkdir -p scratch -cp libbar.so scratch/ -../src/patchelf --shrink-rpath scratch/libbar.so +rm -rf ${SCRATCH} +mkdir -p ${SCRATCH} +cp libbar.so ${SCRATCH}/ +../src/patchelf --shrink-rpath ${SCRATCH}/libbar.so -rpath=$(../src/patchelf --print-rpath scratch/libbar.so) +rpath=$(../src/patchelf --print-rpath ${SCRATCH}/libbar.so) echo "RPATH after: $rpath" if echo "$rpath" | grep -q /no-such-path; then echo "RPATH not shrunk" exit 1 fi -cp libfoo.so scratch/ +cp libfoo.so ${SCRATCH}/ exitCode=0 -cd scratch && LD_LIBRARY_PATH=. ../main || exitCode=$? +cd ${SCRATCH} && LD_LIBRARY_PATH=. ../../main || exitCode=$? if test "$exitCode" != 46; then echo "bad exit code!" -- cgit v0.12 From 5109579418940e6ce96826a3f5374610191ab0ef Mon Sep 17 00:00:00 2001 From: Vincent Danjean Date: Thu, 21 Jun 2012 11:46:09 +0200 Subject: Cleanup configure.ac - quote argument (mostly cosmetic) - use a file present only once in the sources for AC_CONFIG_SRCDIR - use AC_CONFIG_AUX_DIR to put all auxilary scripts in a subdirectory --- configure.ac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 372114d..30ba4f9 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,6 @@ -AC_INIT(patchelf, m4_esyscmd([echo -n $(cat ./version)$VERSION_SUFFIX])) -AC_CONFIG_SRCDIR(Makefile.am) +AC_INIT([patchelf], m4_esyscmd([echo -n $(cat ./version)$VERSION_SUFFIX])) +AC_CONFIG_SRCDIR([src/patchelf.cc]) +AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([dist-bzip2 foreign]) AC_PROG_CC -- cgit v0.12 From 135d47e6c05b5771060d3b8b0b96119e6abde2d7 Mon Sep 17 00:00:00 2001 From: Vincent Danjean Date: Thu, 21 Jun 2012 11:47:14 +0200 Subject: Add a .gitignore for all file generated by ./bootstrap.sh No need to exclude files created when compiling and testing as this can be done out of tree --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c8b27b --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +/autom4te.cache/ + +/aclocal.m4 +/configure +/build-aux/ + +Makefile.in -- cgit v0.12 From 102237983e17a646e064aec90e2bda8c98dd8ecb Mon Sep 17 00:00:00 2001 From: Vincent Danjean Date: Thu, 21 Jun 2012 11:50:48 +0200 Subject: Rewrite tests in automake - add options in AM_INIT_AUTOMAKE to be more strict and to enable more advanced features (color-tests and parallel-tests) - rewrite tests/Makefile.am to use automake rules for building program and libraries => we can now do: ./bootstrap.sh && mkdir build && cd build && ../configure && make -j distcheck --- configure.ac | 2 +- tests/Makefile.am | 82 ++++++++++++++++++++++++++++++------------------------- 2 files changed, 46 insertions(+), 38 deletions(-) diff --git a/configure.ac b/configure.ac index 30ba4f9..63bf76a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ AC_INIT([patchelf], m4_esyscmd([echo -n $(cat ./version)$VERSION_SUFFIX])) AC_CONFIG_SRCDIR([src/patchelf.cc]) AC_CONFIG_AUX_DIR([build-aux]) -AM_INIT_AUTOMAKE([dist-bzip2 foreign]) +AM_INIT_AUTOMAKE([-Wall -Werror dist-bzip2 foreign color-tests parallel-tests]) AC_PROG_CC AC_PROG_CXX diff --git a/tests/Makefile.am b/tests/Makefile.am index aa9e22b..9a38df6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,56 +1,64 @@ -check_PROGRAMS = main main-scoped simple big-dynstr +check_PROGRAMS = simple main main-scoped big-dynstr TESTS = plain-fail.sh plain-run.sh shrink-rpath.sh set-interpreter-short.sh \ set-interpreter-long.sh set-rpath.sh no-rpath.sh big-dynstr.sh \ set-rpath-library.sh +EXTRA_DIST = no-rpath $(TESTS) TESTS_ENVIRONMENT = PATCHELF_DEBUG=1 +CLEANFILES = big-dynstr.c +clean-local: + $(RM) -r scratch -simple_SOURCES = simple.c -main_scoped_SOURCES = - - -main: main.o libfoo.so - LD_LIBRARY_PATH=. gcc -Wl,--disable-new-dtags -o main main.o -L . -lfoo - -main-scoped: main.o libfoo-scoped.so - LD_LIBRARY_PATH=. gcc -Wl,--enable-new-dtags -o main-scoped main.o -L . -lfoo-scoped - -main.o: main.c - $(CC) -fpic -o $@ -c $< - -libfoo.so: foo.o libbar.so - NIX_DONT_SET_RPATH=1 $(CC) -Wl,--disable-new-dtags -shared -o libfoo.so foo.o -L . -lbar - -libfoo-scoped.so: foo.o libbar-scoped.so - NIX_DONT_SET_RPATH=1 $(CC) -Wl,--enable-new-dtags -shared -o libfoo-scoped.so foo.o -L . -lbar-scoped - -foo.o: foo.c - $(CC) -fpic -o $@ -c $< - -libbar.so: bar.o - NIX_DONT_SET_RPATH=1 $(CC) -Wl,--disable-new-dtags -shared -o libbar.so bar.o -L . -Wl,-rpath,`pwd`/no-such-path - -libbar-scoped.so: bar.o - NIX_DONT_SET_RPATH=1 $(CC) -Wl,--enable-new-dtags -shared -o libbar-scoped.so bar.o - -bar.o: bar.c - $(CC) -fpic -o $@ -c $< +# by default, use -fpic to compile +AM_CFLAGS = -fpic +LDFLAGS_local = -Wl,--disable-new-dtags -Wl,-rpath-link=. -L. $(AM_LDFLAGS) +LDFLAGS_sharedlib = -Wl,--disable-new-dtags -shared -L. $(AM_LDFLAGS) +export NIX_DONT_SET_RPATH=1 +simple_SOURCES = simple.c +# no -fpic for simple.o +simple_CFLAGS = -big_dynstr_SOURCES = big-dynstr.c +main_SOURCES = main.c +main_LDADD = -lfoo $(AM_LDADD) +main_DEPENDENCIES = libfoo.so +main_LDFLAGS = $(LDFLAGS_local) -big-dynstr: big-dynstr.o libfoo.so - LD_LIBRARY_PATH=. gcc -Wl,--disable-new-dtags -o big-dynstr big-dynstr.o -L . -lfoo +main_scoped_SOURCES = main.c +main_scoped_LDADD = -lfoo-scoped $(AM_LDADD) +main_scoped_DEPENDENCIES = libfoo-scoped.so +main_scoped_LDFLAGS = $(LDFLAGS_local) big-dynstr.c: main.c cat $< > big-dynstr.c for i in $$(seq 1 2000); do echo "void f$$i(void) { };" >> big-dynstr.c; done +nodist_big_dynstr_SOURCES = big-dynstr.c +big_dynstr_LDADD = -lfoo $(AM_LDADD) +big_dynstr_DEPENDENCIES = libfoo.so +big_dynstr_LDFLAGS = $(LDFLAGS_local) -clean-local: - $(RM) *.o libfoo.so libbar.so main big-dynstr big-dynstr.c +# declare local shared libraries as programs as: +# - without libtool, only archives (static libraries) can be built by automake +# - with libtool, it is difficult to control options +# - with libtool, it is not possible to compile convenience *dynamic* libraries :-( +check_PROGRAMS += libfoo.so libfoo-scoped.so libbar.so libbar-scoped.so + +libfoo_so_SOURCES = foo.c +libfoo_so_LDADD = -lbar $(AM_LDADD) +libfoo_so_DEPENDENCIES = libbar.so +libfoo_so_LDFLAGS = $(LDFLAGS_sharedlib) + +libfoo_scoped_so_SOURCES = foo.c +libfoo_scoped_so_LDADD = -lbar-scoped $(AM_LDADD) +libfoo_scoped_so_DEPENDENCIES = libbar-scoped.so +libfoo_scoped_so_LDFLAGS = $(LDFLAGS_sharedlib) + +libbar_so_SOURCES = bar.c +libbar_so_LDFLAGS = $(LDFLAGS_sharedlib) -Wl,-rpath,`pwd`/no-such-path +libbar_scoped_so_SOURCES = bar.c +libbar_scoped_so_LDFLAGS = $(LDFLAGS_sharedlib) -EXTRA_DIST = main.c foo.c bar.c no-rpath $(TESTS) -- cgit v0.12 From c4220eaf0f552cfd68148ddefd6455ff2ce0e08c Mon Sep 17 00:00:00 2001 From: Vincent Danjean Date: Wed, 11 Jul 2012 10:09:24 +0200 Subject: rewrite no-rpath test * compile locally this test in the no-rpath test * add tests for prebuilt no-rpath binaries on various ELF platforms => ia64 does not work, probably a bug in patchelf. Marking it as XFAIL for now --- tests/Makefile.am | 40 ++++++++++++++++++++--- tests/no-rpath | Bin 2848 -> 0 bytes tests/no-rpath-prebuild.sh | 41 ++++++++++++++++++++++++ tests/no-rpath-prebuild/no-rpath-amd64 | Bin 0 -> 9514 bytes tests/no-rpath-prebuild/no-rpath-armel | Bin 0 -> 7516 bytes tests/no-rpath-prebuild/no-rpath-armhf | Bin 0 -> 7451 bytes tests/no-rpath-prebuild/no-rpath-hurd-i386 | Bin 0 -> 7508 bytes tests/no-rpath-prebuild/no-rpath-i386 | Bin 0 -> 7328 bytes tests/no-rpath-prebuild/no-rpath-ia64 | Bin 0 -> 10745 bytes tests/no-rpath-prebuild/no-rpath-kfreebsd-amd64 | Bin 0 -> 9526 bytes tests/no-rpath-prebuild/no-rpath-kfreebsd-i386 | Bin 0 -> 7296 bytes tests/no-rpath-prebuild/no-rpath-mips | Bin 0 -> 8198 bytes tests/no-rpath-prebuild/no-rpath-mipsel | Bin 0 -> 8202 bytes tests/no-rpath-prebuild/no-rpath-powerpc | Bin 0 -> 7746 bytes tests/no-rpath-prebuild/no-rpath-s390 | Bin 0 -> 7308 bytes tests/no-rpath-prebuild/no-rpath-sh4 | Bin 0 -> 7223 bytes tests/no-rpath-prebuild/no-rpath-sparc | Bin 0 -> 7197 bytes tests/no-rpath.c | 6 ++++ tests/no-rpath.sh | 6 ++-- 19 files changed, 85 insertions(+), 8 deletions(-) delete mode 100755 tests/no-rpath create mode 100755 tests/no-rpath-prebuild.sh create mode 100755 tests/no-rpath-prebuild/no-rpath-amd64 create mode 100755 tests/no-rpath-prebuild/no-rpath-armel create mode 100755 tests/no-rpath-prebuild/no-rpath-armhf create mode 100755 tests/no-rpath-prebuild/no-rpath-hurd-i386 create mode 100755 tests/no-rpath-prebuild/no-rpath-i386 create mode 100755 tests/no-rpath-prebuild/no-rpath-ia64 create mode 100755 tests/no-rpath-prebuild/no-rpath-kfreebsd-amd64 create mode 100755 tests/no-rpath-prebuild/no-rpath-kfreebsd-i386 create mode 100755 tests/no-rpath-prebuild/no-rpath-mips create mode 100755 tests/no-rpath-prebuild/no-rpath-mipsel create mode 100755 tests/no-rpath-prebuild/no-rpath-powerpc create mode 100755 tests/no-rpath-prebuild/no-rpath-s390 create mode 100755 tests/no-rpath-prebuild/no-rpath-sh4 create mode 100755 tests/no-rpath-prebuild/no-rpath-sparc create mode 100644 tests/no-rpath.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 9a38df6..fb98023 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,15 +1,43 @@ -check_PROGRAMS = simple main main-scoped big-dynstr +check_PROGRAMS = simple main main-scoped big-dynstr no-rpath -TESTS = plain-fail.sh plain-run.sh shrink-rpath.sh set-interpreter-short.sh \ +no_rpath_arch_TESTS = \ + no-rpath-amd64.sh \ + no-rpath-armel.sh \ + no-rpath-armhf.sh \ + no-rpath-hurd-i386.sh \ + no-rpath-i386.sh \ + no-rpath-ia64.sh \ + no-rpath-kfreebsd-amd64.sh \ + no-rpath-kfreebsd-i386.sh \ + no-rpath-mips.sh \ + no-rpath-mipsel.sh \ + no-rpath-powerpc.sh \ + no-rpath-s390.sh \ + no-rpath-sh4.sh \ + no-rpath-sparc.sh + +XFAIL_TESTS = no-rpath-ia64.sh + +src_TESTS = \ + plain-fail.sh plain-run.sh shrink-rpath.sh set-interpreter-short.sh \ set-interpreter-long.sh set-rpath.sh no-rpath.sh big-dynstr.sh \ set-rpath-library.sh -EXTRA_DIST = no-rpath $(TESTS) + +build_TESTS = \ + $(no_rpath_arch_TESTS) + +TESTS= $(src_TESTS) $(build_TESTS) + +EXTRA_DIST = no-rpath-prebuild $(src_TESTS) no-rpath-prebuild.sh TESTS_ENVIRONMENT = PATCHELF_DEBUG=1 +$(no_rpath_arch_TESTS): no-rpath-prebuild.sh + @ln -s $< $@ + CLEANFILES = big-dynstr.c clean-local: - $(RM) -r scratch + $(RM) -r scratch $(no_rpath_arch_TESTS) # by default, use -fpic to compile AM_CFLAGS = -fpic @@ -62,3 +90,7 @@ libbar_so_LDFLAGS = $(LDFLAGS_sharedlib) -Wl,-rpath,`pwd`/no-such-path libbar_scoped_so_SOURCES = bar.c libbar_scoped_so_LDFLAGS = $(LDFLAGS_sharedlib) +no_rpath_SOURCES = no-rpath.c +# no -fpic for no-rpath.o +no_rpath_CFLAGS = + diff --git a/tests/no-rpath b/tests/no-rpath deleted file mode 100755 index b454dfe..0000000 Binary files a/tests/no-rpath and /dev/null differ diff --git a/tests/no-rpath-prebuild.sh b/tests/no-rpath-prebuild.sh new file mode 100755 index 0000000..0fc96d2 --- /dev/null +++ b/tests/no-rpath-prebuild.sh @@ -0,0 +1,41 @@ +#! /bin/sh -e +ARCH="$1" +SCRATCH=scratch/no-rpath-$ARCH + +if [ -z "$ARCH" ]; then + ARCH=$(basename $0 .sh | sed -e 's/.*-//') +fi + +if [ -z "$ARCH" ] || [ $ARCH = prebuild ] ; then + echo "Architecture required" + exit 1 +fi + +no_rpath_bin="${srcdir}/no-rpath-prebuild/no-rpath-$ARCH" + +if [ ! -f $no_rpath_bin ]; then + echo "no 'no-rpath' binary for '$ARCH' in '${srcdir}/no-rpath-prebuild'" + exit 1 +fi + +rm -rf ${SCRATCH} +mkdir -p ${SCRATCH} + +cp $no_rpath_bin ${SCRATCH}/no-rpath + +oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath) +if test -n "$oldRPath"; then exit 1; fi +../src/patchelf \ + --set-interpreter "$(../src/patchelf --print-interpreter ../src/patchelf)" \ + --set-rpath /foo:/bar:/xxxxxxxxxxxxxxx ${SCRATCH}/no-rpath + +newRPath=$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath) +if ! echo "$newRPath" | grep -q '/foo:/bar'; then + echo "incomplete RPATH" + exit 1 +fi + +if [ "$(../src/patchelf --print-interpreter $no_rpath_bin)" \ + = "$(../src/patchelf --print-interpreter ../src/patchelf)" ]; then + cd ${SCRATCH} && ./no-rpath +fi diff --git a/tests/no-rpath-prebuild/no-rpath-amd64 b/tests/no-rpath-prebuild/no-rpath-amd64 new file mode 100755 index 0000000..f457704 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-amd64 differ diff --git a/tests/no-rpath-prebuild/no-rpath-armel b/tests/no-rpath-prebuild/no-rpath-armel new file mode 100755 index 0000000..8a9f879 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-armel differ diff --git a/tests/no-rpath-prebuild/no-rpath-armhf b/tests/no-rpath-prebuild/no-rpath-armhf new file mode 100755 index 0000000..aaaef60 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-armhf differ diff --git a/tests/no-rpath-prebuild/no-rpath-hurd-i386 b/tests/no-rpath-prebuild/no-rpath-hurd-i386 new file mode 100755 index 0000000..762c451 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-hurd-i386 differ diff --git a/tests/no-rpath-prebuild/no-rpath-i386 b/tests/no-rpath-prebuild/no-rpath-i386 new file mode 100755 index 0000000..07b3821 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-i386 differ diff --git a/tests/no-rpath-prebuild/no-rpath-ia64 b/tests/no-rpath-prebuild/no-rpath-ia64 new file mode 100755 index 0000000..4b65d7c Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-ia64 differ diff --git a/tests/no-rpath-prebuild/no-rpath-kfreebsd-amd64 b/tests/no-rpath-prebuild/no-rpath-kfreebsd-amd64 new file mode 100755 index 0000000..d7a2644 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-kfreebsd-amd64 differ diff --git a/tests/no-rpath-prebuild/no-rpath-kfreebsd-i386 b/tests/no-rpath-prebuild/no-rpath-kfreebsd-i386 new file mode 100755 index 0000000..36c0ed3 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-kfreebsd-i386 differ diff --git a/tests/no-rpath-prebuild/no-rpath-mips b/tests/no-rpath-prebuild/no-rpath-mips new file mode 100755 index 0000000..2cc2d28 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-mips differ diff --git a/tests/no-rpath-prebuild/no-rpath-mipsel b/tests/no-rpath-prebuild/no-rpath-mipsel new file mode 100755 index 0000000..0a6ae88 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-mipsel differ diff --git a/tests/no-rpath-prebuild/no-rpath-powerpc b/tests/no-rpath-prebuild/no-rpath-powerpc new file mode 100755 index 0000000..9abb07e Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-powerpc differ diff --git a/tests/no-rpath-prebuild/no-rpath-s390 b/tests/no-rpath-prebuild/no-rpath-s390 new file mode 100755 index 0000000..1334eab Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-s390 differ diff --git a/tests/no-rpath-prebuild/no-rpath-sh4 b/tests/no-rpath-prebuild/no-rpath-sh4 new file mode 100755 index 0000000..6135f0a Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-sh4 differ diff --git a/tests/no-rpath-prebuild/no-rpath-sparc b/tests/no-rpath-prebuild/no-rpath-sparc new file mode 100755 index 0000000..a87bb59 Binary files /dev/null and b/tests/no-rpath-prebuild/no-rpath-sparc differ diff --git a/tests/no-rpath.c b/tests/no-rpath.c new file mode 100644 index 0000000..e6a5b85 --- /dev/null +++ b/tests/no-rpath.c @@ -0,0 +1,6 @@ +#include + +int main() { + printf("Hello world\n"); + return 0; +} diff --git a/tests/no-rpath.sh b/tests/no-rpath.sh index 20c720c..3efa7f1 100755 --- a/tests/no-rpath.sh +++ b/tests/no-rpath.sh @@ -4,7 +4,7 @@ SCRATCH=scratch/$(basename $0 .sh) rm -rf ${SCRATCH} mkdir -p ${SCRATCH} -cp ${srcdir}/no-rpath ${SCRATCH}/ +cp no-rpath ${SCRATCH}/ oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath) if test -n "$oldRPath"; then exit 1; fi @@ -18,6 +18,4 @@ if ! echo "$newRPath" | grep -q '/foo:/bar'; then exit 1 fi -if [ "$(uname -m)" = i686 -a "$(uname -s)" = Linux ]; then - cd ${SCRATCH} && ./no-rpath -fi +cd ${SCRATCH} && ./no-rpath -- cgit v0.12