Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 98187 | Differences between
and this patch

Collapse All | Expand All

(-)uClibc-0.9.27/ldso/ldso/ldso.c (-32 / +27 lines)
Lines 74-86 void _dl_debug_state(void) Link Here
74
static unsigned char *_dl_malloc_addr = 0;	/* Lets _dl_malloc use the already allocated memory page */
74
static unsigned char *_dl_malloc_addr = 0;	/* Lets _dl_malloc use the already allocated memory page */
75
static unsigned char *_dl_mmap_zero   = 0;	/* Also used by _dl_malloc */
75
static unsigned char *_dl_mmap_zero   = 0;	/* Also used by _dl_malloc */
76
76
77
#if defined (__SUPPORT_LD_DEBUG__)
77
static void __attribute_used__ _dl_fini(void)
78
static void debug_fini (int status, void *arg)
79
{
78
{
80
	(void)status;
79
	int i;
81
	_dl_dprintf(_dl_debug_file,"\ncalling fini: %s\n\n", (const char*)arg);
80
	struct elf_resolve * tpnt;
82
}
81
82
	for (i = 0; i < nlist; ++i) {
83
		tpnt = init_fini_list[i];
84
		if (tpnt->init_flag & FINI_FUNCS_CALLED)
85
			continue;
86
		tpnt->init_flag |= FINI_FUNCS_CALLED;
87
		if (tpnt->dynamic_info[DT_FINI]) {
88
			void (*dl_elf_func) (void);
89
90
			dl_elf_func = (void (*)(void)) (intptr_t) (tpnt->loadaddr + tpnt->dynamic_info[DT_FINI]);
91
#if defined (__SUPPORT_LD_DEBUG__)
92
			_dl_dprintf(_dl_debug_file,"\ncalling fini: %s\n\n", tpnt->libname);
83
#endif
93
#endif
94
			(*dl_elf_func) ();
95
		}
96
	}
97
}
84
98
85
void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
99
void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
86
			  Elf32_auxv_t auxvt[AT_EGID + 1], char **envp,
100
			  Elf32_auxv_t auxvt[AT_EGID + 1], char **envp,
Lines 98-110 void _dl_get_ready_to_run(struct elf_res Link Here
98
	struct elf_resolve *app_tpnt = &app_tpnt_tmp;
112
	struct elf_resolve *app_tpnt = &app_tpnt_tmp;
99
	struct r_debug *debug_addr;
113
	struct r_debug *debug_addr;
100
	unsigned long *lpnt;
114
	unsigned long *lpnt;
101
	int (*_dl_atexit) (void *);
102
	unsigned long *_dl_envp;		/* The environment address */
115
	unsigned long *_dl_envp;		/* The environment address */
103
	ElfW(Addr) relro_addr = 0;
116
	ElfW(Addr) relro_addr = 0;
104
	size_t relro_size = 0;
117
	size_t relro_size = 0;
105
#if defined (__SUPPORT_LD_DEBUG__)
106
	int (*_dl_on_exit) (void (*FUNCTION)(int STATUS, void *ARG),void*);
107
#endif
108
118
109
#ifdef __SUPPORT_LD_DEBUG_EARLY__
119
#ifdef __SUPPORT_LD_DEBUG_EARLY__
110
	/* Wahoo!!! */
120
	/* Wahoo!!! */
Lines 798-809 next_lib2: Link Here
798
	}
808
	}
799
#endif
809
#endif
800
810
801
	_dl_atexit = (int (*)(void *)) (intptr_t) _dl_find_hash("atexit", _dl_symbol_tables, NULL, ELF_RTYPE_CLASS_PLT);
802
#if defined (__SUPPORT_LD_DEBUG__)
803
	_dl_on_exit = (int (*)(void (*)(int, void *),void*))
804
		(intptr_t) _dl_find_hash("on_exit", _dl_symbol_tables, NULL, ELF_RTYPE_CLASS_PLT);
805
#endif
806
807
	/* Notify the debugger we have added some objects. */
811
	/* Notify the debugger we have added some objects. */
808
	_dl_debug_addr->r_state = RT_ADD;
