Clean up the argc/argv/envp/auxv handling.

There's now only one place where we deal with this stuff, it only needs to
be parsed once by the dynamic linker (rather than by each recipient), and it's
now easier for us to get hold of auxv data early on.

Change-Id: I6314224257c736547aac2e2a650e66f2ea53bef5
This commit is contained in:
Elliott Hughes
2013-02-07 10:14:39 -08:00
parent d32fdbaf03
commit 42b2c6a5ee
16 changed files with 383 additions and 417 deletions

View File

@@ -26,24 +26,23 @@
* SUCH DAMAGE.
*/
#include <stdint.h>
#include <sys/cdefs.h>
extern unsigned __linker_init(unsigned int *elfdata);
extern unsigned __linker_init(void* raw_args);
__attribute__((visibility("hidden")))
void _start() {
__LIBC_HIDDEN__ void _start() {
void (*start)(void);
void* elfdata = (void*) ((uintptr_t) __builtin_frame_address(0) + sizeof(void*));
start = (void(*)(void))__linker_init(elfdata);
void* raw_args = (void*) ((uintptr_t) __builtin_frame_address(0) + sizeof(void*));
start = (void(*)(void))__linker_init(raw_args);
/* linker init returns (%eax) the _entry address in the main image */
/* entry point expects sp to point to elfdata */
/* entry point expects sp to point to raw_args */
__asm__ (
"mov %0, %%esp\n\t"
"jmp *%1\n\t"
: : "r"(elfdata), "r"(start) :
: : "r"(raw_args), "r"(start) :
);
/* Unreachable */