I suppose this is a gray area since printf is C, not Assembly, but I see this being affected by the reflags, so.
I noticed that when I call printf with DF set it causes a segmentation fault. It works fine when DF is clear. Example below:
extern printf
section .data
string db "Hello there!",10,0
section .text
global main
main:
push rbp
mov rbp, rsp
; uncommenting the line below will cause a segmentation fault when printf is called
; std
mov rdi, string
mov rax, 0
call printf
xor rax, rax
mov rsp, rbp
pop rbp
ret
I couldn't find this behavior documented anywhere. Any idea about what is going on here?
For some reason it worked fine when it runs with gdb:
Reading symbols from printfdf...
(gdb) run
Starting program: /home/al/dev/asm/tests/movsb/printfdf
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Hello there!
[Inferior 1 (process 31333) exited normally]