patches/glibc/ports-2.10.1/170-localedef-fix-trampoline.patch
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Mon Feb 13 21:47:25 2012 +0100 (2012-02-13)
changeset 2883 cea814c9932a
permissions -rw-r--r--
libc/glibc: do not consume parameters when parsing them

Currently, there are two constructs used to parse arguments in
glibc backends, one that consumes args as they are parsed, and
one that does not.

Always use the construct that does not eat args as they are parsed.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
yann@1625
     1
#! /bin/sh -e
yann@1625
     2
yann@1625
     3
# DP: Description: Fix localedef segfault when run under exec-shield,
yann@1625
     4
#        PaX or similar. (#231438, #198099)
yann@1625
     5
# DP: Dpatch Author: James Troup <james@nocrew.org>
yann@1625
     6
# DP: Patch Author: (probably) Jakub Jelinek <jakub@redhat.com>
yann@1625
     7
# DP: Upstream status: Unknown
yann@1625
     8
# DP: Status Details: Unknown
yann@1625
     9
# DP: Date: 2004-03-16
yann@1625
    10
yann@1625
    11
if [ $# -ne 2 ]; then
yann@1625
    12
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
yann@1625
    13
    exit 1
yann@1625
    14
fi
yann@1625
    15
case "$1" in
yann@1625
    16
    -patch) patch -d "$2" -f --no-backup-if-mismatch -p1 < $0;;
yann@1625
    17
    -unpatch) patch -d "$2" -f --no-backup-if-mismatch -R -p1 < $0;;
yann@1625
    18
    *)
yann@1625
    19
	echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
yann@1625
    20
	exit 1
yann@1625
    21
esac
yann@1625
    22
exit 0
yann@1625
    23
yann@1625
    24
diff -durN glibc-2.10.1.orig/locale/programs/3level.h glibc-2.10.1/locale/programs/3level.h
yann@1625
    25
--- glibc-2.10.1.orig/locale/programs/3level.h	2007-07-16 02:54:59.000000000 +0200
yann@1625
    26
+++ glibc-2.10.1/locale/programs/3level.h	2009-11-13 00:49:56.000000000 +0100
yann@1625
    27
@@ -203,6 +203,42 @@
yann@1625
    28
 	}
yann@1625
    29
     }
yann@1625
    30
 }
yann@1625
    31
+
yann@1625
    32
+/* GCC ATM seems to do a poor job with pointers to nested functions passed
yann@1625
    33
+   to inlined functions.  Help it a little bit with this hack.  */
yann@1625
    34
+#define wchead_table_iterate(tp, fn) \
yann@1625
    35
+do									      \
yann@1625
    36
+  {									      \
yann@1625
    37
+    struct wchead_table *t = (tp);					      \
yann@1625
    38
+    uint32_t index1;							      \
yann@1625
    39
+    for (index1 = 0; index1 < t->level1_size; index1++)			      \
yann@1625
    40
+      {									      \
yann@1625
    41
+	uint32_t lookup1 = t->level1[index1];				      \
yann@1625
    42
+	if (lookup1 != ((uint32_t) ~0))					      \
yann@1625
    43
+	  {								      \
yann@1625
    44
+	    uint32_t lookup1_shifted = lookup1 << t->q;			      \
yann@1625
    45
+	    uint32_t index2;						      \
yann@1625
    46
+	    for (index2 = 0; index2 < (1 << t->q); index2++)		      \
yann@1625
    47
+	      {								      \
yann@1625
    48
+		uint32_t lookup2 = t->level2[index2 + lookup1_shifted];	      \
yann@1625
    49
+		if (lookup2 != ((uint32_t) ~0))				      \
yann@1625
    50
+		  {							      \
yann@1625
    51
+		    uint32_t lookup2_shifted = lookup2 << t->p;		      \
yann@1625
    52
+		    uint32_t index3;					      \
yann@1625
    53
+		    for (index3 = 0; index3 < (1 << t->p); index3++)	      \
yann@1625
    54
+		      {							      \
yann@1625
    55
+			struct element_t *lookup3			      \
yann@1625
    56
+			  = t->level3[index3 + lookup2_shifted];	      \
yann@1625
    57
+			if (lookup3 != NULL)				      \
yann@1625
    58
+			  fn ((((index1 << t->q) + index2) << t->p) + index3, \
yann@1625
    59
+			      lookup3);					      \
yann@1625
    60
+		      }							      \
yann@1625
    61
+		  }							      \
yann@1625
    62
+	      }								      \
yann@1625
    63
+	  }								      \
yann@1625
    64
+      }									      \
yann@1625
    65
+  } while (0)
yann@1625
    66
+
yann@1625
    67
 #endif
yann@1625
    68
 
yann@1625
    69
 #ifndef NO_FINALIZE