File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,8 @@ src_TESTS = \
39
39
basic-flags.sh \
40
40
set-empty-rpath.sh \
41
41
phdr-corruption.sh \
42
- replace-needed.sh
42
+ replace-needed.sh \
43
+ replace-add-needed.sh
43
44
44
45
build_TESTS = \
45
46
$(no_rpath_arch_TESTS )
Original file line number Diff line number Diff line change
1
+ #! /bin/sh -e
2
+ SCRATCH=scratch/$( basename $0 .sh)
3
+ PATCHELF=$( readlink -f " ../src/patchelf" )
4
+
5
+ rm -rf ${SCRATCH}
6
+ mkdir -p ${SCRATCH}
7
+
8
+ cp simple ${SCRATCH} /
9
+ cp libfoo.so ${SCRATCH} /
10
+ cp libbar.so ${SCRATCH} /
11
+
12
+
13
+ pushd ${SCRATCH}
14
+
15
+ libcldd=$( ldd ./simple | grep -oP " (?<=libc.so.6 => )[^ ]+" )
16
+
17
+ # We have to set the soname on these libraries
18
+ ${PATCHELF} --set-soname libbar.so ./libbar.so
19
+
20
+ # Add a libbar.so so we can rewrite it later
21
+ ${PATCHELF} --add-needed libbar.so ./simple
22
+
23
+ ${PATCHELF} --replace-needed libc.so.6 ${libcldd} \
24
+ --replace-needed libbar.so $( readlink -f ./libbar.so) \
25
+ --add-needed $( readlink -f ./libfoo.so) \
26
+ ./simple
27
+
28
+ exitCode=0
29
+ ./simple || exitCode=$?
30
+
31
+ if test " $exitCode " ! = 0; then
32
+ ldd ./simple
33
+ exit 1
34
+ fi
You can’t perform that action at this time.
0 commit comments