Seems like radare has problems with passing arguments starting with dash ("-"). Please consider open an issue.
Anyway, you can pass arguments to radare2 debugged program in several ways.
The simplest way is:
r2 -d program arg1 arg2 arg3
- r2 is an alias for radare2.
- -d is telling radare2 to debug the execuable.
- arg1..3 are the arguments passed to the executable by radare2.
$ r2 -d echo Hello, World!
Process with PID 4755 started...
= attach 4755 4755
-- You haxor! Me jane?
Another way is using the
ood command inside radare2 shell:
radare2 ./program, then type
ood arg1 arg2 arg3. The
ood command is used to "reopen in debugger mode (with args)".
$ r2 /bin/ls
-- Use V! to enter into the visual panels mode (dwm style)
[0x004049a0]> doo -la
Process with PID 4757 started...
File dbg:///bin/ls -la reopened in read-write mode
= attach 4757 4757
drwxrwxrwx 0 root root 512 Feb 13 04:25 .
drwxrwxrwx 0 root root 512 Jan 16 05:30 ..
You can also call
ood with dynamic parameters using backticks. For example we want debug our program using the content from a file on our system as an arguments:
ood `!cat file.txt`
Say file.txt content is 'foo bar' so this equivalent to executing
ood foo bar
- backticks are used for passing the output of radare2 commands.
- ! is running the given command as in system(3).
Another way to pass arguments to radare2 debugged program is by using
rarun2 profile files:
$ r2 -R profile.rr2 -d program
$ cat profile.rr2
- -R [rarun2] specify rarun2 profile to load.