Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2083)

Unified Diff: elf/rtld.c

Issue 7282019: Adjust for new NaCl startup ABI (Closed) Base URL: http://git.chromium.org/native_client/nacl-glibc.git@master
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « elf/Makefile ('k') | make_sysd_rules.py » ('j') | make_sysd_rules.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: elf/rtld.c
diff --git a/elf/rtld.c b/elf/rtld.c
index fba23121b8814755db09f24f7b74563a4f72a74d..bf0ac163510a60f2d0af0cae220ce537f72c7b21 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -550,16 +550,14 @@ _dl_start (void *arg)
function, that way the compiler cannot put accesses to the GOT
before ELF_DYNAMIC_RELOCATE. */
- struct process_args *ipc_args = argmsg_fetch ();
- if (ipc_args != NULL)
- {
- /* Because code following the ELF ABI expects to find the argv
- and env arrays on the stack, this is a little convoluted
- because we have to allocate stack space here. */
- size_t size = argmsg_get_size_on_stack (ipc_args);
- arg = alloca (size);
- argmsg_move_to_stack (ipc_args, arg, size);
- }
+ /* If we are getting arguments and environment from IPC rather from the
+ startup stack, this will replace ARG with a new mmap'd pointer.
+
+ Keeping _dl_starting_up set lets _dl_*printf calls work. */
+ int starting = INTUSE(_dl_starting_up);
+ INTUSE(_dl_starting_up) = 1;
+ arg = argmsg_fetch(arg);
+ INTUSE(_dl_starting_up) = starting;
{
#ifdef DONT_USE_BOOTSTRAP_MAP
@@ -575,25 +573,23 @@ _dl_start (void *arg)
struct link_map *main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
uintptr_t entry_point = ELF_MACHINE_START_ADDRESS (main_map, entry);
- if (ipc_args != NULL)
- {
- /* This copies the logic of _start in dl-machine.h, but in C
- rather than assembly. */
-
- /* Adjust for skipped arguments. */
- int argc = *(argc_type *) arg;
- argc -= _dl_skip_args;
- arg = (char **) arg + _dl_skip_args;
- *(argc_type *) arg = argc;
-
- char **argv = (char **) ((argc_type *) arg + 1);
- char **envp = argv + argc + 1;
- _dl_init (main_map, argc, argv, envp);
-
- jump_to_elf_start (arg, entry_point, (uintptr_t) _dl_fini);
- }
- else
- return entry_point;
+ /* This roughly copies the logic of _start in dl-machine.h, but in C
+ rather than assembly. We are adjusting the NaCl startup information
+ block rather than the traditional Unix/ELF stack setup. */
+ uint32_t *arginfo = arg;
+ int envc = arginfo[1];
+ int argc = arginfo[2] - _dl_skip_args;
+ arginfo += _dl_skip_args;
+ arginfo[0] = (uintptr_t) &_dl_fini;
+ arginfo[1] = envc;
+ arginfo[2] = argc;
+ char **argv = (void *) &arginfo[3];
+ char **envp = &argv[argc + 1];
+ _dl_init (main_map, argc, argv, envp);
+ (*(void (*)(uint32_t *)) entry_point) (arginfo);
+ /*NOTREACHED*/
+
+ return entry_point;
}
}
« no previous file with comments | « elf/Makefile ('k') | make_sysd_rules.py » ('j') | make_sysd_rules.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698