diff options
| -rw-r--r-- | ldso/dynlink.c | 12 | 
1 files changed, 7 insertions, 5 deletions
diff --git a/ldso/dynlink.c b/ldso/dynlink.c index d1edb131..93ef3633 100644 --- a/ldso/dynlink.c +++ b/ldso/dynlink.c @@ -1874,11 +1874,8 @@ void __dls3(size_t *sp)  	 * code can see to perform. */  	main_ctor_queue = queue_ctors(&app); -	/* The main program must be relocated LAST since it may contin -	 * copy relocations which depend on libraries' relocations. */ -	reloc_all(app.next); -	reloc_all(&app); - +	/* Initial TLS must also be allocated before final relocations +	 * might result in calloc being a call to application code. */  	update_tls_size();  	if (libc.tls_size > sizeof builtin_tls || tls_align > MIN_TLS_ALIGN) {  		void *initial_tls = calloc(libc.tls_size, 1); @@ -1902,6 +1899,11 @@ void __dls3(size_t *sp)  	}  	static_tls_cnt = tls_cnt; +	/* The main program must be relocated LAST since it may contin +	 * copy relocations which depend on libraries' relocations. */ +	reloc_all(app.next); +	reloc_all(&app); +  	if (ldso_fail) _exit(127);  	if (ldd_mode) _exit(0);  | 
