Add support for invoking ld.so via execve() and friends
Introduction: The original implementation of `relibc_ld_so_start` assumes that ld.so will always be invoked manually as in "/lib/ld64.so ./a.out" The problem is regarding this snippet. if sp.argc < 2 { eprintln!("ld.so [executable] [arguments...]"); unistd::_exit(1); loop {} } As such, In linux when user types "./a.out" he will recieve the message ld.so [executable] [arguments...] This patch makes use of AUXV, specifically AT_ENTRY. When invoking ld.so manually, AT_ENTRY happens to be the entry point of ld.so. But when running `./a.out` directly, AT_ENTRY becomes the entry point of `a.out` this patch compares AT_ENTRY to the entry point of ld.so, if they are equal only then it will assume that argv[1] is the real program and adjust the stack, otherwise it will proceed with the stack unadjusted.
Loading
Please register or sign in to comment