Yes, with ld -v you can view the version of binutils (in your case is 2.24)

Answer from 0x2b3bfa0 on Stack Overflow
🌐
OpenGenus
iq.opengenus.org › check-binutils-version
Check binutils version
September 16, 2022 - In our case, the version of Binutils is 2.39 which is the latest version as of September 2022. Other commands to check binutils version are as follows:
Discussions

GNU binutils, get version - Page 1
GNU binutils, get version - Page 1 More on eevblog.com
🌐 eevblog.com
February 16, 2023
homebrew - MacOS 12.1 cannot find my brew install of GNU binutils - Stack Overflow
Use this path on Mac M1 /opt/homebrew/opt/binutils/bin. 2022-09-27T03:57:14.937Z+00:00 ... Thanks @MingjieLi, my installation path broke after upgrading the version. Yours gives the version-agnostic symlink. More on stackoverflow.com
🌐 stackoverflow.com
GNU binutils version | The FreeBSD Forums
How do you know what version of "GNU binutils" is built into the base system? All I could think of doing is picking out some executables that are included with the "GNU binutils" suite and use the "--version" option. Examples: ld --version or as --version Are the commands (above) the only... More on forums.freebsd.org
🌐 forums.freebsd.org
March 22, 2014
How do I find which version of gcc corressponds to which version of binutils? - Stack Overflow
Exactly as the question sounds. If there isn't a generic way to answer this question for any given version pair, can someone at least answer the specific question of whether gcc 3.4.6 and ld 2.15... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Narkive
binutils.sourceware.narkive.com › TrbaaMxy › get-the-version-of
Get the version of binutils?
All components of binutils have the same version, which is the general one. Andreas is correct. Theoretically it is possible to install different versions of each of the tools (assuming that they have been built statically), hence each tool supports its own -v (or --version) switch. But in practice no-one does this, so checking the version of any one binutil tool will give you the overall binutils installation version.
🌐
GitHub
github.com › Gallopsled › pwntools-binutils › pull › 4 › files
Update binutils source to v2.29.1 for macOS by chuanchan1116 · Pull Request #4 · Gallopsled/pwntools-binutils
binutils had already updated to v2.29.1, so I changed the url in the Formulas and fixed some problems in generate.sh. Old version of binutils-m86k and binutils-x86_64 doesn't work because o...
Author   Gallopsled
🌐
EEVblog
eevblog.com › forum › programming › gnu-binutils-get-version
GNU binutils, get version - Page 1
February 16, 2023 - GNU binutils, get version · There was an error while thanking · Thanking... XHTML · RSS · Mobile ·
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_developer_toolset › 9 › html › user_guide › chap-binutils
Chapter 4. binutils | User Guide | Red Hat Developer Toolset | 9 | Red Hat Documentation
Red Hat Developer Toolset’s ld executable path will begin with /opt. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset ld: ... The binutils provide many binary tools other than a linker and an assembler.
🌐
FreeBSD
forums.freebsd.org › base system › general
GNU binutils version | The FreeBSD Forums
March 22, 2014 - See Using newer version of GCC and binutils with the FreeBSD Ports Collection: Introduction. Also see /usr/ports/devel/binutils/pkg-descr and /usr/ports/devel/binutils/distinfo. To summarize, binutils-2.15 are in the base FreeBSD.
Find elsewhere
🌐
GNU
gnu.org › software › binutils
Binutils - GNU Project - Free Software Foundation
Releases are made from branches in the repository, and commits are often made to the branches even after the release has gone out. The branches are named binutils-M_NN-branch where M is the major component of the version number and NN is the minor component.
🌐
Gentoo Wiki
wiki.gentoo.org › wiki › Binutils
Binutils - Gentoo wiki
First list known (installed) versions: ... Select the newest profile. Either the integer number or the full profile name can be used to select the profile; below the profile name is used: ... See the upstream documentation for the appropriate man page for more detailed documentation on each utility. Note The following C file will be referenced throughout the article. ... The default linker provided by binutils which is also commonly referred to as "BFD", or "Binary File Descriptor."
Top answer
1 of 2
5

