From: Kaveh R. Ghazi Date: Mon, 6 Feb 2006 14:06:55 +0000 (+0000) Subject: backport: re PR other/13906 (genmodes.c:964: internal compiler error: Bus error in... X-Git-Tag: releases/gcc-3.4.6~100 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0759e6682f2e057e9e0665ea3c8ade8d688b4c7e;p=thirdparty%2Fgcc.git backport: re PR other/13906 (genmodes.c:964: internal compiler error: Bus error in md5_process_block) include: Backport: 2006-01-18 DJ Delorie * md5.h: Include ansidecl.h 2005-07-03 Steve Ellcey PR other/13906 * ansidecl.h (ATTRIBUTE_ALIGNED_ALIGNOF): New. * md5.h (md5_uintptr): New. (md5_ctx): Align buffer field. libiberty: Backport: 2005-07-03 Steve Ellcey PR other/13906 * md5.c (md5_process_bytes): Check alignment. From-SVN: r110643 --- diff --git a/include/ChangeLog b/include/ChangeLog index 3662517c69db..de5f23a6bb3f 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,17 @@ +2006-02-06 Kaveh R. Ghazi + + Backport: + 2006-01-18 DJ Delorie + + * md5.h: Include ansidecl.h + + 2005-07-03 Steve Ellcey + + PR other/13906 + * ansidecl.h (ATTRIBUTE_ALIGNED_ALIGNOF): New. + * md5.h (md5_uintptr): New. + (md5_ctx): Align buffer field. + 2005-11-30 Release Manager * GCC 3.4.5 released. diff --git a/include/ansidecl.h b/include/ansidecl.h index d2c87768ce2e..ee0aecf22de8 100644 --- a/include/ansidecl.h +++ b/include/ansidecl.h @@ -305,6 +305,15 @@ So instead we use the macro below and test it against specific values. */ # define ATTRIBUTE_NULL_PRINTF_5 ATTRIBUTE_NULL_PRINTF(5, 6) #endif /* ATTRIBUTE_NULL_PRINTF */ + +#ifndef ATTRIBUTE_ALIGNED_ALIGNOF +# if (GCC_VERSION >= 3000) +# define ATTRIBUTE_ALIGNED_ALIGNOF(m) __attribute__ ((__aligned__ (__alignof__ (m)))) +# else +# define ATTRIBUTE_ALIGNED_ALIGNOF(m) +# endif /* GNUC >= 3.0 */ +#endif /* ATTRIBUTE_ALIGNED_ALIGNOF */ + /* We use __extension__ in some places to suppress -pedantic warnings about GCC extensions. This feature didn't work properly before gcc 2.8. */ diff --git a/include/md5.h b/include/md5.h index ad51f19877a2..4d6161c32361 100644 --- a/include/md5.h +++ b/include/md5.h @@ -27,6 +27,8 @@ # include #endif +#include "ansidecl.h" + /* The following contortions are an attempt to use the C preprocessor to determine an unsigned integral type that is 32 bits wide. An alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but @@ -37,6 +39,7 @@ #ifdef _LIBC # include typedef u_int32_t md5_uint32; +typedef uintptr_t md5_uintptr; #else # define INT_MAX_32_BITS 2147483647 @@ -64,6 +67,9 @@ typedef u_int32_t md5_uint32; # endif # endif # endif +/* We have to make a guess about the integer type equivalent in size + to pointers which should always be correct. */ +typedef unsigned long int md5_uintptr; #endif #undef __P @@ -83,7 +89,7 @@ struct md5_ctx md5_uint32 total[2]; md5_uint32 buflen; - char buffer[128]; + char buffer[128] ATTRIBUTE_ALIGNED_ALIGNOF(md5_uint32); }; /* diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 02c79baf8c5f..f0b0cec5e20e 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,11 @@ +2006-02-06 Kaveh R. Ghazi + + Backport: + 2005-07-03 Steve Ellcey + + PR other/13906 + * md5.c (md5_process_bytes): Check alignment. + 2005-11-30 Release Manager * GCC 3.4.5 released. diff --git a/libiberty/md5.c b/libiberty/md5.c index e458f2a6a641..7a202d8c1231 100644 --- a/libiberty/md5.c +++ b/libiberty/md5.c @@ -236,6 +236,23 @@ md5_process_bytes (buffer, len, ctx) /* Process available complete blocks. */ if (len > 64) { +#if !_STRING_ARCH_unaligned +/* To check alignment gcc has an appropriate operator. Other + compilers don't. */ +# if __GNUC__ >= 2 +# define UNALIGNED_P(p) (((md5_uintptr) p) % __alignof__ (md5_uint32) != 0) +# else +# define UNALIGNED_P(p) (((md5_uintptr) p) % sizeof (md5_uint32) != 0) +# endif + if (UNALIGNED_P (buffer)) + while (len > 64) + { + md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); + buffer = (const char *) buffer + 64; + len -= 64; + } + else +#endif md5_process_block (buffer, len & ~63, ctx); buffer = (const void *) ((const char *) buffer + (len & ~63)); len &= 63;