summaryrefslogtreecommitdiff
path: root/libc/string/arc
diff options
context:
space:
mode:
authorPavel Kozlov <pavel.kozlov@synopsys.com>2023-11-09 15:04:29 +0400
committerWaldemar Brodkorb <wbx@openadk.org>2023-11-10 16:14:20 +0100
commit1762b04103e9b2c409649de1857a39867f15718f (patch)
treec6065b406b652caf2800ca77741fb331ca0f8b33 /libc/string/arc
parentdfa72192f19f130d73e6587d0c3f7ef4e22c52c7 (diff)
arc: remove read ahead in asm strcmp code for ARCHS
Remove read ahead in the per-word compare loop as it can cause a segmentation fault in certain circumstances (when a string crosses a page boundary). For baremetal this relaxed approach is suitable but in Linux with MMU we should be more restrictive. Signed-off-by: Pavel Kozlov <pavel.kozlov@synopsys.com>
Diffstat (limited to 'libc/string/arc')
-rw-r--r--libc/string/arc/strcmp.S8
1 files changed, 3 insertions, 5 deletions
diff --git a/libc/string/arc/strcmp.S b/libc/string/arc/strcmp.S
index 3f64ac421..48d2d7ec1 100644
--- a/libc/string/arc/strcmp.S
+++ b/libc/string/arc/strcmp.S
@@ -103,23 +103,21 @@ ENTRY(strcmp)
brne r2, 0, @.Lcharloop
;;; s1 and s2 are word aligned
- ld.ab r2, [r0, 4]
mov_s r12, 0x01010101
ror r11, r12
.align 4
.LwordLoop:
+ ld.ab r2, [r0, 4]
+ sub r4, r2, r12
ld.ab r3, [r1, 4]
;; Detect NULL char in str1
- sub r4, r2, r12
- ld.ab r5, [r0, 4]
bic r4, r4, r2
and r4, r4, r11
brne.d.nt r4, 0, .LfoundNULL
;; Check if the read locations are the same
cmp r2, r3
- beq.d .LwordLoop
- mov.eq r2, r5
+ beq .LwordLoop
;; A match is found, spot it out
#ifdef __LITTLE_ENDIAN__