bug-glibc
[Top][All Lists]
Advanced

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

Re: strlen arm BigEndian glibc bug


From: Andreas Schwab
Subject: Re: strlen arm BigEndian glibc bug
Date: Thu, 12 Dec 2002 18:03:58 +0100
User-agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.3.50 (ia64-suse-linux)

Eric Zerbib <address@hidden> writes:

|> I have found a problem with glibc  strlen fonction on arm processor with 
|> big-endian
|> 
|> I am using 
|>          gcc-2.95.3
|> I compiled glic.2.2.4 but I think that the bug is already present in the 
last 
|> 2.3.1 
|> the library compile .../glibc-2.2.4/sysdeps/arm/strlen.S
|> but in with a simple program
|> 
|> ----------------------------------
|> #include "stdio.h"
|> #include <string.h>
|> 
|> int main(int argc,char **argv)
|> {
|> printf ("strlen =%d\n",strlen("123456789"));
|> }
|> ----------------------------------
|> the result is
|> strlen = 8 !!!! instead of 9
|> 
|> 
|> 
|> Note someone else detect the problem on the net and post the
|> same remark
|> 
|> here is the link
|> http://www.geocrawler.com/archives/3/18/2000/3/0/3528870/
|> 
|> Here is the source...
|> this is the buggy code, but I m not sufficient in arm asm  to understand
|> why this is a buggy code ?

Could you please try this patch?

2002-12-12  Andreas Schwab  <address@hidden>

        * sysdeps/arm/strlen.S: Fix last word check for big endian.

--- sysdeps/arm/strlen.S.~1.3.~ 2001-07-16 10:43:59.000000000 +0200
+++ sysdeps/arm/strlen.S        2002-12-12 18:01:32.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Code contributed by Matthew Wilcox <address@hidden>
 
@@ -53,11 +53,20 @@ Laligned:                           @ here, we have a word 
in r
        ldrne   r2, [r1], $4            @ and we continue to the next word
        bne     Laligned                @
 Llastword:                             @ drop through to here once we find a
+#ifdef __ARMEB__
+       tst     r2, $0xff000000         @ word that has a zero byte in it
+       addne   r0, r0, $1              @
+       tstne   r2, $0x00ff0000         @ and add up to 3 bytes on to it
+       addne   r0, r0, $1              @
+       tstne   r2, $0x0000ff00         @ (if first three all non-zero, 4th
+       addne   r0, r0, $1              @  must be zero)
+#else
        tst     r2, $0x000000ff         @ word that has a zero byte in it
        addne   r0, r0, $1              @
        tstne   r2, $0x0000ff00         @ and add up to 3 bytes on to it
        addne   r0, r0, $1              @
        tstne   r2, $0x00ff0000         @ (if first three all non-zero, 4th
        addne   r0, r0, $1              @  must be zero)
+#endif
        RETINSTR(mov,pc,lr)
 END(strlen)

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



reply via email to

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