|
| 1 | +#!/bin/bash |
| 2 | +# Copyright (C) 2024 Intel Corporation |
| 3 | +# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. |
| 4 | +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 5 | + |
| 6 | +BINARY=$1 |
| 7 | + |
| 8 | +if [ "$BINARY" = "" ]; then |
| 9 | + echo "Usage: $(basename $0) <binary_name>" |
| 10 | + exit 1 |
| 11 | +fi |
| 12 | + |
| 13 | +if ! which strings >/dev/null; then |
| 14 | + echo "strings command not found. Please install the binutils package." |
| 15 | + exit 1 |
| 16 | +fi |
| 17 | + |
| 18 | +# check if the binary is statically linked with libumf |
| 19 | +# or if it is the UMF library itself |
| 20 | +if [ $(strings $BINARY | grep -c -e "@(#) Intel(R) UMF") -gt 0 ]; then |
| 21 | + BIN_NO_LINK=$(readlink -f "$BINARY") |
| 22 | + FILE_INFO=$(file $BIN_NO_LINK) |
| 23 | + if [[ "$FILE_INFO" == *"libumf.so"*"ELF 64-bit LSB shared object"*"dynamically linked"* ]]; then |
| 24 | + echo "$BINARY is the UMF library ($BIN_NO_LINK)." |
| 25 | + else |
| 26 | + echo "$BINARY is statically linked with the UMF library." |
| 27 | + fi |
| 28 | + |
| 29 | + echo "Strings in $BIN_NO_LINK:" |
| 30 | + strings $BIN_NO_LINK | grep "@(#) Intel(R) UMF" |
| 31 | + exit 0 |
| 32 | +fi |
| 33 | + |
| 34 | +# check if the binary is dynamically linked with libumf |
| 35 | +if [ $(ldd $BINARY | grep -c -e "libumf.so") -gt 0 ]; then |
| 36 | + UMF_LIB=$(ldd $BINARY | grep libumf.so | awk '{ print $3 }') |
| 37 | + UMF_LIB=$(readlink -f "$UMF_LIB") |
| 38 | + echo "$BINARY is dynamically linked with the UMF library ($UMF_LIB)." |
| 39 | + echo "Strings in $UMF_LIB:" |
| 40 | + strings $UMF_LIB | grep "@(#) Intel(R) UMF" |
| 41 | + exit 0 |
| 42 | +fi |
| 43 | + |
| 44 | +echo "$BINARY does not contain magic strings of the UMF library." |
0 commit comments