Created
April 24, 2023 18:51
-
-
Save rcoup/2e742a8792907c41c39938ceb9a4f036 to your computer and use it in GitHub Desktop.
Revisions
-
rcoup created this gist
Apr 24, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ #!/bin/bash set -eu command -v eu-elflint >/dev/null || (echo "eu-elflint not found, install elfutils"; exit 1) command -v scanelf >/dev/null || (echo "scanelf not found, install pax-utils"; exit 1) BINARIES=$(scanelf -EET_EXEC -RBF %F "${1-.}") ERRS=0 for BINARY in $BINARIES; do echo -e "\n$BINARY" if [[ "$(scanelf -k '.go.buildinfo' "$BINARY" -q)" == .go.buildinfo* ]]; then # go binary echo "... is a Golang binary. elflint will return errors" fi if ! eu-elflint --gnu-ld "$BINARY"; then ERRS=$((ERRS+1)) fi done if [ "$ERRS" -gt 0 ]; then echo -e "\n$ERRS errors encountered during ELF binary validation" exit 1 else echo -e "\nELF binaries validated ok" fi