1 #if defined __sparc__ && defined __arch64__
2 register void *__thread_self
__asm ("g7");
19 int status
, rerun_ldconfig
= 0, rerun_cnt
= 0;
27 } prefix
[] = { { "libc-", 5 }, { "libm-", 5 },
28 { "librt-", 6 }, { "libpthread-", 11 },
29 { "librtkaio-", 10 }, { "libthread_db-", 13 } };
34 const char *remove_dirs
[] = { "/lib/i686", "/lib/tls" };
36 const char *remove_dirs
[] = { "/lib/tls/i686" };
38 for (j
= 0; j
< sizeof (remove_dirs
) / sizeof (remove_dirs
[0]); ++j
)
40 size_t rmlen
= strlen (remove_dirs
[j
]);
41 fd
= open (remove_dirs
[j
], O_RDONLY
);
43 && (ret
= getdirentries (fd
, buffer
, sizeof (buffer
), &base
))
44 >= (ssize_t
) offsetof (struct dirent
, d_name
))
46 for (base
= 0; base
+ offsetof (struct dirent
, d_name
) < ret
; )
48 struct dirent
*d
= (struct dirent
*) (buffer
+ base
);
50 for (i
= 0; i
< sizeof (prefix
) / sizeof (prefix
[0]); i
++)
51 if (! strncmp (d
->d_name
, prefix
[i
].p
, prefix
[i
].len
))
53 char *p
= d
->d_name
+ prefix
[i
].len
;
55 while (*p
== '.' || (*p
>= '0' && *p
<= '9')) p
++;
56 if (p
[0] == 's' && p
[1] == 'o' && p
[2] == '\0'
58 < sizeof (initpath
) - rmlen
- 1)
60 memcpy (initpath
, remove_dirs
[j
], rmlen
);
61 initpath
[rmlen
] = '/';
62 strcpy (initpath
+ rmlen
+ 1, d
->d_name
);
74 int ldsocfd
= open (LD_SO_CONF
, O_RDONLY
);
76 if (ldsocfd
>= 0 && fstat (ldsocfd
, &ldsocst
) >= 0)
78 char p
[ldsocst
.st_size
+ 1];
79 if (read (ldsocfd
, p
, ldsocst
.st_size
) == ldsocst
.st_size
)
81 p
[ldsocst
.st_size
] = '\0';
82 if (strstr (p
, "include ld.so.conf.d/*.conf") == NULL
)
85 ldsocfd
= open (LD_SO_CONF
, O_WRONLY
| O_TRUNC
);
88 size_t slen
= strlen ("include ld.so.conf.d/*.conf\n");
89 if (write (ldsocfd
, "include ld.so.conf.d/*.conf\n", slen
)
91 || write (ldsocfd
, p
, ldsocst
.st_size
) != ldsocst
.st_size
)
102 char linkbuf
[64], *linkp
;
108 execl ("/sbin/ldconfig", "/sbin/ldconfig", NULL
);
113 if (waitpid (0, &status
, 0) != pid
|| !WIFEXITED (status
))
115 if (WEXITSTATUS (status
))
116 _exit (WEXITSTATUS (status
));
120 linkp
= linkbuf
+ strlen (LIBTLS
);
121 linklen
= readlink (LIBTLS
"librt.so.1", linkp
,
122 sizeof (linkbuf
) - 1 - strlen (LIBTLS
));
123 if (linklen
== strlen ("librtkaio-2.3.X.so")
124 && memcmp (linkp
, "librtkaio-2.3.", 14) == 0
125 && strchr ("23", linkp
[14])
126 && memcmp (linkp
+ 15, ".so", 4) == 0)
128 memcpy (linkbuf
, LIBTLS
, strlen (LIBTLS
));
135 linkp
= linkbuf
+ strlen ("/lib/i686/");
136 linklen
= readlink ("/lib/i686/librt.so.1", linkp
,
137 sizeof (linkbuf
) - 1 - strlen ("/lib/i686/"));
138 if (linklen
== strlen ("librtkaio-2.3.X.so")
139 && memcmp (linkp
, "librtkaio-2.3.", 14) == 0
140 && strchr ("23", linkp
[14])
141 && memcmp (linkp
+ 15, ".so", 4) == 0)
143 memcpy (linkbuf
, "/lib/i686/", strlen ("/lib/i686/"));
149 while (rerun_ldconfig
&& ++rerun_cnt
< 2);
151 if (! utimes (GCONV_MODULES_CACHE
, NULL
))
156 execl ("/usr/sbin/iconvconfig", "/usr/sbin/iconvconfig", NULL
);
161 if (waitpid (0, &status
, 0) != pid
|| !WIFEXITED (status
))
163 if (WEXITSTATUS (status
))
164 _exit (WEXITSTATUS (status
));
167 /* Check if telinit is available and the init fifo as well. */
168 if (access ("/sbin/telinit", X_OK
) || access ("/dev/initctl", F_OK
))
170 /* Check if we are not inside of some chroot, because we'd just
171 timeout and leave /etc/initrunlvl. */
172 if (readlink ("/proc/1/exe", initpath
, 256) <= 0 ||
173 readlink ("/proc/1/root", initpath
, 256) <= 0)
179 execl ("/sbin/telinit", "/sbin/telinit", "u", NULL
);
184 if (waitpid (0, &status
, 0) != pid
|| !WIFEXITED (status
))
187 /* Check if we can safely condrestart sshd. */
188 if (access ("/sbin/service", X_OK
) == 0
189 && access ("/usr/sbin/sshd", X_OK
) == 0
190 && access ("/bin/bash", X_OK
) == 0)
195 execl ("/sbin/service", "/sbin/service", "sshd", "condrestart", NULL
);
200 if (waitpid (0, &status
, 0) != pid
|| !WIFEXITED (status
))
207 int __libc_multiple_threads
__attribute__((nocommon
));
208 int __libc_enable_asynccancel (void) { return 0; }
209 void __libc_disable_asynccancel (int x
) { }
210 void __libc_csu_init (void) { }
211 void __libc_csu_fini (void) { }
212 pid_t
__fork (void) { return -1; }
216 int __libc_start_main (int (*main
) (void), int argc
, char **argv
,
217 void (*init
) (void), void (*fini
) (void),
218 void (*rtld_fini
) (void), void * stack_end
)
223 int (*main
) (int, char **, char **, void *);
224 int (*init
) (int, char **, char **, void *);
228 int __libc_start_main (int argc
, char **ubp_av
,
230 void *auxvec
, void (*rtld_fini
) (void),
231 struct startup_info
*stinfo
,
232 char **stack_on_entry
)
235 #if defined __ia64__ || defined __powerpc64__
236 register void *r13
__asm ("r13") = thr_buf
+ 32768;
237 __asm ("" : : "r" (r13
));
238 #elif defined __sparc__
239 register void *g6
__asm ("g6") = thr_buf
+ 32768;
241 __thread_self
= thr_buf
+ 32768;
243 register void *__thread_self
__asm ("g7") = thr_buf
+ 32768;
245 __asm ("" : : "r" (g6
), "r" (__thread_self
));
246 #elif defined __s390__ && !defined __s390x__
247 __asm ("sar %%a0,%0" : : "d" (thr_buf
+ 32768));
248 #elif defined __s390x__
249 __asm ("sar %%a1,%0; srlg 0,%0,32; sar %%a0,0" : : "d" (thr_buf
+ 32768) : "0");
250 #elif defined __powerpc__ && !defined __powerpc64__
251 register void *r2
__asm ("r2") = thr_buf
+ 32768;
252 __asm ("" : : "r" (r2
));