mirror of
https://github.com/NixOS/patchelf.git
synced 2025-10-20 13:03:57 +08:00

Parsing this file results in patchelf segfaulting at: Program received signal SIGSEGV, Segmentation fault. std::vector<Elf32_Phdr, std::allocator<Elf32_Phdr> >::_M_realloc_insert<Elf32_Phdr const&> (this=0x7fffffff80a8, __position=..., __args=...) at /nix/store/h31cy7jm6g7cfqbhc5pm4rf9c53i3qfb-gcc-9.3.0/include/c++/9.3.0/bits/vector.tcc:449 449 _Alloc_traits::construct(this->_M_impl, (gdb) bt at /nix/store/h31cy7jm6g7cfqbhc5pm4rf9c53i3qfb-gcc-9.3.0/include/c++/9.3.0/bits/vector.tcc:449 at /nix/store/h31cy7jm6g7cfqbhc5pm4rf9c53i3qfb-gcc-9.3.0/include/c++/9.3.0/bits/stl_vector.h:1195 this=0x7fffffff8088, fileContents=...) at patchelf.cc:421
41 lines
1.0 KiB
Bash
Executable File
41 lines
1.0 KiB
Bash
Executable File
#! /bin/sh -u
|
|
|
|
# Usage: killed_by_signal $?
|
|
#
|
|
# Returns true if the exit code indicates that the program was killed
|
|
# by a signal. This works because the exit code of processes that were
|
|
# killed by a signal is 128 plus the signal number.
|
|
killed_by_signal() {
|
|
[ $1 -ge 128 ]
|
|
}
|
|
|
|
|
|
# The directory containing all our input files.
|
|
TEST_DIR=$(dirname $(readlink -f $0))/invalid-elf
|
|
|
|
# Each test case is listed here. The names should roughly indicate
|
|
# what makes the given ELF file invalid.
|
|
TEST_CASES="invalid-shrstrtab-idx invalid-shrstrtab-size invalid-shrstrtab-zero
|
|
invalid-shrstrtab-nonterm invalid-shdr-name invalid-phdr-offset"
|
|
|
|
FAILED_TESTS=""
|
|
|
|
for tcase in $TEST_CASES; do
|
|
if [ ! -r "$TEST_DIR/$tcase" ]; then
|
|
echo "Cannot read test case: $tcase"
|
|
exit 1
|
|
fi
|
|
|
|
../src/patchelf --output /dev/null "$TEST_DIR/$tcase"
|
|
if killed_by_signal $?; then
|
|
FAILED_TESTS="$FAILED_TESTS $tcase"
|
|
fi
|
|
done
|
|
|
|
if [ -z "$FAILED_TESTS" ]; then
|
|
exit 0
|
|
else
|
|
echo "Failed tests: $FAILED_TESTS"
|
|
exit 1
|
|
fi
|