PPC64 strcmp bug
Jakub Jelinek
jakub@redhat.com
Fri Apr 11 19:08:00 GMT 2003
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
More information about the Libc-alpha
mailing list