Skip to content

Commit a71fa6b

Browse files
authored
Merge pull request #290 from ius/endianness-fix
tests: add e_machine endianness test (#269)
2 parents add92c1 + f823fa3 commit a71fa6b

File tree

7 files changed

+28
-0
lines changed

7 files changed

+28
-0
lines changed

tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ src_TESTS = \
2828
no-rpath-pie-powerpc.sh \
2929
build-id.sh \
3030
invalid-elf.sh \
31+
endianness.sh \
3132
contiguous_note_sections.sh
3233

3334
build_TESTS = \

tests/endianness.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#! /bin/sh -e
2+
SCRATCH=scratch/$(basename $0 .sh)
3+
PATCHELF="../src/patchelf"
4+
5+
for arch in ppc64 ppc64le; do
6+
rm -rf ${SCRATCH}
7+
mkdir -p ${SCRATCH}
8+
9+
cp endianness/${arch}/main endianness/${arch}/libtest.so ${SCRATCH}/
10+
11+
rpath="${PWD}/${SCRATCH}"
12+
13+
# set rpath to scratch dir
14+
${PATCHELF} --output ${SCRATCH}/main-rpath --set-rpath $rpath ${SCRATCH}/main
15+
16+
# attempt to shrink rpath, should not result in empty rpath
17+
${PATCHELF} --output ${SCRATCH}/main-shrunk --shrink-rpath --debug ${SCRATCH}/main-rpath
18+
19+
# check whether rpath is still present
20+
if ! ${PATCHELF} --print-rpath ${SCRATCH}/main-shrunk | grep -q "$rpath"; then
21+
echo "rpath was removed for ${arch}"
22+
exit 1
23+
fi
24+
done

tests/endianness/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
all:
2+
$(CC) -xc -nostdlib -shared -o libtest.so - <<< 'void test() {}'
3+
$(CC) -xc -nostdlib -L. -ltest -o main - <<< 'void _start() {}'

tests/endianness/ppc64/libtest.so

65.2 KB
Binary file not shown.

tests/endianness/ppc64/main

65.4 KB
Binary file not shown.
65.2 KB
Binary file not shown.

tests/endianness/ppc64le/main

65.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)