|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -# Copyright (C) 2015-2020 Kristofer Berggren |
| 3 | +# Copyright (C) 2015-2021 Kristofer Berggren |
4 | 4 | # All rights reserved. |
5 | 5 | # |
6 | 6 | # stackusage is distributed under the BSD 3-Clause license, see LICENSE for details. |
@@ -43,15 +43,33 @@ showusage() |
43 | 43 |
|
44 | 44 | showversion() |
45 | 45 | { |
46 | | - echo "stackusage v1.14" |
| 46 | + echo "stackusage v1.15" |
47 | 47 | echo "" |
48 | | - echo "Copyright (C) 2015-2020 Kristofer Berggren" |
| 48 | + echo "Copyright (C) 2015-2021 Kristofer Berggren" |
49 | 49 | echo "" |
50 | 50 | echo "stackusage is distributed under the BSD 3-Clause license." |
51 | 51 | echo "" |
52 | 52 | echo "Written by Kristofer Berggren" |
53 | 53 | } |
54 | 54 |
|
| 55 | +check_arch_compat() |
| 56 | +{ |
| 57 | + LIBPATH="${1}" |
| 58 | + PRGPATH="$(which ${2})" |
| 59 | + if [[ "${PRGPATH}" != "" ]]; then |
| 60 | + PRGARCH=$(file -b ${PRGPATH} | awk '{print $1 " " $2}') |
| 61 | + LIBARCH=$(file -b ${LIBPATH} | awk '{print $1 " " $2}') |
| 62 | + PRGBITS=$(file -b ${PRGPATH} | awk '{print $2}' | awk -F'-' '{print $1}') |
| 63 | + LIBBITS=$(file -b ${LIBPATH} | awk '{print $2}' | awk -F'-' '{print $1}') |
| 64 | + if [[ "${PRGBITS}" =~ ^(32|64)$ ]] && [[ "${LIBBITS}" =~ ^(32|64)$ ]] && \ |
| 65 | + [[ "${PRGARCH}" != "${LIBARCH}" ]]; then |
| 66 | + echo "warning: $(basename ${LIBPATH}) architecture (${LIBARCH}) does not appear" |
| 67 | + echo "to match ${PRGPATH} architecture (${PRGARCH}), analysis may fail." |
| 68 | + echo "see https://github.com/d99kris/stackusage#technical-details" |
| 69 | + fi |
| 70 | + fi |
| 71 | +} |
| 72 | + |
55 | 73 | if [ "${1}" == "--help" ] ; then |
56 | 74 | showusage |
57 | 75 | exit 0 |
@@ -155,6 +173,9 @@ while [ "${LIBPATHS[CNT]}" != "" ]; do |
155 | 173 | LIBPATH="${LIBPATHS[CNT]}" |
156 | 174 | if [ -e "${LIBPATH}" ]; then |
157 | 175 |
|
| 176 | + # Check if libstackusage is compatible with program to analyze |
| 177 | + check_arch_compat "${LIBPATH}" "${1}" |
| 178 | + |
158 | 179 | # Run program |
159 | 180 | if [ "${DEBUG}" == "0" ]; then |
160 | 181 | SU_FILE="${TMPLOG}${OUTFILE}" \ |
|
0 commit comments