Setting up TLS block for the main thread must be done after the
relocations are processed, since tls initialization section might be itself subject for relocations. Only set up of the block is postponed, the tls block offsets are allocated before relocation processing, since TLS-related relocations may need offsets ready. Reported by: ale PR: threads/161344 Reviewed by: kan MFC after: 1 week
This commit is contained in:
parent
112a855de7
commit
4e63ea7386
@ -495,8 +495,12 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
|
|||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setup TLS for main thread */
|
/*
|
||||||
dbg("initializing initial thread local storage");
|
* Processing tls relocations requires having the tls offsets
|
||||||
|
* initialized. Prepare offsets before starting initial
|
||||||
|
* relocation processing.
|
||||||
|
*/
|
||||||
|
dbg("initializing initial thread local storage offsets");
|
||||||
STAILQ_FOREACH(entry, &list_main, link) {
|
STAILQ_FOREACH(entry, &list_main, link) {
|
||||||
/*
|
/*
|
||||||
* Allocate all the initial objects out of the static TLS
|
* Allocate all the initial objects out of the static TLS
|
||||||
@ -504,7 +508,6 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
|
|||||||
*/
|
*/
|
||||||
allocate_tls_offset(entry->obj);
|
allocate_tls_offset(entry->obj);
|
||||||
}
|
}
|
||||||
allocate_initial_tls(obj_list);
|
|
||||||
|
|
||||||
if (relocate_objects(obj_main,
|
if (relocate_objects(obj_main,
|
||||||
ld_bind_now != NULL && *ld_bind_now != '\0', &obj_rtld, NULL) == -1)
|
ld_bind_now != NULL && *ld_bind_now != '\0', &obj_rtld, NULL) == -1)
|
||||||
@ -519,6 +522,14 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
|
|||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Setup TLS for main thread. This must be done after the
|
||||||
|
* relocations are processed, since tls initialization section
|
||||||
|
* might be the subject for relocations.
|
||||||
|
*/
|
||||||
|
dbg("initializing initial thread local storage");
|
||||||
|
allocate_initial_tls(obj_list);
|
||||||
|
|
||||||
dbg("initializing key program variables");
|
dbg("initializing key program variables");
|
||||||
set_program_var("__progname", argv[0] != NULL ? basename(argv[0]) : "");
|
set_program_var("__progname", argv[0] != NULL ? basename(argv[0]) : "");
|
||||||
set_program_var("environ", env);
|
set_program_var("environ", env);
|
||||||
|
Loading…
Reference in New Issue
Block a user