Re: Simulator question about argc/argv
Mike Frysinger <[email protected]>
| Newsgroups | gmane.comp.gdb.devel |
|---|---|
| Message-ID | <[email protected]> |
On Friday 31 May 2013 12:47:54 Steve Ellcey wrote:
> Some new tests have been added to the GCC testsuite (cilk tests) that
> check the value of argc and they expect it to be 1 if there are no
> arguments to the test program (and there are none) but I am getting 0
> when I run the tests under the gnu simulator. Does anyone know why
> this is? I don't know if this is specific to my target (mips-mti-elf)
> or a general simulator problem. Perhaps it is related to my linker
> script? The mips-mti-elf target is built with newlib. Could someone
> else who uses the gnu simulator and newlib try this. It works fine for
> me under the qemu simulator.
unfortunately, the argc/argv handling tends to be target specific and spread
across newlib, libgloss, and the sim (target specific pieces). you might even
see different behavior if the env is gdb rather than the run frontend :).
i'd have to dig into the specific mips lower startup code to see how it
transfers things, but this does work for Blackfin targets:
$ cat test.c
#include <stdio.h>
int main(int argc, char **argv)
{
printf("%d\n", argc);
return 0;
}
$ bfin-elf-gcc -msim test.c
$ bfin-elf-run ./a.out
1
$ bfin-elf-gdb -q -ex 'target sim' -ex load -ex run ./a.out
Connected to the simulator.
Loading section .init, size 0x12 lma 0x0
Loading section .text, size 0x89f8 lma 0x14
Loading section .fini, size 0xe lma 0x8a0c
Loading section .rodata, size 0x618 lma 0x8a1c
Loading section .eh_frame, size 0x4 lma 0x9034
Loading section .ctors, size 0x8 lma 0xa038
Loading section .dtors, size 0x8 lma 0xa040
Loading section .jcr, size 0x4 lma 0xa048
Loading section .data, size 0x8bc lma 0xa04c
Start address 0x14
Transfer rate: 313376 bits in <1 sec.
Starting program: /usr/local/src/gnu/gdb/sim/bfin/a.out
1
Program exited normally.
-mike
signature.asc
(application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQIcBAABAgAGBQJRqPGRAAoJEEFjO5/oN/WBzRkP/jHTIlD9BvHyACmWXIuEurDj eJYNmjK9nkaLNaz1lXDh2UFITxJyYv8O0UxVbplDKt/kHsj9IQFmuqxwCZRSEgtr ad8910ExByWKZQsznzy0fMPhV9vAGgV1NaZITat1pCIjHegILp1EOQKYT8YIffnM Uf9gATgASqcelYt2X3BO/7CHP5Z6P8QQ9l4+m73A2kWFxO/R+xcQL1nru1My3bj+ AijKI/e2fmHbiCXgy5q67ZDrO0cWRlRUz4QB5swVwokL+Q9ElPlAQmf81banc+N1 bqt+OWP/XAAcOhfN43JlcqOhsc/bdqzoH0mEAKJJdiN+Qd9bRiZ6R/4/j4WK7iP/ SIUO1xpE3kq9cuM57oVm91QNYPjGZ/nFHQi5XrfP3WilXV7Jz1+BQksMHb+dzNnn f54HEnfmW9UNYCXVKGOSOpxv8O1Hml4vyENbRZvvrNXvD3kk1l8UPnZgZUuZWHiN hV3oujlhR6cdnIR/s8oEITzJaoUG7TSUWip3HDVq6G2aXxSsUlj8sgJXlqPTB7uk YrwhAnktmLt/5POwhckO5u1i75FgSZzL3hrgDmLSnKJLCySCE9vHuGgjdppdnqTQ YwE+PhuDF3KQWuRYx38f795+gnq+QJob35JtIW0Mxz0/C+JM+nxE6XA2R6kmni8M ZHSzscLFwXoS1QJsiJWK =FhoC -----END PGP SIGNATURE-----