Account for alloca size rounding in extend_alloca
authorAndreas Schwab <schwab@linux-m68k.org>
Tue, 1 Nov 2011 17:05:31 +0000 (18:05 +0100)
committerAndreas Schwab <schwab@linux-m68k.org>
Tue, 1 Nov 2011 17:29:34 +0000 (18:29 +0100)
ChangeLog
elf/dl-deps.c
include/alloca.h

index c8bf9b7..a70847e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2011-11-01  Andreas Schwab  <schwab@linux-m68k.org>
 
+       * include/alloca.h (stackinfo_alloca_round): Define.
+       (extend_alloca): Use it.
+       [_STACK_GROWS_UP]: Correct check for adjacent allocation.
+       * elf/dl-deps.c (_dl_map_object_deps): Don't round alloca size
+       here.
+
        * scripts/check-local-headers.sh: Ignore libaudit.h.
 
        * nscd/Makefile (extra-objs): Make recursively expanded.
index a1ba3d1..565a339 100644 (file)
@@ -221,15 +221,11 @@ _dl_map_object_deps (struct link_map *map,
       if (l->l_searchlist.r_list == NULL && l->l_initfini == NULL
          && l != map && l->l_ldnum > 0)
        {
-         /* 16-align so extend_alloca has a chance to re-use the space.
-            Note that extend_alloca is broken for recent versions of GCC
-            on x86: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50938  */
-         size_t new_size
-            = (l->l_ldnum * sizeof (struct link_map *) + 15) & ~15;
+         size_t new_size = l->l_ldnum * sizeof (struct link_map *);
 
          if (new_size > needed_space_bytes)
            needed_space
-              = extend_alloca (needed_space, needed_space_bytes, new_size);
+             = extend_alloca (needed_space, needed_space_bytes, new_size);
 
          needed = needed_space;
        }
index 8350413..f741d25 100644 (file)
@@ -20,9 +20,13 @@ libc_hidden_proto (__libc_alloca_cutoff)
 
 #include <allocalim.h>
 
+#ifndef stackinfo_alloca_round
+# define stackinfo_alloca_round(l) (((l) + 15) & -16)
+#endif
+
 #if _STACK_GROWS_DOWN
 # define extend_alloca(buf, len, newlen) \
-  (__typeof (buf)) ({ size_t __newlen = (newlen);                            \
+  (__typeof (buf)) ({ size_t __newlen = stackinfo_alloca_round (newlen);      \
                      char *__newbuf = __alloca (__newlen);                   \
                      if (__newbuf + __newlen == (char *) buf)                \
                        len += __newlen;                                      \
@@ -31,10 +35,10 @@ libc_hidden_proto (__libc_alloca_cutoff)
                      __newbuf; })
 #elif _STACK_GROWS_UP
 # define extend_alloca(buf, len, newlen) \
-  (__typeof (buf)) ({ size_t __newlen = (newlen);                            \
+  (__typeof (buf)) ({ size_t __newlen = stackinfo_alloca_round (newlen);      \
                      char *__newbuf = __alloca (__newlen);                   \
                      char *__buf = (buf);                                    \
-                     if (__buf + __newlen == __newbuf)                       \
+                     if (__buf + len == __newbuf)                            \
                        {                                                     \
                          len += __newlen;                                    \
                          __newbuf = __buf;                                   \