This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: arm-elf-as truncates branch offsets w/o warning
- To: binutils at sourceware dot cygnus dot com
- Subject: Re: arm-elf-as truncates branch offsets w/o warning
- From: Grant Edwards <grante at visi dot com>
- Date: Thu, 16 Mar 2000 17:19:57 -0600
- References: <20000316102708.A18044@visi.com>
> I just noticed that a recent snapshot (000309) of the ARM
> assembler truncates branch offsets without warning. I haven't
> had a chance yet to take look at the ARM assembler source.
There are two different (but related) problems:
1) Legal, non-relocatible branch destinations >= 0x0400,00000
are not handled correctly and bad code is generated with
no error or warning messages.
2) Illegal branches to non-relocatible branch destinations
with offsets >= +/- 0x0200,00000 aren't detected and bad
code is generated (also silently).
So far I've had a look at #1. I can't see a way to fix it
easily, but I've attached a patch to gas/config/tc-arm.c that
will generate an error when a non-relocatible branch destination
is too large for gas to deal with.
I'll work on #2 next.
--
Grant Edwards
grante@visi.com
--- binutils-000309/gas/config/tc-arm.c Thu Feb 24 13:46:27 2000
+++ binutils-000309.work/gas/config/tc-arm.c Thu Mar 16 17:07:25 2000
@@ -5562,12 +5562,15 @@
#ifdef OBJ_ELF
if (! target_oabi)
value = fixP->fx_offset;
#endif
- value = (value >> 2) & 0x00ffffff;
- value = (value + (newval & 0x00ffffff)) & 0x00ffffff;
+ value = (value >> 2);
+ if (value & 0xff000000)
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ _("gas can't handle non-relocatable branch dest >= 0x04000000"));
+ value = (value + newval) & 0x00ffffff;
newval = value | (newval & 0xff000000);
md_number_to_chars (buf, newval, INSN_SIZE);
break;