Use a less misleading name for the code that sets up the main thread.
Change-Id: I50c1b0a3b633cf8bc40a6bd86f12adb6b91e2888
This commit is contained in:
parent
c99fabb7a0
commit
d29486343a
@ -64,18 +64,15 @@ char** environ;
|
||||
// Declared in "private/bionic_ssp.h".
|
||||
uintptr_t __stack_chk_guard = 0;
|
||||
|
||||
/* Init TLS for the initial thread. Called by the linker _before_ libc is mapped
|
||||
* in memory. Beware: all writes to libc globals from this function will
|
||||
* apply to linker-private copies and will not be visible from libc later on.
|
||||
*
|
||||
* Note: this function creates a pthread_internal_t for the initial thread and
|
||||
* stores the pointer in TLS, but does not add it to pthread's thread list. This
|
||||
* has to be done later from libc itself (see __libc_init_common).
|
||||
*
|
||||
* This function also stores a pointer to the kernel argument block in a TLS slot to be
|
||||
* picked up by the libc constructor.
|
||||
*/
|
||||
void __libc_init_tls(KernelArgumentBlock& args) {
|
||||
// Setup for the main thread. For dynamic executables, this is called by the
|
||||
// linker _before_ libc is mapped in memory. This means that all writes to
|
||||
// globals from this function will apply to linker-private copies and will not
|
||||
// be visible from libc later on.
|
||||
//
|
||||
// Note: this function creates a pthread_internal_t for the initial thread and
|
||||
// stores the pointer in TLS, but does not add it to pthread's thread list. This
|
||||
// has to be done later from libc itself (see __libc_init_common).
|
||||
void __libc_init_main_thread(KernelArgumentBlock& args) {
|
||||
__libc_auxv = args.auxv;
|
||||
|
||||
static pthread_internal_t main_thread;
|
||||
@ -99,6 +96,9 @@ void __libc_init_tls(KernelArgumentBlock& args) {
|
||||
__init_thread(&main_thread);
|
||||
__init_tls(&main_thread);
|
||||
__set_tls(main_thread.tls);
|
||||
|
||||
// Store a pointer to the kernel argument block in a TLS slot to be
|
||||
// picked up by the libc constructor.
|
||||
main_thread.tls[TLS_SLOT_BIONIC_PREINIT] = &args;
|
||||
|
||||
__init_alternate_signal_stack(&main_thread);
|
||||
|
@ -90,7 +90,7 @@ __noreturn void __libc_init(void* raw_args,
|
||||
int (*slingshot)(int, char**, char**),
|
||||
structors_array_t const * const structors) {
|
||||
KernelArgumentBlock args(raw_args);
|
||||
__libc_init_tls(args);
|
||||
__libc_init_main_thread(args);
|
||||
__libc_init_AT_SECURE(args);
|
||||
__libc_init_common(args);
|
||||
|
||||
|
@ -114,7 +114,7 @@ __END_DECLS
|
||||
|
||||
#if defined(__cplusplus)
|
||||
class KernelArgumentBlock;
|
||||
extern __LIBC_HIDDEN__ void __libc_init_tls(KernelArgumentBlock& args);
|
||||
extern __LIBC_HIDDEN__ void __libc_init_main_thread(KernelArgumentBlock& args);
|
||||
#endif
|
||||
|
||||
#endif /* __BIONIC_PRIVATE_BIONIC_TLS_H_ */
|
||||
|
@ -3465,7 +3465,7 @@ extern "C" ElfW(Addr) __linker_init(void* raw_args) {
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
__libc_init_tls(args);
|
||||
__libc_init_main_thread(args);
|
||||
|
||||
// Initialize the linker's own global variables
|
||||
linker_so.call_constructors();
|
||||
|
Loading…
Reference in New Issue
Block a user