]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/patches/glibc-remove-ctors-dtors-output-sections.patch
Merge branch 'strongswan-5' into thirteen
[people/teissler/ipfire-2.x.git] / src / patches / glibc-remove-ctors-dtors-output-sections.patch
1 From 4a531bb0b3b582cb693de9f76d2d97d970f9a5d5 Mon Sep 17 00:00:00 2001
2 From: H.J. Lu <hongjiu.lu@intel.com>
3 Date: Fri, 24 Dec 2010 20:14:37 -0500
4 Subject: [PATCH] Remove `.ctors' and `.dtors' output sections
5
6 ---
7 config.h.in | 3 +
8 configure.in | 2 +
9 elf/sofini.c | 2 +
10 elf/soinit.c | 2 +
11 sysdeps/i386/init-first.c | 2 +
12 sysdeps/mach/hurd/i386/init-first.c | 2 +-
13 sysdeps/mach/hurd/powerpc/init-first.c | 2 +-
14 sysdeps/sh/init-first.c | 2 +
15 sysdeps/unix/sysv/linux/init-first.c | 2 +-
16 9 files changed, 16 insertions(+), 3 deletions(-)
17
18 diff --git a/config.h.in b/config.h.in
19 index 18bf01a..9e797eb 100644
20 --- a/config.h.in
21 +++ b/config.h.in
22 @@ -201,6 +201,9 @@
23 /* Define if multi-arch DSOs should be generated. */
24 #undef USE_MULTIARCH
25
26 +/* Define if `.ctors' and `.dtors' sections shouldn't be used. */
27 +#undef NO_CTORS_DTORS_SECTIONS
28 +
29 /*
30 \f */
31
32 diff --git a/configure.in b/configure.in
33 index d8cd5f1..ad25b9b 100644
34 --- a/configure.in
35 +++ b/configure.in
36 @@ -1497,6 +1497,8 @@ EOF
37 rm -f conftest*])
38 if test $libc_cv_initfini_array != yes; then
39 AC_MSG_ERROR([Need linker with .init_array/.fini_array support.])
40 + elif AC_TRY_COMMAND([${CC-cc} -Wl,--verbose 2>&1|grep SORT_BY_INIT_PRIORITY 1>&AS_MESSAGE_LOG_FD]); then
41 + AC_DEFINE(NO_CTORS_DTORS_SECTIONS)
42 fi
43
44 AC_CACHE_CHECK(for libunwind-support in compiler,
45 diff --git a/elf/sofini.c b/elf/sofini.c
46 index 5e06f0c..13e74b7 100644
47 --- a/elf/sofini.c
48 +++ b/elf/sofini.c
49 @@ -1,12 +1,14 @@
50 /* Finalizer module for ELF shared C library. This provides terminating
51 null pointer words in the `.ctors' and `.dtors' sections. */
52
53 +#ifndef NO_CTORS_DTORS_SECTIONS
54 static void (*const __CTOR_END__[1]) (void)
55 __attribute__ ((used, section (".ctors")))
56 = { 0 };
57 static void (*const __DTOR_END__[1]) (void)
58 __attribute__ ((used, section (".dtors")))
59 = { 0 };
60 +#endif
61
62 /* Terminate the frame unwind info section with a 4byte 0 as a sentinel;
63 this would be the 'length' field in a real FDE. */
64 diff --git a/elf/soinit.c b/elf/soinit.c
65 index 6fecbb5..1db676a 100644
66 --- a/elf/soinit.c
67 +++ b/elf/soinit.c
68 @@ -3,6 +3,7 @@
69 the `.ctors' and `.dtors' sections so the lists are terminated, and
70 calling those lists of functions. */
71
72 +#ifndef NO_CTORS_DTORS_SECTIONS
73 #include <libc-internal.h>
74 #include <stdlib.h>
75
76 @@ -40,3 +41,4 @@ __libc_fini (void)
77
78 void (*_fini_ptr) (void) __attribute__ ((section (".fini_array")))
79 = &__libc_fini;
80 +#endif
81 diff --git a/sysdeps/i386/init-first.c b/sysdeps/i386/init-first.c
82 index c6355a8..2af042f 100644
83 --- a/sysdeps/i386/init-first.c
84 +++ b/sysdeps/i386/init-first.c
85 @@ -59,7 +59,9 @@ _init (int argc, ...)
86 {
87 init (&argc);
88
89 +#ifndef NO_CTORS_DTORS_SECTIONS
90 __libc_global_ctors ();
91 +#endif
92 }
93 #endif
94
95 diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c
96 index f9a7a58..60823bd 100644
97 --- a/sysdeps/mach/hurd/i386/init-first.c
98 +++ b/sysdeps/mach/hurd/i386/init-first.c
99 @@ -92,7 +92,7 @@ posixland_init (int argc, char **argv, char **envp)
100 __getopt_clean_environment (envp);
101 #endif
102
103 -#ifdef SHARED
104 +#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
105 __libc_global_ctors ();
106 #endif
107 }
108 diff --git a/sysdeps/mach/hurd/powerpc/init-first.c b/sysdeps/mach/hurd/powerpc/init-first.c
109 index 20fa1d4..21b5054 100644
110 --- a/sysdeps/mach/hurd/powerpc/init-first.c
111 +++ b/sysdeps/mach/hurd/powerpc/init-first.c
112 @@ -82,7 +82,7 @@ posixland_init (int argc, char **argv, char **envp)
113 __getopt_clean_environment (__environ);
114 #endif
115
116 -#ifdef SHARED
117 +#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
118 __libc_global_ctors ();
119 #endif
120 }
121 diff --git a/sysdeps/sh/init-first.c b/sysdeps/sh/init-first.c
122 index d816625..1f3a821 100644
123 --- a/sysdeps/sh/init-first.c
124 +++ b/sysdeps/sh/init-first.c
125 @@ -59,7 +59,9 @@ _init (int argc, ...)
126 {
127 init (&argc);
128
129 +#ifndef NO_CTORS_DTORS_SECTIONS
130 __libc_global_ctors ();
131 +#endif
132 }
133 #endif
134
135 diff --git a/sysdeps/unix/sysv/linux/init-first.c b/sysdeps/unix/sysv/linux/init-first.c
136 index 7b2333d..a60212f 100644
137 --- a/sysdeps/unix/sysv/linux/init-first.c
138 +++ b/sysdeps/unix/sysv/linux/init-first.c
139 @@ -93,7 +93,7 @@ _init (int argc, char **argv, char **envp)
140 __getopt_clean_environment (envp);
141 #endif
142
143 -#ifdef SHARED
144 +#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
145 __libc_global_ctors ();
146 #endif
147 }
148 --
149 1.7.3.4
150