@@ -60,6 +60,16 @@ config LLD_VERSION
default $(ld-version) if LD_IS_LLD
default 0
+config OBJDUMP_IS_GNU
+ def_bool $(success,test "$(objdump-name)" = objdump)
+
+config OBJDUMP_IS_LLVM
+ def_bool $(success,test "$(objdump-name)" = llvm-objdump)
+
+config OBJDUMP_VERSION
+ int
+ default $(objdump-version)
+
config RUSTC_VERSION
int
default $(rustc-version)
@@ -58,6 +58,12 @@ $(error-if,$(success,test -z "$(ld-info)"),Sorry$(comma) this linker is not supp
ld-name := $(shell,set -- $(ld-info) && echo $1)
ld-version := $(shell,set -- $(ld-info) && echo $2)
+# Get the objdump name, version, and error out if it is not supported.
+objdump-info := $(shell,$(srctree)/scripts/objdump-version.sh $(OBJDUMP))
+$(error-if,$(success,test -z "$(objdump-info)"),Sorry$(comma) this objdump is not supported.)
+objdump-name := $(shell,set -- $(objdump-info) && echo $1)
+objdump-version := $(shell,set -- $(objdump-info) && echo $2)
+
# machine bit flags
# $(m32-flag): -m32 if the compiler supports it, or an empty string otherwise.
# $(m64-flag): -m64 if the compiler supports it, or an empty string otherwise.
new file mode 100755
@@ -0,0 +1,69 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Print the objdump name and its version in a 5 or 6-digit form.
+# Also, perform the minimum version check.
+
+set -e
+
+# Convert the version string x.y.z to a canonical 5 or 6-digit form.
+get_canonical_version()
+{
+ IFS=.
+ set -- $1
+
+ # If the 2nd or 3rd field is missing, fill it with a zero.
+ #
+ # The 4th field, if present, is ignored.
+ # This occurs in development snapshots as in 2.35.1.20201116
+ echo $((10000 * $1 + 100 * ${2:-0} + ${3:-0}))
+}
+
+orig_args="$@"
+
+# Get the first line of the --version output.
+IFS='
+'
+set -- $(LC_ALL=C "$@" --version)
+
+# Split the line on spaces.
+IFS=' '
+set -- $1
+
+min_tool_version=$(dirname $0)/min-tool-version.sh
+
+if [ "$1" = GNU -a "$2" = objdump ]; then
+ shift $(($# - 1))
+ version=$1
+ min_version=$($min_tool_version binutils)
+ disp_name="GNU objdump"
+else
+ while [ $# -gt 1 -a "$1" != "LLVM" ]; do
+ shift
+ done
+
+ if [ "$1" = LLVM ]; then
+ version=$3
+ min_version=$($min_tool_version llvm)
+ disp_name="llvm-objdump"
+ else
+ echo "$orig_args: unknown objdump" >&2
+ exit 1
+ fi
+fi
+
+version=${version%%[!0-9.]*}
+
+cversion=$(get_canonical_version $version)
+min_cversion=$(get_canonical_version $min_version)
+
+if [ "$cversion" -lt "$min_cversion" ]; then
+ echo >&2 "***"
+ echo >&2 "*** objdump is too old."
+ echo >&2 "*** Your $disp_name version: $version"
+ echo >&2 "*** Minimum $disp_name version: $min_version"
+ echo >&2 "***"
+ exit 1
+fi
+
+echo objdump $cversion
Similar to ld-version, add a way to check the version of objdump. This should most of the time end up being the binutils version or the llvm version. Signed-off-by: Charlie Jenkins <charlie@rivosinc.com> --- init/Kconfig | 10 +++++++ scripts/Kconfig.include | 6 ++++ scripts/objdump-version.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+)