They're [probably] all the same (gold has an extra version -- see the end of this post).
But consider the rest of this answer code-golf for the best way to extract the versions.

dpkg -L binutils | grep "/usr/bin/" | xargs -i sh -c "{} --version"

Does pretty much what roadmr's does.

dpkg -L binutils | xargs -i sh -c "{} --version 2>/dev/null || exit 0"

Tries to run everything dpkg -L ... outputs. Obviously only the executables will run so we just need to redirect error (and make xargs ignore them).

dpkg -L binutils | xargs -i bash -c '[[ -x "{}" && -f "{}" ]] && {} --version'

Test that we're dealing with an executable file rather than filtering path.


sudo apt-get install parallel
dpkg -L binutils | grep /usr/bin/ | parallel {} --version
dpkg -L binutils | parallel {} --version 2>/dev/null
dpkg -L binutils | parallel '[[ -x "{}" && -f "{}" ]] && {} --version'

This time we use GNU parallel to do the same approaches. parallel lets us skip over certain inconveniences in xargs (like it not being able to skip over any non-zero exit code. man parallel is a genuinely good read.


With all that said, while shorter, all my examples fork out into a new shell (unavoidable with xargs, and sort of the point of parallel) so they're all somewhat slower than roadmr's. The first is the quickest.

Edit: Until now...

sh <(dpkg -L binutils | awk '/bin\// {print $0 " --version"}')

Only two forks (sort of) and it's as fast as the for loop (while much shorter).


Edit: They're actually not quite the same. gold has a secondary version (1.11) which the other commands don't.

$ sh <(dpkg -L binutils | awk '/bin\// {print $0 " --version"}') | \
    grep Binutils | sort -u | column -t
GNU  addr2line  (GNU  Binutils  for  Ubuntu)  2.23.52.20130913
GNU  ar         (GNU  Binutils  for  Ubuntu)  2.23.52.20130913
GNU  assembler  (GNU  Binutils  for  Ubuntu)  2.23.52.20130913
GNU  c++filt    (GNU  Binutils  for  Ubuntu)  2.23.52.20130913
GNU  dwp        (GNU  Binutils  for  Ubuntu)  2.23.52.20130913
GNU  elfedit    (GNU  Binutils  for  Ubuntu)  2.23.52.20130913
GNU  gold       (GNU  Binutils  for  Ubuntu   2.23.52.20130913)  1.11
GNU  gprof      (GNU  Binutils  for  Ubuntu)  2.23.52.20130913
GNU  ld         (GNU  Binutils  for  Ubuntu)  2.23.52.20130913
GNU  nm         (GNU  Binutils  for  Ubuntu)  2.23.52.20130913
GNU  objcopy    (GNU  Binutils  for  Ubuntu)  2.23.52.20130913
GNU  objdump    (GNU  Binutils  for  Ubuntu)  2.23.52.20130913
GNU  ranlib     (GNU  Binutils  for  Ubuntu)  2.23.52.20130913
GNU  readelf    (GNU  Binutils  for  Ubuntu)  2.23.52.20130913
GNU  size       (GNU  Binutils  for  Ubuntu)  2.23.52.20130913
GNU  strings    (GNU  Binutils  for  Ubuntu)  2.23.52.20130913
GNU  strip      (GNU  Binutils  for  Ubuntu)  2.23.52.20130913
2 of 2
2

Try this:

for util in `dpkg --listfiles binutils |grep "\/usr\/bin\/"`; do
    echo -n "$util -> "; echo "" | $util --version
done

This gets all the binaries in the binutils packages and queries each one with its --version parameter. I echo an empty string for those that expect input in the terminal.

🌐
MacPorts
ports.macports.org › port › binutils › details
binutils | MacPorts
Free Software Foundation development toolchain ("binutils") for native development. Tools are prefixed with g to avoid conflicts with original tools. + Show more Version: 2.43.1 License: GPL-3+ GitHub
🌐
Reddit
reddit.com › r/linuxquestions › cross compiling, please upgrade your binutils to 2.12.1 or newer?
r/linuxquestions on Reddit: Cross compiling, please upgrade your binutils to 2.12.1 or newer?
May 9, 2023 -

Currently I’m trying to compile Linux source 2.6.24.3 for PowerPC64 architecture(an Xbox 360, following the Free60 project as a guide). I’m on an x86_64 device so I got crosstools-ng and installed powerpc64-linux-unknown which was required for what I’m doing

Now I’ve reached an error message that a higher version of Binutils is required which I already have

*** 2.6 kernels no longer build correctly with old versions of binutils. *** Please upgrade your binutils to 2.12.1 or newer

https://imgur.com/a/yPtpU3s

Is there something I’m missing here?

I also noticed I get the same error if I try to compile from my Xbox 360 as well which is the same arch I’m targeting.

🌐
Blogger
countchu.blogspot.com › 2015 › 05 › install-binutils-in-mac-os.html
Count Chu: Install binutils in Mac OS
May 29, 2015 - We can set environment variables to build binutils. export PREFIX="$HOME/opt/cross" export TARGET=i686-elf export PATH="$PREFIX/bin:$PATH" 6) Build binutils In the ~/src/binutils-2.25 directory run the below command. ../binutils-2.24/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --disable-werror make make install 8) Check if binutils is installed.
🌐
Lindevs
lindevs.com › check-binutils-version-on-linux
Check Binutils Version on Linux | Lindevs
December 18, 2023 - The ld is the GNU linker, and it is a part of the Binutils collection. The ld command can be used to check the version of the Binutils.
Top answer
1 of 2
2

