[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] PATCH: fix ctype linker errors

From: Dmitry K.
Subject: Re: [avr-libc-dev] PATCH: fix ctype linker errors
Date: Fri, 25 Mar 2005 16:23:44 +1000
User-agent: KMail/1.5

On Friday 25 March 2005 09:27, Stefano Fedrigo wrote:
> Hello,
> ctype.S contains several functions that end up in different sections.
> All them branch to __cty_isfalse and __cty_istrue, which resides in yet
> another section. Thus there is no guarantee that all sections are
> allocated next to each other within the limit of relative branch
> instructions.
> When I build my application the linker complains like this:
> relocation truncated to fit: R_AVR_7_PCREL no symbol
> The best fix I could come up with consists in copying the
> three-instruction sequence into each section. Is there a better solution?

There is, for example:

          TEXT_SEG(ctype, isdigit)
          TST   rHigh
          BRNE  __ctype_isfalse
          CPI   rLow,'0'
          BRLT  __ctype_isfalse
          CPI   rLow,'9'+1
          BRGE  __ctype_isfalse
          RET                      ; '0' <= rLow <= '9' (!= 0!!)
in to:
          cpse  rHigh, r1
  1:      rjmp  __ctype_isfalse
          CPI   rLow,'0'
          BRLT  1b
          CPI   rLow,'9'+1
          BRGE  1b
          RET                      ; '0' <= rLow <= '9' (!= 0!!)

          cpse  rHigh, r1
  1:      rjmp  __ctype_isfalse
          subi  rLow, '0'
          cpi   rLow, 10
          brsh  1b
          RET                      ; '0' <= rLow <= '9' (!= 0!!)

> Patch attached. I didn't bother fixing the RJMP instructions that have
> the same potential problem, but didn't affect me. Replacing them with
> JMP wouldn't be compatible with all MCUs.

I badly understand these things, but in my opinion 'rjmp' usage is safe
due to '.progmem.ctype' (macros TEXT_SEG).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]