812
	_dl_debug_addr->r_state = RT_ADD;
809
	_dl_debug_state();
813
	_dl_debug_state();
Lines 829-853 next_lib2: Link Here
829
			(*dl_elf_func) ();
833
			(*dl_elf_func) ();
830
		}
834
		}
831
		tpnt->init_flag |= FINI_FUNCS_CALLED;
835
		tpnt->init_flag |= FINI_FUNCS_CALLED;
832
		if (_dl_atexit && tpnt->dynamic_info[DT_FINI]) {
833
			void (*dl_elf_func) (void);
834
835
			dl_elf_func = (void (*)(void)) (intptr_t) (tpnt->loadaddr + tpnt->dynamic_info[DT_FINI]);
836
			(*_dl_atexit) (dl_elf_func);
837
#if defined (__SUPPORT_LD_DEBUG__)
838
			if(_dl_debug && _dl_on_exit) {
839
				(*_dl_on_exit)(debug_fini, tpnt->libname);
840
			}
841
#endif
842
		}
843
#if defined (__SUPPORT_LD_DEBUG__)
844
		else {
845
			if (!_dl_atexit)
846
				_dl_dprintf(_dl_debug_file, "%s: The address of atexit () is 0x0.\n", tpnt->libname);
847
		}
848
#endif
849
	}
836
	}
850
837
838
	{
839
		void (*__set__dl_fini) (void *);
840
841
		__set__dl_fini = (void (*)(void *)) (intptr_t) _dl_find_hash("_set__dl_fini",
842
					_dl_symbol_tables, NULL, ELF_RTYPE_CLASS_PLT);
843
		(*__set__dl_fini) (_dl_fini);
844
	}
845
	
851
	/* Notify the debugger that all objects are now mapped in.  */
846
	/* Notify the debugger that all objects are now mapped in.  */
852
	_dl_debug_addr->r_state = RT_CONSISTENT;
847
	_dl_debug_addr->r_state = RT_CONSISTENT;
853
	_dl_debug_state();
848
	_dl_debug_state();
(-)uClibc-0.9.27/libc/misc/internals/__uClibc_main.c (+10 lines)
Lines 158-163 void __uClibc_init(void) Link Here
158
void (*__app_fini)(void) = NULL;
158
void (*__app_fini)(void) = NULL;
159
#endif
159
#endif
160
160
161
#ifdef _DL_FINI_CRT_COMPAT
162
void attribute_hidden (*__dl_fini)(void) = NULL;
163
164
void _set__dl_fini(void *fini_func)
165
{
166
	if (fini_func != NULL)
167
		__dl_fini = fini_func;
168
}
169
#endif
170
161
/* __uClibc_start_main is the new main stub for uClibc. This function is
171
/* __uClibc_start_main is the new main stub for uClibc. This function is
162
 * called from crt0 (version 0.9.16 or newer), after ALL shared libraries
172
 * called from crt0 (version 0.9.16 or newer), after ALL shared libraries
163
 * are initialized, just before we call the application's main function.
173
 * are initialized, just before we call the application's main function.
(-)uClibc-0.9.27/libc/stdlib/atexit.c (+5 lines)
Lines 222-227 pthread_mutex_t mylock = PTHREAD_RECURSI Link Here
222
extern void (*__app_fini)(void);
222
extern void (*__app_fini)(void);
223
#endif
223
#endif
224
224
225
extern void (*__dl_fini)(void);
226
225
/*
227
/*
226
 * Normal program termination
228
 * Normal program termination
227
 */
229
 */
Lines 239-244 void exit(int rv) Link Here
239
		(__app_fini)();
241
		(__app_fini)();
240
#endif
242
#endif
241
243
244
	if (__dl_fini != NULL)
245
		(__dl_fini)();
246
242
    /* If we are using stdio, try to shut it down.  At the very least,
247
    /* If we are using stdio, try to shut it down.  At the very least,
243
	 * this will attempt to commit all buffered writes.  It may also
248
	 * this will attempt to commit all buffered writes.  It may also
244
	 * unbuffer all writable files, or close them outright.
249
	 * unbuffer all writable files, or close them outright.

Return to bug 98187