tests: add e_machine endianness test (#269)

This commit is contained in:
Joerie de Gram 2021-07-24 00:50:09 +02:00
parent 7ec8edbe09
commit 4052850d22
7 changed files with 29 additions and 1 deletions

View File

@ -27,7 +27,8 @@ src_TESTS = \
output-flag.sh \
no-rpath-pie-powerpc.sh \
build-id.sh \
invalid-elf.sh
invalid-elf.sh \
endianness.sh
build_TESTS = \
$(no_rpath_arch_TESTS)

24
tests/endianness.sh Executable file
View File

@ -0,0 +1,24 @@
#! /bin/sh -e
SCRATCH=scratch/$(basename $0 .sh)
PATCHELF="../src/patchelf"
for arch in ppc64 ppc64le; do
rm -rf ${SCRATCH}
mkdir -p ${SCRATCH}
cp endianness/${arch}/main endianness/${arch}/libtest.so ${SCRATCH}/
rpath="${PWD}/${SCRATCH}"
# set rpath to scratch dir
${PATCHELF} --output ${SCRATCH}/main-rpath --set-rpath $rpath ${SCRATCH}/main
# attempt to shrink rpath, should not result in empty rpath
${PATCHELF} --output ${SCRATCH}/main-shrunk --shrink-rpath --debug ${SCRATCH}/main-rpath
# check whether rpath is still present
if ! ${PATCHELF} --print-rpath ${SCRATCH}/main-shrunk | grep -q "$rpath"; then
echo "rpath was removed for ${arch}"
exit 1
fi
done

View File

@ -0,0 +1,3 @@
all:
$(CC) -xc -nostdlib -shared -o libtest.so - <<< 'void test() {}'
$(CC) -xc -nostdlib -L. -ltest -o main - <<< 'void _start() {}'

BIN
tests/endianness/ppc64/libtest.so Executable file

Binary file not shown.

BIN
tests/endianness/ppc64/main Executable file

Binary file not shown.

Binary file not shown.

BIN
tests/endianness/ppc64le/main Executable file

Binary file not shown.