This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: arm-elf-as truncates branch offsets w/o warning



> Would you have a testcase for this as well?

Sure:
------------------------------testit2.s------------------------------
     .text
     .org 0x05000000
     b    label1
     nop
     nop
     nop
label1:
     nop
--------------------------------------------------------------------

NB: Assembling the above file will suck the life out of your
    machine for a minute or two.

This generates the following (broken) code with the unpatched
000309 arm-elf-as:

Disassembly of section .text:

00000000 <label1-0x5000010>:
	...
 5000000:	ea400002 	b	6000010 <label1+0x1000000>
 5000004:	e1a00000 	nop			(mov r0,r0)
 5000008:	e1a00000 	nop			(mov r0,r0)
 500000c:	e1a00000 	nop			(mov r0,r0)

05000010 <label1>:
 5000010:	e1a00000 	nop			(mov r0,r0)

While my patch doesn't generate the correct code, it does
generate an error message:

$ binutils-000309.work/gas/as-new testit2.s
testit2.s: Assembler messages:
testit2.s:3: Error: gas can't handle non-relocatable branch dest >= 0x04000000
$ 

Now, there's damned little reason anybody would ever want to
_write_ code like that but believe it or not, somebody e-mailed
me an off-the-cuff snippet of code to demonstrate something,
and I ran into the problem.  ;)

I _think_ that relocatable destinations for both cases #1 and
#2 are handled correctly by the linker, but I haven't verified
that just yet.

-- 
Grant Edwards
grante@visi.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]