Bug 31266 - sparc: string/tst-memmove-overflow fails on 32-bit sparcv9
Summary: sparc: string/tst-memmove-overflow fails on 32-bit sparcv9
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: string (show other bugs)
Version: 2.27
: P2 normal
Target Milestone: 2.39
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-18 15:28 UTC by Adhemerval Zanella
Modified: 2024-01-22 13:02 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adhemerval Zanella 2024-01-18 15:28:06 UTC
The sparcv9 uses the generic sparc64 sysdeps/sparc/sparc64/memmove.S implementation and the initial size test is done with a signed comparison:

ENTRY(memmove)
        mov     %o0, %g2        /* Save pointer to destination  */
        cmp     %o1, %o0        /* if from address is >= to use forward copy  */
        bgeu,a  %XCC, 2f        /* else use backward if ...  */
         cmp    %o2, 17         /* delay slot, for small counts copy bytes  */

        sub     %o0, %o1, %o4   /* get difference of two addresses  */
        cmp     %o2, %o4        /* compare size and difference of addresses  */
        bgu     %XCC, .Lovbc    /* if size is bigger, have to do overlapped copy  */
         cmp    %o2, 17         /* delay slot, for small counts copy bytes  */
/*
 * normal, copy forwards
 */
2:      ble    %XCC, .Ldbytecp
         andcc  %o1, 3, %o5     /* is src word aligned  */

Where it should be a 'bleu' due the buffer length being a size_t.
Comment 1 Adhemerval Zanella 2024-01-22 13:02:51 UTC
Fixed on 2.39.