This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: md_apply_fix3 bug on arm-linux
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Philip Blundell <pb at nexus dot co dot uk>
- Cc: binutils at sources dot redhat dot com, Richard Earnshaw <rearnsha at arm dot com>
- Date: Wed, 14 Apr 2004 17:59:38 +0100
- Subject: Re: md_apply_fix3 bug on arm-linux
- Organization: ARM Ltd.
- Reply-to: Richard Earnshaw <rearnsha at arm dot com>
> A user reports that "mov r0, #UNDEFINED_SYMBOL" assembles to "mov r0,
> #0" without emitting any relocation or diagnostic, which clearly isn't
> right.
>
> Also, this code:
>
> .word 0
> foo:
> mov r0, #foo
>
> assembles to "mov r0, #4", again with no relocation, which also seems
> fairly bogus.
>
> A patch like the one below seems to clear it up. Does this look right?
> I guess I should also generate some cases for the testsuite.
>
> Thanks
>
> p.
>
>
> 2004-04-05 Philip Blundell <philb@gnu.org>
>
> * config/tc-arm.c (md_apply_fix3): Decline to handle IMMEDIATE
> relocs involving symbols.
Argh!! md_apply_fix3 makes my brain hurt...
After a long stare at the code I wonder whether the bug is that the
BFD_RELOC_ARM_IMMEDIATE case unconditionally sets fixP->fx_done; but I
think for all the cases that matter the earlier code
if (fixP->fx_addsy == 0 && !fixP->fx_pcrel)
fixP->fx_done = 1;
will have already done this.
>
> --- gas/config/tc-arm.c 2004-04-05 19:40:42.000000000 +0100
> +++ gas/config/tc-arm.c 2004-04-05 19:40:36.000000000 +0100
> @@ -12190,6 +12167,10 @@
> switch (fixP->fx_r_type)
> {
> case BFD_RELOC_ARM_IMMEDIATE:
> + /* If a symbol is involved, we must leave this to the linker. */
> + if (fixP->fx_addsy)
> + return;
> +
> newimm = validate_immediate (value);
> temp = md_chars_to_number (buf, INSN_SIZE);
>
>