Use a less misleading name for the code that sets up the main thread.

Change-Id: I50c1b0a3b633cf8bc40a6bd86f12adb6b91e2888
This commit is contained in:
Elliott Hughes 2015-07-21 11:57:09 -07:00
parent c99fabb7a0
commit d29486343a
4 changed files with 15 additions and 15 deletions

View File

@ -64,18 +64,15 @@ char** environ;
// Declared in "private/bionic_ssp.h". // Declared in "private/bionic_ssp.h".
uintptr_t __stack_chk_guard = 0; uintptr_t __stack_chk_guard = 0;
/* Init TLS for the initial thread. Called by the linker _before_ libc is mapped // Setup for the main thread. For dynamic executables, this is called by the
* in memory. Beware: all writes to libc globals from this function will // linker _before_ libc is mapped in memory. This means that all writes to
* apply to linker-private copies and will not be visible from libc later on. // 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 // Note: this function creates a pthread_internal_t for the initial thread and
* has to be done later from libc itself (see __libc_init_common). // 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 void __libc_init_main_thread(KernelArgumentBlock& args) {
* picked up by the libc constructor.
*/
void __libc_init_tls(KernelArgumentBlock& args) {
__libc_auxv = args.auxv; __libc_auxv = args.auxv;
static pthread_internal_t main_thread; static pthread_internal_t main_thread;
@ -99,6 +96,9 @@ void __libc_init_tls(KernelArgumentBlock& args) {
__init_thread(&main_thread); __init_thread(&main_thread);
__init_tls(&main_thread); __init_tls(&main_thread);
__set_tls(main_thread.tls); __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; main_thread.tls[TLS_SLOT_BIONIC_PREINIT] = &args;
__init_alternate_signal_stack(&main_thread); __init_alternate_signal_stack(&main_thread);

View File

@ -90,7 +90,7 @@ __noreturn void __libc_init(void* raw_args,
int (*slingshot)(int, char**, char**), int (*slingshot)(int, char**, char**),
structors_array_t const * const structors) { structors_array_t const * const structors) {
KernelArgumentBlock args(raw_args); KernelArgumentBlock args(raw_args);
__libc_init_tls(args); __libc_init_main_thread(args);
__libc_init_AT_SECURE(args); __libc_init_AT_SECURE(args);
__libc_init_common(args); __libc_init_common(args);

View File

@ -114,7 +114,7 @@ __END_DECLS
#if defined(__cplusplus) #if defined(__cplusplus)
class KernelArgumentBlock; class KernelArgumentBlock;
extern __LIBC_HIDDEN__ void __libc_init_tls(KernelArgumentBlock& args); extern __LIBC_HIDDEN__ void __libc_init_main_thread(KernelArgumentBlock& args);
#endif #endif
#endif /* __BIONIC_PRIVATE_BIONIC_TLS_H_ */ #endif /* __BIONIC_PRIVATE_BIONIC_TLS_H_ */

View File

@ -3465,7 +3465,7 @@ extern "C" ElfW(Addr) __linker_init(void* raw_args) {
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }
__libc_init_tls(args); __libc_init_main_thread(args);
// Initialize the linker's own global variables // Initialize the linker's own global variables
linker_so.call_constructors(); linker_so.call_constructors();