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
diff --git a/tests/dl_test.cpp b/tests/dl_test.cpp
index 18ba011..57d04e9 100644
--- a/tests/dl_test.cpp
+++ b/tests/dl_test.cpp
@@ -104,6 +104,7 @@
std::string expected_output =
"ctor: argc=1 argv[0]=" + helper + "\n" +
"main: argc=1 argv[0]=" + helper + "\n" +
+ "__progname=" + helper + "\n" +
"helper_func called\n";
ExecTestHelper eth;
eth.SetArgs({ kPathToLinker, helper.c_str(), nullptr });
@@ -118,6 +119,7 @@
std::string expected_output =
"ctor: argc=1 argv[0]=" + helper + "\n" +
"main: argc=1 argv[0]=" + helper + "\n" +
+ "__progname=" + helper + "\n" +
"helper_func called\n";
ExecTestHelper eth;
eth.SetArgs({ kPathToLinker, helper.c_str(), nullptr });