am bc0b8ff2: Merge "Use a less misleading name for the code that sets up the main thread."

* commit 'bc0b8ff2fbfb38f73114aef7df8e302025245441':
  Use a less misleading name for the code that sets up the main thread.
This commit is contained in:
Elliott Hughes 2015-07-23 02:06:17 +00:00 committed by Android Git Automerger
commit 2329b7218e
4 changed files with 15 additions and 15 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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_ */

View file

@ -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();