https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64697

Jim Wilson <wilson at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wilson at gcc dot gnu.org

--- Comment #22 from Jim Wilson <wilson at gcc dot gnu.org> ---
This looks like a binutils bug to me.  A call to an undefined weak function
should never be executed, so it is OK for the linker to convert that call
instruction into anything convenient.  There is no need for a relocation that
can reach an address of zero.  We can convert the call instruction to call
itself, or the next instruction, or change it to a nop, what ever is
convenient, it doesn't really matter.

A number of binutils ports already have code to handle related problems.  ARM
and RISC-V for sure.  Probably others.  It looks like this support is missing
from the x86_64 port.  I'd suggest refiling this as a binutils bug.  See for
instance
  https://sourceware.org/bugzilla/show_bug.cgi?id=23244
for a RISC-V example of the same problem.  But we need a new bug for the x86_64
problem.  RISC-V has a register hard wired to zero, so I rewrite the call
instruction to use x0 as the base address.  The arm port turns the call into a
nop.

Reply via email to