fixed big-endian problems in strcpy + strcmp
This commit is contained in:
parent
9c4dfc9262
commit
f64111dd32
2 changed files with 55 additions and 0 deletions
53
dietlibc-0.31.20080212-strend.patch
Normal file
53
dietlibc-0.31.20080212-strend.patch
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
diff -upN dietlibc-0.31.20080212/lib/strcpy.c.~1~ dietlibc-0.31.20080212/lib/strcpy.c
|
||||
--- dietlibc-0.31.20080212/lib/strcpy.c.~1~ 2008-02-14 21:51:56.000000000 +0100
|
||||
+++ dietlibc-0.31.20080212/lib/strcpy.c 2008-02-14 22:45:56.000000000 +0100
|
||||
@@ -26,8 +26,7 @@ strcpy (char *s1, const char *s2)
|
||||
while (1) {
|
||||
l = *(const unsigned long *) s2;
|
||||
if (((l - MKW(0x1ul)) & ~l) & MKW(0x80ul)) {
|
||||
- unsigned char c;
|
||||
- while ((*s1++ = (l & 0xff))) l>>=8;
|
||||
+ while ((*s1++ = GFC(l))) INCSTR(l);
|
||||
return (res);
|
||||
}
|
||||
*(unsigned long *) s1 = l;
|
||||
diff -upN dietlibc-0.31.20080212/lib/strcmp.c.~1~ dietlibc-0.31.20080212/lib/strcmp.c
|
||||
--- dietlibc-0.31.20080212/lib/strcmp.c.~1~ 2008-02-14 21:51:56.000000000 +0100
|
||||
+++ dietlibc-0.31.20080212/lib/strcmp.c 2008-02-14 22:44:44.000000000 +0100
|
||||
@@ -35,12 +35,12 @@ strcmp (const char *s1, const char *s2)
|
||||
((((l2 - MKW(0x1ul)) & ~l2) & MKW(0x80ul))) || l1 != l2) {
|
||||
unsigned char c1, c2;
|
||||
while (1) {
|
||||
- c1 = l1 & 0xff;
|
||||
- c2 = l2 & 0xff;
|
||||
+ c1 = GFC(l1);
|
||||
+ c2 = GFC(l2);
|
||||
if (!c1 || c1 != c2)
|
||||
return (c1 - c2);
|
||||
- l1 >>= 8;
|
||||
- l2 >>= 8;
|
||||
+ INCSTR(l1);
|
||||
+ INCSTR(l2);
|
||||
}
|
||||
}
|
||||
}
|
||||
diff -upN dietlibc-0.31.20080212/dietstring.h.~1~ dietlibc-0.31.20080212/dietstring.h
|
||||
--- dietlibc-0.31.20080212/dietstring.h.~1~ 2003-12-21 13:06:36.000000000 +0100
|
||||
+++ dietlibc-0.31.20080212/dietstring.h 2008-02-14 22:45:56.000000000 +0100
|
||||
@@ -11,6 +11,16 @@
|
||||
# define STRALIGN(x) (((unsigned long)x&3)?4-((unsigned long)x&3):0)
|
||||
#endif
|
||||
|
||||
+/* GFC(x) - returns first character */
|
||||
+/* INCSTR(x) - moves to next character */
|
||||
+#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
+# define GFC(x) ((x)&0xff)
|
||||
+# define INCSTR(x) do { x >>= 8; } while (0)
|
||||
+#else
|
||||
+# define GFC(x) (((x)>>(sizeof(x)-8))&0xff)
|
||||
+# define INCSTR(x) do { x <<= 8; } while (0)
|
||||
+#endif
|
||||
+
|
||||
#define UNALIGNED(x,y) (((unsigned long)x & (sizeof (unsigned long)-1)) ^ ((unsigned long)y & (sizeof (unsigned long)-1)))
|
||||
|
||||
#endif /* _DIET_STRING_H_ */
|
||||
|
|
@ -53,6 +53,7 @@ Patch40: dietlibc-0.31-printftest.patch
|
|||
Patch41: dietlibc-0.31.20080212-teststdout.patch
|
||||
Patch42: dietlibc-0.31.20080212-strlen.patch
|
||||
Patch43: dietlibc-0.31.20080212-ulong.patch
|
||||
Patch44: dietlibc-0.31.20080212-strend.patch
|
||||
BuildRoot: %_tmppath/%name-%version-%release-buildroot
|
||||
%{?with_dynamic:Requires: dietlibc-lib = %version-%release}
|
||||
%{!?with_dynamic:Obsoletes: dietlibc-lib < %version-%release}
|
||||
|
|
@ -95,6 +96,7 @@ This package contains the dynamic libraries for dietlibc.
|
|||
%patch41 -p1 -b .teststdout
|
||||
%patch42 -p1 -b .strlen
|
||||
%patch43 -p1 -b .ulong
|
||||
%patch44 -p1 -b .strend
|
||||
|
||||
|
||||
%if %{without ssp}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue