Skip to content

Commit 6a88311

Browse files
committed
Check for -static-pie support before testing support
1 parent b94da2b commit 6a88311

File tree

3 files changed

+49
-8
lines changed

3 files changed

+49
-8
lines changed

src/test/run-make/static-pie/Makefile

+9-8
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
# How to manually run this
88
# $ ./x.py test --target x86_64-unknown-linux-[musl,gnu] src/test/run-make/static-pie
99

10-
all:
11-
$(RUSTC) --target $(TARGET) -C target-feature=+crt-static test-aslr.rs
12-
# Check that no dynamic interpreter is set
13-
! readelf -l $(call RUN_BINFILE,test-aslr) | $(CGREP) INTERP
14-
# Check that we have a dynamic executable
15-
readelf -l $(call RUN_BINFILE,test-aslr) | $(CGREP) DYNAMIC
16-
# Check for address space layout randomization
17-
$(call RUN,test-aslr) --test-aslr
10+
all: test-clang test-gcc
11+
12+
test-%:
13+
if ./check_$*_version.sh; then\
14+
${RUSTC} -Clinker=$* -Clinker-flavor=gcc --target ${TARGET} -C target-feature=+crt-static test-aslr.rs; \
15+
! readelf -l $(call RUN_BINFILE,test-aslr) | $(CGREP) INTERP; \
16+
readelf -l $(call RUN_BINFILE,test-aslr) | $(CGREP) DYNAMIC; \
17+
$(call RUN,test-aslr) --test-aslr; \
18+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
if command -v clang > /dev/null
6+
then
7+
CLANG_VERSION=$(echo __clang_major__ | clang -E -x c - | grep -v -e '^#' )
8+
echo "clang version $CLANG_VERSION detected"
9+
if (( $CLANG_VERSION >= 9 ))
10+
then
11+
echo "clang supports -static-pie"
12+
exit 0
13+
else
14+
echo "clang too old to support -static-pie, skipping test"
15+
exit 1
16+
fi
17+
else
18+
echo "No clang version detected"
19+
exit 2
20+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
if command -v gcc > /dev/null
6+
then
7+
GCC_VERSION=$(echo __GNUC__ | gcc -E -x c - | grep -v -e '^#' )
8+
echo "gcc version $GCC_VERSION detected"
9+
if (( $GCC_VERSION >= 8 ))
10+
then
11+
echo "gcc supports -static-pie"
12+
exit 0
13+
else
14+
echo "gcc too old to support -static-pie, skipping test"
15+
exit 1
16+
fi
17+
else
18+
echo "No gcc version detected"
19+
exit 2
20+
fi

0 commit comments

Comments
 (0)