There is a special symbol called .gasversion. (with a leading and trailing dot). You can use it this way:

        .data
.if .gasversion. >= 22900
        .ascii "binutils 2.29 or newer"
.endif
.if .gasversion. >= 22800
        .ascii "binutils 2.28 or newer"
.endif

Note that this is not a preprocessor feature (as GCC does not know the GAS/BFD version and does not pass it to the preprocessor). So you have to use GAS constructs like .if and .macro to implement what you need.

Often, an alternative approach is used where the actual presence of the bug is tested in some configure script and the workaround is activated only if necessary. This means that the workaround is only used when it is absolutely required—version numbers do not reflect distribution backports which could have fixed the bug. Obviously, this only makes sense if the workaround is costly (because it introduces additional run-time overhead).

2 of 2
1

How to check the version of Binutils on GNU GAS assembly code at compile time?

Crypto++ had a a similar problem. They needed to know AS and LD versions to ensure instructions part of ISAs like SSE4 (-msse4.1), AES (-maes) and SHA (-msha) were available during a build (using Intel as an example).

In a GNUmakefile Crypto++ used to perform:

GCC_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -v -E '(llvm|clang)' | $(GREP) -i -c -E '(gcc|g\+\+)')
...

ifneq ($(GCC_COMPILER),0)
  IS_GCC_29 := $(shell $(CXX) -v 2>&1 | $(GREP) -i -c -E gcc-9[0-9][0-9])
  GCC42_OR_LATER := $(shell $(CXX) -v 2>&1 | $(GREP) -i -c -E "gcc version (4\.[2-9]|[5-9]\.)")
  GCC46_OR_LATER := $(shell $(CXX) -v 2>&1 | $(GREP) -i -c -E "gcc version (4\.[6-9]|[5-9]\.)")
endif

ifneq ($(HAVE_GAS),0)
  GAS210_OR_LATER := $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(GREP) -c -E "GNU assembler version (2\.[1-9][0-9]|[3-9])")
  GAS217_OR_LATER := $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(GREP) -c -E "GNU assembler version (2\.1[7-9]|2\.[2-9]|[3-9])")
  GAS218_OR_LATER := $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(GREP) -c -E "GNU assembler version (2\.1[8-9]|2\.[2-9]|[3-9])")
  GAS219_OR_LATER := $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(GREP) -c -E "GNU assembler version (2\.19|2\.[2-9]|[3-9])")
  GAS224_OR_LATER := $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(GREP) -c -E "GNU assembler version (2\.2[4-9]|2\.[3-9]|[3-9])")
