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

Side by Side 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, 5 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 unified diff | Download patch
OLDNEW
1 /* Run time dynamic linker. 1 /* Run time dynamic linker.
2 Copyright (C) 1995-2006, 2007, 2008 Free Software Foundation, Inc. 2 Copyright (C) 1995-2006, 2007, 2008 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 The GNU C Library is free software; you can redistribute it and/or 5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version. 8 version 2.1 of the License, or (at your option) any later version.
9 9
10 The GNU C Library is distributed in the hope that it will be useful, 10 The GNU C Library is distributed in the hope that it will be useful,
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 therefore need not test whether we have to allocate the array 543 therefore need not test whether we have to allocate the array
544 for the relocation results (as done in dl-reloc.c). */ 544 for the relocation results (as done in dl-reloc.c). */
545 545
546 /* Now life is sane; we can call functions and access global data. 546 /* Now life is sane; we can call functions and access global data.
547 Set up to use the operating system facilities, and find out from 547 Set up to use the operating system facilities, and find out from
548 the operating system's program loader where to find the program 548 the operating system's program loader where to find the program
549 header table in core. Put the rest of _dl_start into a separate 549 header table in core. Put the rest of _dl_start into a separate
550 function, that way the compiler cannot put accesses to the GOT 550 function, that way the compiler cannot put accesses to the GOT
551 before ELF_DYNAMIC_RELOCATE. */ 551 before ELF_DYNAMIC_RELOCATE. */
552 552
553 struct process_args *ipc_args = argmsg_fetch (); 553 /* If we are getting arguments and environment from IPC rather from the
554 if (ipc_args != NULL) 554 startup stack, this will replace ARG with a new mmap'd pointer.
555 { 555
556 /* Because code following the ELF ABI expects to find the argv 556 Keeping _dl_starting_up set lets _dl_*printf calls work. */
557 and env arrays on the stack, this is a little convoluted 557 int starting = INTUSE(_dl_starting_up);
558 because we have to allocate stack space here. */ 558 INTUSE(_dl_starting_up) = 1;
559 size_t size = argmsg_get_size_on_stack (ipc_args); 559 arg = argmsg_fetch(arg);
560 arg = alloca (size); 560 INTUSE(_dl_starting_up) = starting;
561 argmsg_move_to_stack (ipc_args, arg, size);
562 }
563 561
564 { 562 {
565 #ifdef DONT_USE_BOOTSTRAP_MAP 563 #ifdef DONT_USE_BOOTSTRAP_MAP
566 ElfW(Addr) entry = _dl_start_final (arg); 564 ElfW(Addr) entry = _dl_start_final (arg);
567 #else 565 #else
568 ElfW(Addr) entry = _dl_start_final (arg, &info); 566 ElfW(Addr) entry = _dl_start_final (arg, &info);
569 #endif 567 #endif
570 568
571 #ifndef ELF_MACHINE_START_ADDRESS 569 #ifndef ELF_MACHINE_START_ADDRESS
572 # define ELF_MACHINE_START_ADDRESS(map, start) (start) 570 # define ELF_MACHINE_START_ADDRESS(map, start) (start)
573 #endif 571 #endif
574 572
575 struct link_map *main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded; 573 struct link_map *main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
576 uintptr_t entry_point = ELF_MACHINE_START_ADDRESS (main_map, entry); 574 uintptr_t entry_point = ELF_MACHINE_START_ADDRESS (main_map, entry);
577 575
578 if (ipc_args != NULL) 576 /* This roughly copies the logic of _start in dl-machine.h, but in C
579 { 577 rather than assembly. We are adjusting the NaCl startup information
580 /* This copies the logic of _start in dl-machine.h, but in C 578 block rather than the traditional Unix/ELF stack setup. */
581 rather than assembly. */ 579 uint32_t *arginfo = arg;
580 int envc = arginfo[1];
581 int argc = arginfo[2] - _dl_skip_args;
582 arginfo += _dl_skip_args;
583 arginfo[0] = (uintptr_t) &_dl_fini;
584 arginfo[1] = envc;
585 arginfo[2] = argc;
586 char **argv = (void *) &arginfo[3];
587 char **envp = &argv[argc + 1];
588 _dl_init (main_map, argc, argv, envp);
589 (*(void (*)(uint32_t *)) entry_point) (arginfo);
590 /*NOTREACHED*/
582 591
583 /* Adjust for skipped arguments. */ 592 return entry_point;
584 int argc = *(argc_type *) arg;
585 argc -= _dl_skip_args;
586 arg = (char **) arg + _dl_skip_args;
587 *(argc_type *) arg = argc;
588
589 char **argv = (char **) ((argc_type *) arg + 1);
590 char **envp = argv + argc + 1;
591 _dl_init (main_map, argc, argv, envp);
592
593 jump_to_elf_start (arg, entry_point, (uintptr_t) _dl_fini);
594 }
595 else
596 return entry_point;
597 } 593 }
598 } 594 }
599 595
600 596
601 597
602 /* Now life is peachy; we can do all normal operations. 598 /* Now life is peachy; we can do all normal operations.
603 On to the real work. */ 599 On to the real work. */
604 600
605 /* Some helper functions. */ 601 /* Some helper functions. */
606 602
(...skipping 2258 matching lines...) Expand 10 before | Expand all | Expand 10 after
2865 *wp++ = '.'; 2861 *wp++ = '.';
2866 *wp++ = *cp++; 2862 *wp++ = *cp++;
2867 } 2863 }
2868 *wp = '\0'; 2864 *wp = '\0';
2869 _dl_debug_printf ("\ 2865 _dl_debug_printf ("\
2870 time needed to load objects: %s (%s%%)\n", 2866 time needed to load objects: %s (%s%%)\n",
2871 buf, pbuf); 2867 buf, pbuf);
2872 } 2868 }
2873 #endif 2869 #endif
2874 } 2870 }
OLDNEW
« 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