I wonder why the assembly version is not showing any output when piped into hexdump
?
Source code (printf.c):
#include <stdio.h>
// gcc -o printf printf.c && ./printf
int main() {
const char *frmt = "%s\n";
char *msg = "TEST";
printf(frmt, msg);
return 0;
}
Output to STDOUT:
$ ./printf
TEST
Pipe to hexdump
:
$ ./printf | hexdump -v -C
00000000 54 45 53 54 0a |TEST.|
00000005
Strace:
$ strace -ttT -f -e trace="write" ./printf
17:44:33.841789 write(1, "TEST\n", 5TEST
) = 5 <0.000050>
17:44:33.842320 +++ exited with 0 +++
Source code (printf.nasm):
; nasm -g -f elf64 printf.nasm && ld printf.o -o printf && ./printf
extern printf
global main
section .text
main:
mov rdi, frmt
mov rsi, msg
xor rax, rax
call printf
jmp exit
exit:
mov rax, 60
xor rdi, rdi
syscall
section .data
frmt db "%s", 0xa, 0x0
msg: db "TEST"
len: equ $ - msg
Output to STDOUT:
$ ./printf
TEST
Pipe to hexdump
(no output):
$ ./printf | hexdump -v -C
Strace:
$ strace -ttT -f -e trace="write" ./printf
17:46:00.828887 write(1, "TEST\n", 5TEST
) = 5 <0.000050>
17:46:00.829282 +++ exited with 0 +++