This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PPC64 strcmp bug


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]