# ;; dmesg.s # the documentation on syslog(2) seems to be slightly different # than what I observe from on strace. strace shows # a call to syslog(0xa,0,0) to apparently retrieve the size of the # buffer (?) and then a call to syslog(3,buffer,bufflen) to actually # retrieve data #include .file "dmesg.s" .globl dmesg dmesg: mov $0xa,%rdi # find out how many bytes? I guess -- 0xa is definitely not documented! mov $0,%rsi mov $0,%rdx mov $__NR_syslog,%rax syscall mov %rax,%r15 # save the number of bytes off in %r15 mov $0,%rdi # find the bottom of the heap mov $__NR_brk,%rax # syscall mov %rax,%r14 # and save the bottom of heap in %r14 mov %rax,%r13 # %r13 will keep the top of the heap add %r15,%r13 # now, request more bytes to store dmesg data, so add to get top of heap in %r14 mov %r13,%rdi # now ask to extend heap to %r14 mov $__NR_brk,%rax syscall mov $3,%rdi # do the actual call to syslog(2) mov %r14,%rsi mov %r15,%rdx mov $__NR_syslog,%rax syscall mov %rax,%r12 # %r12 will have the number of bytes remaining # to write, and of course begins with what # syslog(2) returned... write_loop: mov $1,%rdi mov %r14,%rsi mov %r12,%rdx mov $__NR_write,%rax syscall add %rax,%r14 sub %rax,%r12 jnz write_loop mov $0,%rdi mov $__NR_exit,%rax syscall