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
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(-)
18 diff --git a/config.h.in b/config.h.in
19 index 18bf01a..9e797eb 100644
23 /* Define if multi-arch DSOs should be generated. */
26 +/* Define if `.ctors' and `.dtors' sections shouldn't be used. */
27 +#undef NO_CTORS_DTORS_SECTIONS
32 diff --git a/configure.in b/configure.in
33 index d8cd5f1..ad25b9b 100644
36 @@ -1497,6 +1497,8 @@ EOF
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)
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
50 /* Finalizer module for ELF shared C library. This provides terminating
51 null pointer words in the `.ctors' and `.dtors' sections. */
53 +#ifndef NO_CTORS_DTORS_SECTIONS
54 static void (*const __CTOR_END__[1]) (void)
55 __attribute__ ((used, section (".ctors")))
57 static void (*const __DTOR_END__[1]) (void)
58 __attribute__ ((used, section (".dtors")))
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
69 the `.ctors' and `.dtors' sections so the lists are terminated, and
70 calling those lists of functions. */
72 +#ifndef NO_CTORS_DTORS_SECTIONS
73 #include <libc-internal.h>
76 @@ -40,3 +41,4 @@ __libc_fini (void)
78 void (*_fini_ptr) (void) __attribute__ ((section (".fini_array")))
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, ...)
89 +#ifndef NO_CTORS_DTORS_SECTIONS
90 __libc_global_ctors ();
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);
104 +#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
105 __libc_global_ctors ();
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);
117 +#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
118 __libc_global_ctors ();
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, ...)
129 +#ifndef NO_CTORS_DTORS_SECTIONS
130 __libc_global_ctors ();
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);
144 +#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
145 __libc_global_ctors ();