public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [ARM] global Thumb to ARM branches broken
@ 2010-02-03 15:16 Christophe LYON
  2010-02-03 16:16 ` Ramana Radhakrishnan
  0 siblings, 1 reply; 10+ messages in thread
From: Christophe LYON @ 2010-02-03 15:16 UTC (permalink / raw)
  To: Binutils

Hello,

It seems to me that the patch discussed in
http://sourceware.org/ml/binutils/2009-03/msg00511.html
broke the global Thumb branches by encoding the PC inside the instruction.

For instance:
	.global _start
	.syntax unified
	.text
	.thumb_func
_start:
	.global bar
	.space 0x300000
	bl bar

	.section .foo, "xa"
	.arm
	.type bar, %function
bar:
	bx lr

is assembled into (using -march=armv5t):
00000000 <_start>:
         ...
   300000:       f4ff fffe       bl      ffd00000 <_start+0xffd00000>
                         300000: R_ARM_THM_CALL  bar
Disassembly of section .foo:
00000000 <bar>:
    0:   e12fff1e        bx      lr

In turn, if one links, the resulting code is:
00008000 <_start>:
         ...
   308000:       f500 e800       blx     8004 <_start+0x4>
Disassembly of section .foo:
00308004 <bar>:
   308004:       e12fff1e        bx      lr

This is because Ramana's fix in md_pcrel_from_section() does not check 
whether both sides of the branch are in the same section, or if the 
destination is external.

I am working on a patch, but some inputs/comments could help.
Indeed, I am not sure what "in line with what happens with global 
functions for both ARM and Thumb mode" really means (as appears in the 
original post).

As I am not sure about the actual intent of that patch, I tried to 
remove some parts, which did not result in regressions in the testsuite, 
so some tests may be missing.

Finally, I am not sure about the new behaviour of 
arm_force_relocation(): it now returns 1 in several new occurrences, but 
the corresponding relocations do not appear in the object file (see 
blx-local test)

I am trying to fix gas, but maybe a better fix would be in the linker 
side, because the involved relocations are declared as *not* partial 
inplace, but ld handles them as if they were (eg when it reads the 
addend from upper_insn).

Christophe.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-02-11 14:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-03 15:16 [ARM] global Thumb to ARM branches broken Christophe LYON
2010-02-03 16:16 ` Ramana Radhakrishnan
2010-02-04 16:46   ` Christophe LYON
2010-02-05 10:08     ` Ramana Radhakrishnan
2010-02-05 13:44       ` Christophe LYON
2010-02-08 16:09         ` Christophe LYON
2010-02-09 10:17           ` Nick Clifton
2010-02-09 14:45             ` Christophe LYON
2010-02-11 12:42               ` Tristan Gingold
2010-02-11 14:33                 ` Christophe LYON

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).