public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* arm-elf-ld: problems with long calls in thumb mode
@ 2005-02-24 16:11 Lars Olsson
  2005-02-24 16:16 ` Richard Earnshaw
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Olsson @ 2005-02-24 16:11 UTC (permalink / raw)
  To: binutils

Hi,

I'm working on a platform with an arm7tdmi chip with a large (but slow)
flashrom and a small, fast sram. Code is in thumb mode. The flashrom is used to 
store collected data as well as providing non-volatile storage for the program 
code. On bootstrap, all code is copied from flash to ram because speed is of 
essence. This works as intended.

However, I'm getting to the point where I'm running out of ram and I would like 
to skip copying non-critical functions to ram in order to save some space and 
here I experience problems with the linker:

thumb/send.o(.text+0x10): In function `InitRS232':
send.c:39: relocation truncated to fit: R_ARM_THM_PC22 _call_via_r3
thumb/send.o(.text+0x20):send.c:40: relocation truncated to fit: R_ARM_THM_PC22 
_call_via_r3
thumb/send.o(.text+0x58): In function `SendData':
send.c:71: relocation truncated to fit: R_ARM_THM_PC22 _call_via_r4
thumb/send.o(.text+0x60):send.c:72: relocation truncated to fit: R_ARM_THM_PC22 
_call_via_r4
thumb/send.o(.text+0x6a):send.c:76: relocation truncated to fit: R_ARM_THM_PC22 
_call_via_r3
thumb/send.o(.text+0x7a):send.c:79: relocation truncated to fit: R_ARM_THM_PC22 
_call_via_r4
thumb/send.o(.text+0x8c):send.c:82: relocation truncated to fit: R_ARM_THM_PC22 
_call_via_r3
thumb/send.o(.text+0xa0):send.c:83: relocation truncated to fit: R_ARM_THM_PC22 
_call_via_r4
thumb/send.o(.text+0xa6):send.c:85: relocation truncated to fit: R_ARM_THM_PC22 
_call_via_r3
thumb/send.o(.text+0xda):send.c:103: relocation truncated to fit: 
R_ARM_THM_PC22 _call_via_r3
thumb/send.o(.text+0xea):send.c:106: additional relocation overflows omitted 
from the output

I have looked for information regarding this behaviour and I've seen
that other people have also run into similar situations, but I haven't
found a solution. The problem seems to be that the 'bl' instruction can't 
bridge the gap between flash and ram so the linker tries to use the 
_call_via_rX routines as intermediates. However, these routines are in libgcc 
which are linked only to the ram address which means they too are unreachable 
from flash! Is there anyway to get the linker to smarten up and place these 
routines in flash as well as in ram so that functions can be called from either 
place?


Thanks,
/Lars

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

* Re: arm-elf-ld: problems with long calls in thumb mode
  2005-02-24 16:11 arm-elf-ld: problems with long calls in thumb mode Lars Olsson
@ 2005-02-24 16:16 ` Richard Earnshaw
  2005-02-24 17:46   ` Vincent Rubiolo
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Earnshaw @ 2005-02-24 16:16 UTC (permalink / raw)
  To: Lars Olsson; +Cc: binutils

On Thu, 2005-02-24 at 10:08, Lars Olsson wrote:
> Hi,
> 
> I'm working on a platform with an arm7tdmi chip with a large (but slow)
> flashrom and a small, fast sram. Code is in thumb mode. The flashrom is used to 
> store collected data as well as providing non-volatile storage for the program 
> code. On bootstrap, all code is copied from flash to ram because speed is of 
> essence. This works as intended.
> 
> However, I'm getting to the point where I'm running out of ram and I would like 
> to skip copying non-critical functions to ram in order to save some space and 
> here I experience problems with the linker:
> 
> thumb/send.o(.text+0x10): In function `InitRS232':
> send.c:39: relocation truncated to fit: R_ARM_THM_PC22 _call_via_r3
> thumb/send.o(.text+0x20):send.c:40: relocation truncated to fit: R_ARM_THM_PC22 
> _call_via_r3
> thumb/send.o(.text+0x58): In function `SendData':
> send.c:71: relocation truncated to fit: R_ARM_THM_PC22 _call_via_r4
> thumb/send.o(.text+0x60):send.c:72: relocation truncated to fit: R_ARM_THM_PC22 
> _call_via_r4
> thumb/send.o(.text+0x6a):send.c:76: relocation truncated to fit: R_ARM_THM_PC22 
> _call_via_r3
> thumb/send.o(.text+0x7a):send.c:79: relocation truncated to fit: R_ARM_THM_PC22 
> _call_via_r4
> thumb/send.o(.text+0x8c):send.c:82: relocation truncated to fit: R_ARM_THM_PC22 
> _call_via_r3
> thumb/send.o(.text+0xa0):send.c:83: relocation truncated to fit: R_ARM_THM_PC22 
> _call_via_r4
> thumb/send.o(.text+0xa6):send.c:85: relocation truncated to fit: R_ARM_THM_PC22 
> _call_via_r3
> thumb/send.o(.text+0xda):send.c:103: relocation truncated to fit: 
> R_ARM_THM_PC22 _call_via_r3
> thumb/send.o(.text+0xea):send.c:106: additional relocation overflows omitted 
> from the output
> 
> I have looked for information regarding this behaviour and I've seen
> that other people have also run into similar situations, but I haven't
> found a solution. The problem seems to be that the 'bl' instruction can't 
> bridge the gap between flash and ram so the linker tries to use the 
> _call_via_rX routines as intermediates. However, these routines are in libgcc 
> which are linked only to the ram address which means they too are unreachable 
> from flash! Is there anyway to get the linker to smarten up and place these 
> routines in flash as well as in ram so that functions can be called from either 
> place?
> 
> 
> Thanks,
> /Lars

This is gcc PR target/7525.  It's been fixed for gcc-4 for other
reasons, but it's not going to get back-ported onto any older compilers
since it doesn't fix a regression.  You can try using the trunk
compiler, or you could try and back-port the change yourself if you
wished, but it might require some adjustment to work with the older
code.

R.

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

* Re: arm-elf-ld: problems with long calls in thumb mode
  2005-02-24 16:16 ` Richard Earnshaw
@ 2005-02-24 17:46   ` Vincent Rubiolo
  0 siblings, 0 replies; 3+ messages in thread
From: Vincent Rubiolo @ 2005-02-24 17:46 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: Lars Olsson, binutils

Hello,

I encountered the problem before and Nick was kind enough to direct me 
to an experimental patch (which worked for me at the time). This 
involves patching and rebuilding gcc. YMMV as this is quite old but this 
may work.

Here is the corresponding binutils discussion (some time has passed 
obviously, Richard was still working for ARM :)
http://sources.redhat.com/ml/binutils/2003-06/msg00412.html

HTH,

Vincent

Richard Earnshaw wrote:
[...]
> This is gcc PR target/7525.  It's been fixed for gcc-4 for other
> reasons, but it's not going to get back-ported onto any older compilers
> since it doesn't fix a regression.  You can try using the trunk
> compiler, or you could try and back-port the change yourself if you
> wished, but it might require some adjustment to work with the older
> code.
> 
> R.

-- 
Reclaim Your Inbox!
http://internal.vannes.wrsec.fr/twiki/bin/view/Utilities/MailThunderbird

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

end of thread, other threads:[~2005-02-24 16:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-24 16:11 arm-elf-ld: problems with long calls in thumb mode Lars Olsson
2005-02-24 16:16 ` Richard Earnshaw
2005-02-24 17:46   ` Vincent Rubiolo

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).