diff options
author | David S. Miller <davem@davemloft.net> | 2014-04-30 12:57:51 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-05-01 12:15:06 -0700 |
commit | 5331255b6eeafa74865b2e6af627cb712c41dafd (patch) | |
tree | a9d5fe7cfb4ad4af1dcb12bad7e1b158d281eca5 /sysdeps/sparc | |
parent | 4fdfe821e20a70670b3d03deb2abed5d8c83e51b (diff) | |
download | glibc-5331255b6eeafa74865b2e6af627cb712c41dafd.tar.gz glibc-5331255b6eeafa74865b2e6af627cb712c41dafd.tar.xz glibc-5331255b6eeafa74865b2e6af627cb712c41dafd.zip |
Fix v9/64-bit strcmp when string ends in multiple zero bytes.
[BZ #16885] * sysdeps/sparc/sparc64/strcmp.S: Fix end comparison handling when multiple zero bytes exist at the end of a string. Reported by Aurelien Jarno <aurelien@aurel32.net> * string/test-strcmp.c (check): Add explicit test for situations where there are multiple zero bytes after the first.
Diffstat (limited to 'sysdeps/sparc')
-rw-r--r-- | sysdeps/sparc/sparc64/strcmp.S | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sysdeps/sparc/sparc64/strcmp.S b/sysdeps/sparc/sparc64/strcmp.S index 8925396ec6..f32b0fc779 100644 --- a/sysdeps/sparc/sparc64/strcmp.S +++ b/sysdeps/sparc/sparc64/strcmp.S @@ -121,6 +121,37 @@ ENTRY(strcmp) movleu %xcc, -1, %o0 srlx rTMP1, 7, rTMP1 + /* In order not to be influenced by bytes after the zero byte, we + * have to retain only the highest bit in the mask for the comparison + * with rSTRXOR to work properly. + */ + mov 0, rTMP2 + andcc rTMP1, 0x0100, %g0 + + movne %xcc, 8, rTMP2 + sllx rTMP1, 63 - 16, %o1 + + movrlz %o1, 16, rTMP2 + sllx rTMP1, 63 - 24, %o1 + + movrlz %o1, 24, rTMP2 + sllx rTMP1, 63 - 32, %o1 + + movrlz %o1, 32, rTMP2 + sllx rTMP1, 63 - 40, %o1 + + movrlz %o1, 40, rTMP2 + sllx rTMP1, 63 - 48, %o1 + + movrlz %o1, 48, rTMP2 + sllx rTMP1, 63 - 56, %o1 + + movrlz %o1, 56, rTMP2 + + srlx rTMP1, rTMP2, rTMP1 + + sllx rTMP1, rTMP2, rTMP1 + cmp rTMP1, rSTRXOR retl movgu %xcc, 0, %o0 |