This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
PPC64 strcmp bug
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Steve Munroe <sjmunroe at us dot ibm dot com>
- Cc: libc-alpha at sources dot redhat dot com
- Date: Fri, 11 Apr 2003 21:08:41 +0200
- Subject: PPC64 strcmp bug
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
strcmp is broken on PPC64, as it is declared to return int and PPC64 ABI
requires int return value to be sign extended into %r3 by callee.
Testcase:
#include <string.h>
#include <stdlib.h>
long l;
void
foo (void)
{
char s1[] = { 0x41, 0x42, 0 }, s2[] = { 0xc1, 0x42, 0 };
l = strcmp (s1, s2);
}
int
main (void)
{
foo ();
if (l >= 0)
abort ();
exit (0);
}
Either sysdeps/powerpc/powerpc64/strcmp.S needs to be rewritten to
compare 8 bytes at a time, or it needs extsw rRTN, rRTN
inserted where needed (with the conditional returns if they happen
to be in loops it would be better to replace them with conditional
jumps to extsw rRTN, rRTN; blr I guess).
Jakub