Revision 0b959cf5
b/linux-user/main.c | ||
---|---|---|
3663 | 3663 |
return optind; |
3664 | 3664 |
} |
3665 | 3665 |
|
3666 |
static int get_execfd(char **envp) |
|
3667 |
{ |
|
3668 |
typedef struct { |
|
3669 |
long a_type; |
|
3670 |
long a_val; |
|
3671 |
} auxv_t; |
|
3672 |
auxv_t *auxv; |
|
3673 |
|
|
3674 |
while (*envp++ != NULL) { |
|
3675 |
; |
|
3676 |
} |
|
3677 |
|
|
3678 |
for (auxv = (auxv_t *)envp; auxv->a_type != AT_NULL; auxv++) { |
|
3679 |
if (auxv->a_type == AT_EXECFD) { |
|
3680 |
return auxv->a_val; |
|
3681 |
} |
|
3682 |
} |
|
3683 |
return -1; |
|
3684 |
} |
|
3685 |
|
|
3686 | 3666 |
int main(int argc, char **argv, char **envp) |
3687 | 3667 |
{ |
3688 | 3668 |
struct target_pt_regs regs1, *regs = ®s1; |
... | ... | |
3876 | 3856 |
env->opaque = ts; |
3877 | 3857 |
task_settid(ts); |
3878 | 3858 |
|
3879 |
execfd = get_execfd(envp);
|
|
3880 |
if (execfd < 0) {
|
|
3859 |
execfd = qemu_getauxval(AT_EXECFD);
|
|
3860 |
if (execfd == 0) {
|
|
3881 | 3861 |
execfd = open(filename, O_RDONLY); |
3882 |
}
|
|
3883 |
if (execfd < 0) {
|
|
3884 |
printf("Error while loading %s: %s\n", filename, strerror(-execfd));
|
|
3885 |
_exit(1);
|
|
3862 |
if (execfd < 0) {
|
|
3863 |
printf("Error while loading %s: %s\n", filename, strerror(errno));
|
|
3864 |
_exit(1);
|
|
3865 |
}
|
|
3886 | 3866 |
} |
3887 | 3867 |
|
3888 | 3868 |
ret = loader_exec(execfd, filename, target_argv, target_environ, regs, |
Also available in: Unified diff