Skip to content

Commit 86fa688

Browse files
committed
tests
1 parent 62dcdd2 commit 86fa688

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

tests/Makefile.am

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ check_DATA = libbig-dynstr.debug
110110
# - with libtool, it is difficult to control options
111111
# - with libtool, it is not possible to compile convenience *dynamic* libraries :-(
112112
check_PROGRAMS += libfoo.so libfoo-scoped.so libbar.so libbar-scoped.so libsimple.so libbuildid.so libtoomanystrtab.so \
113-
phdr-corruption.so
113+
phdr-corruption.so many-syms-main libmany-syms.so
114114

115115
libbuildid_so_SOURCES = simple.c
116116
libbuildid_so_LDFLAGS = $(LDFLAGS_sharedlib) -Wl,--build-id
@@ -138,6 +138,14 @@ too_many_strtab_SOURCES = too-many-strtab.c too-many-strtab2.s
138138
libtoomanystrtab_so_SOURCES = too-many-strtab.c too-many-strtab2.s
139139
libtoomanystrtab_so_LDFLAGS = $(LDFLAGS_sharedlib)
140140

141+
many_syms_main_SOURCES = many-syms-main.c
142+
many_syms_main_LDFLAGS = $(LDFLAGS_local)
143+
many_syms_main_LDADD = -lmany-syms $(AM_LDADD)
144+
many_syms_main_DEPENDENCIES = libmany-syms.so
145+
many_syms_main_CFLAGS = -pie
146+
libmany_syms_so_SOURCES = many-syms.c
147+
libmany_syms_so_LDFLAGS = $(LDFLAGS_sharedlib)
148+
141149
no_rpath_SOURCES = no-rpath.c
142150
# no -fpic for no-rpath.o
143151
no_rpath_CFLAGS =
@@ -149,3 +157,12 @@ contiguous_note_sections_CFLAGS = -pie
149157
phdr_corruption_so_SOURCES = void.c phdr-corruption.ld
150158
phdr_corruption_so_LDFLAGS = -nostdlib -shared -Wl,-T$(srcdir)/phdr-corruption.ld
151159
phdr_corruption_so_CFLAGS =
160+
161+
many-syms.c:
162+
i=1; while [ $$i -le 2000 ]; do echo "void f$$i() {};"; i=$$(($$i + 1)); done > $@
163+
164+
many-syms-main.c:
165+
echo "int main() {" > $@
166+
i=1; while [ $$i -le 2000 ]; do echo "void f$$i(); f$$i();"; i=$$(($$i + 1)); done >> $@
167+
echo "}" >> $@
168+

tests/rename-dynamic-symbols.sh

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@ PATCHELF=$(readlink -f "../src/patchelf")
55
rm -rf ${SCRATCH}
66
mkdir -p ${SCRATCH}
77

8-
# Use the c++ standard library used by patchelf for our testing
9-
# It helps exercising a large number of symbols, versioning and validate
10-
# the feature in a more real scenario
11-
full_lib_name=$(ldd ${PATCHELF} | awk '/ => / { print $3 }' | grep "c++" | head -n 1)
12-
echo "The library used in this test is: ${full_lib_name}"
8+
full_main_name="${PWD}/many-syms-main"
9+
full_lib_name="${PWD}/libmany-syms.so"
10+
chmod -w $full_lib_name $full_main_name
1311

14-
lib_name="$(basename $full_lib_name)"
1512
suffix="_special_suffix"
1613

1714
cd ${SCRATCH}
@@ -71,18 +68,17 @@ diff orig_rel map_rel_r > diff_orig_rel_map_rel_r || exit 1
7168
# 4. Run patchelf with the modified dependencies
7269
###############################################################################
7370

74-
# Create the map
71+
echo "# Create the map"
7572
list_symbols --defined-only $full_lib_name | cut -d@ -f1 | sort -u | awk "{printf \"%s %s${suffix}\n\",\$1,\$1}" > map
7673

77-
# Copy all dependencies
74+
echo "# Copy all dependencies"
7875
mkdir env
7976
cd env
80-
patchelf_dependencies="$(ldd ${PATCHELF} | awk '/ => / { print $3 }')"
81-
cp ${PATCHELF} $patchelf_dependencies .
77+
cp $full_lib_name $full_main_name .
8278

83-
# Apply renaming
79+
echo "# Apply renaming"
8480
chmod +w *
8581
${PATCHELF} --rename-dynamic-symbols ../map *
8682

87-
# Run the patched tool and libraries
88-
env LD_BIND_NOW=1 LD_LIBRARY_PATH=. ./patchelf --version
83+
echo "# Run the patched tool and libraries"
84+
env LD_BIND_NOW=1 LD_LIBRARY_PATH=${PWD} ./many-syms-main

0 commit comments

Comments
 (0)