summaryrefslogtreecommitdiff
path: root/linker/linker_main.cpp
diff options
context:
space:
mode:
authorRyan Prichard <rprichard@google.com>2018-11-22 02:41:36 -0800
committerRyan Prichard <rprichard@google.com>2018-11-28 14:26:14 -0800
commit48b1159bb82b12bdd75be9228bd43db45168bdba (patch)
tree876b546289ca58c6bb0a923c325aedeef7fd5cf8 /linker/linker_main.cpp
parent7752bcb234a9960d2e9e89766d143b7ac0c5f332 (diff)
Use shared globals to init __progname + environ
Initialize the __progname and environ global variables using libc_shared_globals rather than KernelArgumentBlock. Also: suppose the linker is invoked on an executable: linker prog [args...] The first argument passed to main() and constructor functions is "prog" rather than "linker". For consistency, this CL changes the BSD __progname global from "linker" to "prog". Bug: none Test: bionic unit tests Change-Id: I376d76953c9436706dbc53911ef6585c1acc1c31
Diffstat (limited to 'linker/linker_main.cpp')
-rw-r--r--linker/linker_main.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index 442ecd909..7edfd54ea 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -290,7 +290,7 @@ static ElfW(Addr) linker_main(KernelArgumentBlock& args, const char* exe_to_load
#endif
// Sanitize the environment.
- __libc_init_AT_SECURE(args);
+ __libc_init_AT_SECURE(args.envp);
// Initialize system properties
__system_properties_init(); // may use 'environ'
@@ -655,6 +655,7 @@ __linker_init_post_relocation(KernelArgumentBlock& args, soinfo& tmp_linker_so)
g_argc = args.argc - __libc_shared_globals()->initial_linker_arg_count;
g_argv = args.argv + __libc_shared_globals()->initial_linker_arg_count;
g_envp = args.envp;
+ __libc_shared_globals()->init_progname = g_argv[0];
// Initialize static variables. Note that in order to
// get correct libdl_info we need to call constructors