From a71334dc2e2d10e57fed4b6dfc902420ce917e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 21 Aug 2021 09:38:46 +0200 Subject: add failing test for .dynamic == NOBITS --- .gitignore | 1 + tests/Makefile.am | 17 +++++++++++++++-- tests/no-dynamic-section.sh | 4 ++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100755 tests/no-dynamic-section.sh diff --git a/.gitignore b/.gitignore index ef4abeb..8fcfb2a 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ Makefile /tests/too-many-strtab /tests/big-dynstr* /tests/main-scoped +/tests/libbig-dynstr.debug diff --git a/tests/Makefile.am b/tests/Makefile.am index 2196401..90fe906 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,7 @@ LIBS = +STRIP ?= strip + check_PROGRAMS = simple main too-many-strtab main-scoped big-dynstr no-rpath contiguous-note-sections no_rpath_arch_TESTS = \ @@ -32,7 +34,8 @@ src_TESTS = \ invalid-elf.sh \ endianness.sh \ contiguous-note-sections.sh \ - no-gnu-hash.sh + no-gnu-hash.sh \ + no-dynamic-section.sh build_TESTS = \ $(no_rpath_arch_TESTS) @@ -73,13 +76,23 @@ 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 + for i in $$(seq 1 2000); do echo "void f$$i(void) { };"; done >> big-dynstr.c nodist_big_dynstr_SOURCES = big-dynstr.c big_dynstr_LDADD = -lfoo $(AM_LDADD) big_dynstr_DEPENDENCIES = libfoo.so big_dynstr_LDFLAGS = $(LDFLAGS_local) +# somehow bug does not trigger if we use +# normal autotools rules to build the program: +# https://github.com/NixOS/patchelf/pull/303 +libbig-dynstr.so: big-dynstr.c + $(CC) -fPIC -shared -o $@ $< +libbig-dynstr.debug: libbig-dynstr.so + $(STRIP) --only-keep-debug libbig-dynstr.so -o libbig-dynstr.debug +check_DATA = libbig-dynstr.debug + + # 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 diff --git a/tests/no-dynamic-section.sh b/tests/no-dynamic-section.sh new file mode 100755 index 0000000..3e74b38 --- /dev/null +++ b/tests/no-dynamic-section.sh @@ -0,0 +1,4 @@ +#! /bin/sh -e + +# print rpath on library with stripped dynamic section +../src/patchelf --print-rpath libbig-dynstr.debug -- cgit v1.2.1