Fedora 30 : Cannot run ld and compile c++ and fortran codes

I have installed f30 about 4 weeks ago and I keep encountering this error when compiling c++ macros or trying to install programs that require a compilation of a source code in fortran.

error: ld returned 126 exit status

I’ve tried to look into it and so far I have no explanation.

What I tried to is to find where is ld and see if I can find something. So, ld resides in /usr/bin which is a soft link from /etc/alternatives.

$ ls -al /usr/bin/ld*
lrwxrwxrwx. 1 root root      20 Apr 26 04:27 /usr/bin/ld -> /etc/alternatives/ld
-rwxr-xr-x. 1 root root   13536 Aug 11 11:27 /usr/bin/ld.bfd
-rwxr-xr-x. 1 root root    5441 Jun  6 13:55 /usr/bin/ldd
-rwxr-xr-x. 1 root root 3853632 Mar  6 11:00 /usr/bin/ld.gold

When I try to execute ld by itself, I get the following error

$ /usr/bin/ld
bash: /usr/bin/ld: cannot execute binary file: Exec format error

$ sudo /usr/bin/ld
/usr/bin/ld: /usr/bin/ld: cannot execute binary file

Then I searched the original /etc/alternatives location, but it’s again a soft link to the orignial one!

$ ls -al /etc/alternatives/ld*
lrwxrwxrwx. 1 root root 15 Apr 26 04:27 /etc/alternatives/ld -> /usr/bin/ld.bfd

I tried to find the version of ld.bfd but it seems that it cannot be executed

$ /usr/bin/ld.bfd --version
bash: /usr/bin/ld.bfd: cannot execute binary file: Exec format error
$ sudo /usr/bin/ld.bfd --version
/usr/bin/ld.bfd: /usr/bin/ld.bfd: cannot execute binary file

Any idea on how to understand what is wrong and solve the issue?

1 Like

Please, collect the related diagnostics:

type ld
rpm -q -f $(type -p ld)
rpm -V $(rpm -q -f $(type -p ld))

Thank you very much for your answer!

This are the diagnostics you asked

$ type ld
ld is /usr/bin/ld
$ rpm -q -f $(type -p ld)
$ rpm -V $(rpm -q -f $(type -p ld))
1 Like
readlink -f $(type -p ld)
rpm -q -f $(readlink -f $(type -p ld))

Thank you once again.
I don’t understand what are you trying to see, but I will do a research!

$ readlink -f $(type -p ld)
$ rpm -q -f $(readlink -f $(type -p ld))
1 Like

I wanted to verify the following:

  • Automatic symlink resolution.
  • The package which provides the binary:
    • Package version.
    • Package integrity.

I don’t see any issues, but still it doesn’t work, and this is confusing.

Please, also check:

uname -a
file $(readlink -f $(type -p ld))

A similar issue:

Thank you very much for you help!
I think I solve it, unless I destroyed something without knowing it!

I reinstalled binutils by using

sudo yum reinstall binutils

and it seems it is working!

But I really hope I didn’t messed up with something else!
How can I validate that?

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.