avr-libc-dev
[Top][All Lists]
Advanced

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

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


From: Stefano Fedrigo
Subject: [avr-libc-dev] PATCH: fix ctype linker errors
Date: Thu, 24 Mar 2005 23:27:45 +0000
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050324)

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:

/usr/local/avr/lib/gcc/avr/3.4.3/../../../../avr/lib/avr5/libc.a(isalnum.o)(.text.ctype+0x2):
In function `isalnum':
../../../../avr-libc-1.2.2/libc/stdlib/ctype.S:105: relocation truncated
to fit: R_AVR_7_PCREL no symbol
/usr/local/avr/lib/gcc/avr/3.4.3/../../../../avr/lib/avr5/libc.a(isalnum.o)(.text.ctype+0xc):../../../../avr-libc-1.2.2/libc/stdlib/ctype.S:110:
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?

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.

Please include me in the Cc list explicitly as I'm not subscribed
to the list.

-- 
  // Stefano Fedrigo - Develer S.r.l., R&D dept.
\X/  http://www.develer.com

diff -Nru avr-libc-1.2.2.orig/libc/stdlib/Makefile.am 
avr-libc-1.2.2/libc/stdlib/Makefile.am
--- avr-libc-1.2.2.orig/libc/stdlib/Makefile.am 2004-12-31 09:48:46.000000000 
+0000
+++ avr-libc-1.2.2/libc/stdlib/Makefile.am      2005-03-24 22:07:17.000000000 
+0000
@@ -56,10 +56,10 @@
 
 # this objects are all generated from ctype.S
 libc_ctype_asm_objs = \
-       isascii.o toascii.o isalnum.o cty_isfalse.o \
-       isalpha.o isdigit.o isxdigit.o iscntrl.o    \
-       isprint.o isspace.o isblank.o ispunct.o     \
-       tolower.o toupper.o
+       isascii.o toascii.o isalnum.o isalpha.o     \
+       isdigit.o isxdigit.o iscntrl.o isprint.o    \
+       isspace.o isblank.o ispunct.o tolower.o     \
+       toupper.o
 
 lib_a_SOURCES = $(lib_a_c_sources) $(lib_a_asm_sources)
 
diff -Nru avr-libc-1.2.2.orig/libc/stdlib/ctype.S 
avr-libc-1.2.2/libc/stdlib/ctype.S
--- avr-libc-1.2.2.orig/libc/stdlib/ctype.S     2005-03-24 21:25:38.000000000 
+0000
+++ avr-libc-1.2.2/libc/stdlib/ctype.S  2005-03-24 22:11:33.000000000 +0000
@@ -76,10 +76,14 @@
 
 GLOBAL(isascii)
           TST     rHigh
-          BRNE    __ctype_isfalse
+          BRNE    _isascii00       ; false
           COM     rLow
           ANDI    rLow, 0x80
           RET
+_isascii00:
+          CLR     rHigh
+          CLR     rLow
+          RET
 
           ENDFUNC
 #endif
@@ -102,25 +106,17 @@
 
 GLOBAL(isalnum)
           TST   rHigh
-          BRNE  __ctype_isfalse
+          BRNE  _isalnum00         ; false
           PUSH  rLow               ; save, destroyed by isdigit returning 0
           RCALL _U(isdigit)
           TST   rLow
           POP   rLow
-          BRNE  __ctype_istrue
+          BRNE  _isalnum01         ; true
           RJMP  _U(isalpha)
-
-          ENDFUNC
-#endif
-
-#if defined (Lcty_isfalse)
-          TEXT_SEG(ctype, __ctype_isfalse)
-          FUNCTION(__ctype_isfalse)
-
-GLOBAL(__ctype_isfalse)
+_isalnum00:
           CLR   rHigh
           CLR   rLow
-GLOBAL(__ctype_istrue)
+_isalnum01:
           RET
 
           ENDFUNC
@@ -134,19 +130,23 @@
 
 GLOBAL(isupper)
           ;TST   rHigh
-          ;BRNE  __ctype_isfalse    ; checked by _islower later on
+          ;BRNE  _isalpha00         ; checked by _islower later on
           SBRC  rLow,5       ; if bit 5 is set it is no upper
-          RJMP  __ctype_isfalse     ; bit 5 is clear, so if isalpha is true it 
is an upper
+          RJMP  _isalpha00          ; bit 5 is clear, so if isalpha is true it 
is an upper
 GLOBAL(isalpha)
           ORI     rLow,0x20        ; make a lower out of an upper (all others 
are changed but do not get alpha)
 GLOBAL(islower)
           TST   rHigh
-          BRNE  __ctype_isfalse
+          BRNE  _isalpha00
           CPI   rLow,'a'
-          BRLT  __ctype_isfalse
+          BRLT  _isalpha00
           CPI   rLow,'z'+1
-          BRGE  __ctype_isfalse
+          BRGE  _isalpha00
           RET                      ; 'a' <= rLow <= 'z' (!= 0!!, Z=0)
+_isalpha00:                        ; false
+          CLR   rHigh
+          CLR   rLow
+          RET
 
           ENDFUNC
 #endif
@@ -159,12 +159,16 @@
 
 GLOBAL(isdigit)
           TST   rHigh
-          BRNE  __ctype_isfalse
+          BRNE  _isdigit00
           CPI   rLow,'0'
-          BRLT  __ctype_isfalse
+          BRLT  _isdigit00
           CPI   rLow,'9'+1
-          BRGE  __ctype_isfalse
+          BRGE  _isdigit00
           RET                      ; '0' <= rLow <= '9' (!= 0!!)
+_isdigit00:                        ; false
+          CLR   rHigh
+          CLR   rLow
+          RET
 
           ENDFUNC
 #endif
@@ -181,11 +185,15 @@
           CPI   rLow,'a'
           BRLT  _isxdigit00
           CPI   rLow,'f'+1
-          BRGE  __ctype_isfalse
+          BRGE  _isxdigit01
           RET                      ; 'a' <= rLow <= 'f' (!= 0!!)
 _isxdigit00:
           MOV   rLow,__tmp_reg__
           RJMP  _U(isdigit)
+_isxdigit01:                       ; false
+          CLR   rHigh
+          CLR   rLow
+          RET
 
           ENDFUNC
 #endif
@@ -198,13 +206,18 @@
 
 GLOBAL(iscntrl)
           TST   rHigh
-          BRNE  __ctype_isfalse
+          BRNE  _iscntrl00
           CPI   rLow,0x7F
-          BREQ  __ctype_istrue
+          BREQ  _iscntrl01
           CPI   rLow,0x1F+1
-          BRGE  __ctype_isfalse
+          BRGE  _iscntrl00
           SER   rLow               ; 0 is cntrl, too! -> return true
           RET
+_iscntrl00:                        ; false
+          CLR   rHigh
+          CLR   rLow
+_iscntrl01:                        ; true
+          RET
 
           ENDFUNC
 #endif
@@ -217,14 +230,18 @@
 
 GLOBAL(isgraph)
           CPI   rLow,' '
-          BREQ  __ctype_isfalse
+          BREQ  _isprint00
 GLOBAL(isprint)
           TST   rHigh
-          BRNE  __ctype_isfalse
+          BRNE  _isprint00
           CPI   rLow,' '
-          BRLT  __ctype_isfalse
+          BRLT  _isprint00
           CPI   rLow,0x7E+1
-          BRGE  __ctype_isfalse    ;  ' ' <= rLow <= 0x7E (!= 0!!)
+          BRGE  _isprint00         ;  ' ' <= rLow <= 0x7E (!= 0!!)
+          RET
+_isprint00:                        ; false
+          CLR   rHigh
+          CLR   rLow
           RET
 
           ENDFUNC
@@ -238,19 +255,24 @@
 
 GLOBAL(isspace)
           TST   rHigh
-          BRNE  __ctype_isfalse
+          BRNE  _isspace00
           CPI   rLow,' '           ; blank
-          BREQ  __ctype_istrue
+          BREQ  _isspace01
           CPI   rLow,0x0A    ;'\n' ; line feed
-          BREQ  __ctype_istrue
+          BREQ  _isspace01
           CPI   rLow,0x0C    ;'\f' ; form feed
-          BREQ  __ctype_istrue
+          BREQ  _isspace01
           CPI   rLow,0x0D    ;'\r' ; carriage return
-          BREQ  __ctype_istrue
+          BREQ  _isspace01
           CPI   rLow,0x09    ;'\t' ; tab
-          BREQ  __ctype_istrue
+          BREQ  _isspace01
           CPI   rLow,0x0B    ;'\v' ; vertical tab
-          BRNE  __ctype_isfalse
+          BRNE  _isspace00
+          RET
+_isspace00:                        ; false
+          CLR   rHigh
+          CLR   rLow
+_isspace01:                        ; true
           RET
 
           ENDFUNC
@@ -269,14 +291,18 @@
 
           RCALL _U(isspace)
           TST   rLow
-          BRNE  __ctype_isfalse
+          BRNE  _ispunct01
           mov   rLow, __tmp_reg__    ; **changed**
           RCALL _U(isalnum)
           TST   rLow
-          BRNE  __ctype_isfalse
+          BRNE  _ispunct01
           SER   rLow
 _ispunct00:
           RET
+_ispunct01:                          ; false
+          CLR   rHigh
+          CLR   rLow
+          RET
 
           ENDFUNC
 #endif
@@ -289,13 +315,18 @@
 
 GLOBAL(isblank)
           TST   rHigh
-          BRNE  __ctype_isfalse
+          BRNE  _isblank00
           CPI   rLow,' '           ; blank
-          BREQ  __ctype_istrue
+          BREQ  _isblank01
           CPI   rLow,0x09    ;'\t' ; tab
-          BREQ  __ctype_istrue
+          BREQ  _isblank01
           CPI   rLow,0x0B    ;'\v' ; vertical tab
-          BRNE  __ctype_isfalse
+          BRNE  _isblank00
+          RET
+_isblank00:                        ; false
+          CLR   rHigh
+          CLR   rLow
+_isblank01:                        ; true
           RET
 
           ENDFUNC

reply via email to

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