|
| 1 | +#! /bin/sh -e |
| 2 | +set -x |
| 3 | +SCRATCH=scratch/no-rpath-pie-powerpc |
| 4 | + |
| 5 | +no_rpath_bin="${srcdir}/no-rpath-prebuild/no-rpath-pie-powerpc" |
| 6 | + |
| 7 | +if [ ! -f $no_rpath_bin ]; then |
| 8 | + echo "no 'no-rpath' binary for '$ARCH' in '${srcdir}/no-rpath-prebuild'" |
| 9 | + exit 1 |
| 10 | +fi |
| 11 | + |
| 12 | +rm -rf ${SCRATCH} |
| 13 | +mkdir -p ${SCRATCH} |
| 14 | + |
| 15 | +cp $no_rpath_bin ${SCRATCH}/no-rpath |
| 16 | + |
| 17 | +oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath) |
| 18 | +if test -n "$oldRPath"; then exit 1; fi |
| 19 | +../src/patchelf \ |
| 20 | + --set-interpreter "$(../src/patchelf --print-interpreter ../src/patchelf)" \ |
| 21 | + --set-rpath /foo:/bar:/xxxxxxxxxxxxxxx ${SCRATCH}/no-rpath |
| 22 | + |
| 23 | +newRPath=$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath) |
| 24 | +if ! echo "$newRPath" | grep -q '/foo:/bar'; then |
| 25 | + echo "incomplete RPATH" |
| 26 | + exit 1 |
| 27 | +fi |
| 28 | + |
| 29 | +# Tests for powerpc PIE endianness regressions |
| 30 | +readelfData=$(readelf -l ${SCRATCH}/no-rpath 2>&1) |
| 31 | + |
| 32 | +if [ $(echo "$readelfData" | grep --count "PHDR") != 1 ]; then |
| 33 | + # Triggered if PHDR errors appear on stderr |
| 34 | + echo "Unexpected number of occurences of PHDR in readelf results" |
| 35 | + exit 1 |
| 36 | +fi |
| 37 | + |
| 38 | +virtAddr=$(echo "$readelfData" | grep "PHDR" | awk '{print $3}') |
| 39 | +if [ "$virtAddr" != "0x00000034" ]; then |
| 40 | + # Triggered if the virtual address is the incorrect endianness |
| 41 | + echo "Unexpected virt addr, expected [0x00000034] got [$virtAddr]" |
| 42 | + exit 1 |
| 43 | +fi |
| 44 | + |
| 45 | +echo "$readelfData" | grep "LOAD" | while read -r line ; do |
| 46 | + align=$(echo "$line" | awk '{print $NF}') |
| 47 | + if [ "$align" != "0x10000" ]; then |
| 48 | + # Triggered if the target arch was not detected properly |
| 49 | + echo "Unexpected Align for LOAD segment, expected [0x10000] got [$align]" |
| 50 | + echo "Load segment: [$line]" |
| 51 | + exit 1 |
| 52 | + fi |
| 53 | +done |
| 54 | + |
0 commit comments