|
Lines 544-550
Link Here
|
| 544 |
exit(exitcode); |
544 |
exit(exitcode); |
| 545 |
} |
545 |
} |
| 546 |
|
546 |
|
| 547 |
static int parse_args(int argc, char **argv) |
547 |
static int parse_args(int argc, char **argv, int assume_P_flag) |
| 548 |
{ |
548 |
{ |
| 549 |
const char *r; |
549 |
const char *r; |
| 550 |
int optind; |
550 |
int optind; |
|
Lines 560-566
Link Here
|
| 560 |
arginfo->handle_opt(r); |
560 |
arginfo->handle_opt(r); |
| 561 |
} |
561 |
} |
| 562 |
} |
562 |
} |
| 563 |
|
563 |
if (assume_P_flag) { |
|
|
564 |
/* Assume started by binmisc and binfmt P flag is set */ |
| 565 |
if (argc < 3) { |
| 566 |
fprintf(stderr, "%s: Please use me through binfmt with P flag\n", |
| 567 |
argv[0]); |
| 568 |
exit(1); |
| 569 |
} |
| 570 |
/* filename = argv[1]; for QEMU < 4.2 */ |
| 571 |
exec_path = argv[1]; |
| 572 |
/* Next argv must be argv0 for the app */ |
| 573 |
return 2; |
| 574 |
} |
| 564 |
optind = 1; |
575 |
optind = 1; |
| 565 |
for (;;) { |
576 |
for (;;) { |
| 566 |
if (optind >= argc) { |
577 |
if (optind >= argc) { |
|
Lines 659-665
Link Here
|
| 659 |
qemu_add_opts(&qemu_trace_opts); |
670 |
qemu_add_opts(&qemu_trace_opts); |
| 660 |
qemu_plugin_add_opts(); |
671 |
qemu_plugin_add_opts(); |
| 661 |
|
672 |
|
| 662 |
optind = parse_args(argc, argv); |
673 |
execfd = qemu_getauxval(AT_EXECFD); |
|
|
674 |
optind = parse_args(argc, argv, execfd > 0); |
| 663 |
|
675 |
|
| 664 |
if (!trace_init_backends()) { |
676 |
if (!trace_init_backends()) { |
| 665 |
exit(1); |
677 |
exit(1); |
|
Lines 682-688
Link Here
|
| 682 |
|
694 |
|
| 683 |
init_qemu_uname_release(); |
695 |
init_qemu_uname_release(); |
| 684 |
|
696 |
|
| 685 |
execfd = qemu_getauxval(AT_EXECFD); |
|
|
| 686 |
if (execfd == 0) { |
697 |
if (execfd == 0) { |
| 687 |
execfd = open(exec_path, O_RDONLY); |
698 |
execfd = open(exec_path, O_RDONLY); |
| 688 |
if (execfd < 0) { |
699 |
if (execfd < 0) { |