From 39778c6c9e6455303979aca2dc4685bf56cdc9be Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 19 Aug 1996 01:07:44 +0000 Subject: update from main archive 960818 --- elf/dl-open.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'elf/dl-open.c') diff --git a/elf/dl-open.c b/elf/dl-open.c index 9dda31e761..40b5224725 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -22,6 +22,11 @@ Cambridge, MA 02139, USA. */ #include #include + +extern void _dl_start (void); weak_extern (_dl_start) + +extern int __libc_multiple_libcs; /* Defined in init-first.c. */ + size_t _dl_global_scope_alloc; struct link_map * @@ -30,7 +35,9 @@ _dl_open (const char *file, int mode) struct link_map *new, *l; ElfW(Addr) init; struct r_debug *r; - + /* To decide whether we are the static libc or not. We must use + this variable since gcc would otherwise optimize the test away. */ + void (*dl_start_ptr) (void) = &_dl_start; /* Load the named object. */ new = _dl_map_object (NULL, file, lt_loaded); @@ -131,5 +138,11 @@ _dl_open (const char *file, int mode) while (init = _dl_init_next (new)) (*(void (*) (void)) init) (); + if (dl_start_ptr == NULL) + /* We must be the static _dl_open in libc.a because ld.so.1 is not + in scope. A static program that has loaded a dynamic object + now has competition. */ + __libc_multiple_libcs = 1; + return new; } -- cgit 1.4.1