forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpie_test.sh
More file actions
executable file
·37 lines (29 loc) · 895 Bytes
/
pie_test.sh
File metadata and controls
executable file
·37 lines (29 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
set -e
ENVOY_BIN="${TEST_SRCDIR}/envoy/source/exe/envoy-static"
if [[ $(uname) == "Darwin" ]]; then
echo "Skipping on macOS."
exit 0
fi
# Try to find llvm-readelf, failing that fallback to non-hermetic readelf in PATH
READELF="$(find "${RUNFILES_DIR}" -name llvm-readelf -type f | head -n1 || :)"
if [[ -z "$READELF" ]]; then
READELF="$(command -v llvm-readelf || :)"
fi
if [[ -z "$READELF" ]]; then
READELF="$(command -v readelf || :)"
fi
if [[ -z "$READELF" ]]; then
echo "Unable to find readelf binary" >&2
exit 1
fi
if "$READELF" -hW "${ENVOY_BIN}" | grep "Type" | grep -o "DYN (Shared object file)"; then
echo "${ENVOY_BIN} is a PIE!"
exit 0
fi
if "$READELF" -hW "${ENVOY_BIN}" | grep "Type" | grep -o "DYN (Position-Independent Executable file)"; then
echo "${ENVOY_BIN} is a PIE!"
exit 0
fi
echo "${ENVOY_BIN} is not a PIE!"
exit 1