Running via qi skips the seek
Environment
Mon Oct 14 08:53:53 PM CEST 2024
radare2 5.9.4 0 @ linux-x86-64
birth: git.5.9.4 2024-08-12__00:00:00
options: gpl release -O1 cs:5 cl:2 meson
Linux x86_64
Description
Running the same commands as a script somehow omits the seek command.
Test
I've created a script file with following contents:
aaaa;
s main;
drr;
Running it via r2 -qi script /bin/ls .
Here's the output of the run:
WARN: Relocs has not been applied. Please use `-e bin.relocs.apply=true` or `-e bin.cache=true` next time
INFO: Analyze all flags starting with sym. and entry0 (aa)
INFO: Analyze imports (af@@@i)
INFO: Analyze entrypoint (af@ entry0)
INFO: Analyze symbols (af@@@s)
INFO: Analyze all functions arguments/locals (afva@@@F)
INFO: Analyze function calls (aac)
INFO: Analyze len bytes of instructions for references (aar)
INFO: Finding and parsing C++ vtables (avrr)
INFO: Analyzing methods (af @@ method.*)
INFO: Recovering local variables (afva@@@F)
INFO: Type matching analysis for all functions (aaft)
INFO: Propagate noreturn information (aanr)
INFO: Scanning for strings constructed in code (/azs)
INFO: Finding function preludes (aap)
INFO: Enable anal.types.constraint for experimental type propagation
role reg value refstr
――――――――――――――――――――――――
SN rax 0x0 0 R 0x10102464c457f
rbx 0x0 0 R 0x10102464c457f
A3 rcx 0x0 0 R 0x10102464c457f
A2 rdx 0x0 0 R 0x10102464c457f
A1 rsi 0x0 0 R 0x10102464c457f
A0 rdi 0x0 0 R 0x10102464c457f
A4 r8 0x0 0 R 0x10102464c457f
A5 r9 0x0 0 R 0x10102464c457f
A6 r10 0x0 0 R 0x10102464c457f
A7 r11 0x0 0 R 0x10102464c457f
r12 0x0 0 R 0x10102464c457f
r13 0x0 0 R 0x10102464c457f
r14 0x0 0 R 0x10102464c457f
r15 0x0 0 R 0x10102464c457f
PC rip 0x0 0 R 0x10102464c457f
BP rbp 0x0 0 R 0x10102464c457f
rflags 0x0 0 R 0x10102464c457f
riz 0x0 0 R 0x10102464c457f
SP rsp 0x0 0 R 0x10102464c457f
Comare the drr output when I have typed all the commands in interactive mode one by one:
SN rax 0x0 0 R 0x10102464c457f
rbx 0x0 0 R 0x10102464c457f
A3 rcx 0x0 0 R 0x10102464c457f
A2 rdx 0x0 0 R 0x10102464c457f
A1 rsi 0x0 0 R 0x10102464c457f
A0 rdi 0x0 0 R 0x10102464c457f
A4 r8 0x0 0 R 0x10102464c457f
A5 r9 0x0 0 R 0x10102464c457f
A6 r10 0x0 0 R 0x10102464c457f
A7 r11 0x0 0 R 0x10102464c457f
r12 0x0 0 R 0x10102464c457f
r13 0x0 0 R 0x10102464c457f
r14 0x0 0 R 0x10102464c457f
r15 0x0 0 R 0x10102464c457f
PC rip 0x5ef0 24304 .text entry0,_start,rip entry0 R X 'endbr64'
BP rbp 0x0 0 R 0x10102464c457f
rflags 0x0 0 R 0x10102464c457f
riz 0x0 0 R 0x10102464c457f
SP rsp 0x0 0 R 0x10102464c457f
Seek doesnt' change the program counter. what is happening here is that when you run commands in the shell r2 runs internally the .dr* command which loads the flags associated with the register values.
If you want to change the program counter use the dr PC=main command instead. you can later do sr PC to seek there
But apart from that what is what you are trying to achieve here? Also, can you try with latest release?
But apart from that what is what you are trying to achieve here? Also, can you try with latest release?
I am trying to create repeatable environment so that I don't have to re-type same commands over and over. Is this fundamentally not compatible with the mode of operation in r2?