endif

And later Crypto++ would do stuff like:

ifeq ($(HAVE_GAS)$(GAS224_OR_LATER),10)
  CXXFLAGS += -DCRYPTOPP_DISABLE_SHA
endif

The 10 string is basically equivalent to the following. It is the GNU Makefile way of doing boolean expressions:

if HAVE_GAS==true && GAS224_OR_LATER==false
  CXXFLAGS += -DCRYPTOPP_DISABLE_SHA
fi

By the way, the GAS version checking broke with Clang and the Integrated Assembler. Clang does not respond to -Wa,-v like AS does. LLVM Bug 24200 was filed because of it: Fail to fetch version string of assembler when using integrated assembler.


What Crypto++ found was, this did not scale well. It was OK 10 or 20 years ago (literally, when it was initially used). However it broke down when (1) new platforms use ancient toolchains, like modern BSD pinning to GPL2 toolchains (2) new compilers were installed on old platforms, like Clang 7.0 on a Power6 machine, and (3) Clang and its integrated assembler, which did not need AS to assemble higher ISAs.

ARM platforms was also very troublesome because the project could not reliably determine when to include <arm_neon.h> and <arm_acle.h> based on platforms and compiler versions. Sometimes the headers were available for a platform and compiler, sometimes they were not (even on the same platform with different versions of the same compiler). Preprocessor macros like __ARM_ACLE__ were completely missing (see ARM C Language Extensions (ACLE)). Android and iOS just does what the hell it wants breaking from what happens on armhf and friends or what is stated in the docs. And Microsoft found a new way to break it with their header <arm64_neon.h>.

Now Crypto++ performs a test compile through the GNU Makefile to see if a program can be compiled, assembled and linked. However, it is not braindead like Autotools or Cmake. Crypto++ looks for any diagnostic and fails the test for any diagnostic. This caught cases Autotools and Cmake were missing, like SunCC emitting like "illegal option: -xarch=sha". Autotools and Cmake would report success and later the build would fail. (Apparently Autotools and Cmake only check compiler return codes, and not diagnostic messages like "illegal option").

The Crypto++ tests now look like:

SUN_COMPILER := $(shell $(CXX) -V 2>&1 | $(GREP) -i -c -E 'CC: (Sun|Studio)')
...

ifeq ($(SUN_COMPILER),1)
  SSE2_FLAG = -xarch=sse2
else
  SSE2_FLAG = -msse2
endif
...

TPROG = TestPrograms/test_x86_sse2.cxx
TOPT = $(SSE2_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
ifeq ($(strip $(HAVE_OPT)),0)
  CHACHA_FLAG = $(SSE2_FLAG)
  SUN_LDFLAGS += $(SSE2_FLAG)
else
  SSE2_FLAG =
endif

And test_x86_sse2.cxx, which is compiled at -O0 so the optimzer does not remove the code:

$ cat TestPrograms/test_x86_sse2.cxx
#include <emmintrin.h>
int main(int argc, char* argv[])
{
    __m128i x = _mm_setzero_si128();
    x=_mm_add_epi64(x,x);
    return 0;
}
🌐
Mac App Store
macappstore.org › home › install binutils on mac osx
Install binutils on Mac OSX - Mac App Store
June 12, 2022 - Mind you, as you type your password, ... echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile · Copy and paste the following command: brew install binutils......
🌐
Linux Questions
linuxquestions.org › questions › linux-software-2 › determining-gcc-binutils-and-libc-version-compatibility-799876
Determining GCC, binutils and libc version compatibility
April 4, 2010 - Hi everyone, this questions pertains mainly to building a brandnew GNU toolchain on one machine for deployment on fs of another machine that has no