Check for -static-pie support before testing support
This commit is contained in:
parent
b94da2bace
commit
6a88311373
3 changed files with 49 additions and 8 deletions
|
|
@ -7,11 +7,12 @@
|
|||
# How to manually run this
|
||||
# $ ./x.py test --target x86_64-unknown-linux-[musl,gnu] src/test/run-make/static-pie
|
||||
|
||||
all:
|
||||
$(RUSTC) --target $(TARGET) -C target-feature=+crt-static test-aslr.rs
|
||||
# Check that no dynamic interpreter is set
|
||||
! readelf -l $(call RUN_BINFILE,test-aslr) | $(CGREP) INTERP
|
||||
# Check that we have a dynamic executable
|
||||
readelf -l $(call RUN_BINFILE,test-aslr) | $(CGREP) DYNAMIC
|
||||
# Check for address space layout randomization
|
||||
$(call RUN,test-aslr) --test-aslr
|
||||
all: test-clang test-gcc
|
||||
|
||||
test-%:
|
||||
if ./check_$*_version.sh; then\
|
||||
${RUSTC} -Clinker=$* -Clinker-flavor=gcc --target ${TARGET} -C target-feature=+crt-static test-aslr.rs; \
|
||||
! readelf -l $(call RUN_BINFILE,test-aslr) | $(CGREP) INTERP; \
|
||||
readelf -l $(call RUN_BINFILE,test-aslr) | $(CGREP) DYNAMIC; \
|
||||
$(call RUN,test-aslr) --test-aslr; \
|
||||
fi
|
||||
|
|
|
|||
20
src/test/run-make/static-pie/check_clang_version.sh
Executable file
20
src/test/run-make/static-pie/check_clang_version.sh
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if command -v clang > /dev/null
|
||||
then
|
||||
CLANG_VERSION=$(echo __clang_major__ | clang -E -x c - | grep -v -e '^#' )
|
||||
echo "clang version $CLANG_VERSION detected"
|
||||
if (( $CLANG_VERSION >= 9 ))
|
||||
then
|
||||
echo "clang supports -static-pie"
|
||||
exit 0
|
||||
else
|
||||
echo "clang too old to support -static-pie, skipping test"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "No clang version detected"
|
||||
exit 2
|
||||
fi
|
||||
20
src/test/run-make/static-pie/check_gcc_version.sh
Executable file
20
src/test/run-make/static-pie/check_gcc_version.sh
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if command -v gcc > /dev/null
|
||||
then
|
||||
GCC_VERSION=$(echo __GNUC__ | gcc -E -x c - | grep -v -e '^#' )
|
||||
echo "gcc version $GCC_VERSION detected"
|
||||
if (( $GCC_VERSION >= 8 ))
|
||||
then
|
||||
echo "gcc supports -static-pie"
|
||||
exit 0
|
||||
else
|
||||
echo "gcc too old to support -static-pie, skipping test"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "No gcc version detected"
|
||||
exit 2
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue