This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: ARM as crash
- From: Nick Clifton <nickc at redhat dot com>
- To: Richard Earnshaw <rearnsha at gcc dot gnu dot org>
- Cc: Shaun Jackman <sjackman at gmail dot com>, binutils at sources dot redhat dot com
- Date: Fri, 02 Sep 2005 12:25:14 +0100
- Subject: Re: ARM as crash
- References: <7f45d9390508260909e8bb798@mail.gmail.com> <431339B6.5010807@redhat.com> <1125398630.744.34.camel@pc960.cambridge.arm.com>
Hi Richard,
That might avoid the crash, but I'm not sure it's the 'right thing'. In
this case, remember that the BL instruction is PC-relative, so we do
need to express the branch to '0' somehow.
Agreed. The attached patch makes this work by allowing relocs which
have no associated symbol to be resolved normally. I am however worried
about two things:
* It handles the R_ARM_PC24 reloc generated by the BL instruction,
but it also affects other relocs such as R_ARM_ABS32 and R_ARM_REL32. I
am not sure that there can ever be valid situations where such relocs
would need processing rather than ignoring.
* It means that relocs against discarded sections which would before
have just been silently mis-resolved and then ignored might now start to
produce error messages, eg for a branch out of range. I am not sure if
this will actually happen in real life, but I think that maybe I ought
to update the patch to disable such errors if there is no valid symbol
for the relocation.
What do you think ?
Cheers
Nick
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.54
diff -c -3 -p -r1.54 elf32-arm.c
*** bfd/elf32-arm.c 25 Aug 2005 02:32:09 -0000 1.54
--- bfd/elf32-arm.c 2 Sep 2005 11:16:46 -0000
*************** elf32_arm_final_link_relocate (reloc_how
*** 2880,2890 ****
case R_ARM_XPC25:
case R_ARM_PREL31:
case R_ARM_PLT32:
! /* r_symndx will be zero only for relocs against symbols
! from removed linkonce sections, or sections discarded by
! a linker script. */
if (r_symndx == 0)
! return bfd_reloc_ok;
/* Handle relocations which should use the PLT entry. ABS32/REL32
will use the symbol's value, which may point to a PLT entry, but we
--- 2880,2893 ----
case R_ARM_XPC25:
case R_ARM_PREL31:
case R_ARM_PLT32:
! /* r_symndx will be zero only for relocs against symbols from removed
! linkonce sections, or sections discarded by a linker script, or for
! absolute addresses. eg: "bl 0x1234". We do not need to worry
! about the first two alterantives, but we do need to support the
! last one. In this case the offset stored in the reloc should be
! ignored since it is already in input_section->offset. */
if (r_symndx == 0)
! rel->r_offset = 0; /* return bfd_reloc_ok; */
/* Handle relocations which should use the PLT entry. ABS32/REL32
will use the symbol's value, which may point to a PLT entry, but we