Commit 53efec77 authored by bbguimaraes's avatar bbguimaraes
Browse files

blog: strace prelude in C

parent a44fc412
......@@ -26,6 +26,7 @@
<li>
2022
<ul>
<li><a href="strace-prelude-in-c.html">strace prelude in C</a></li>
<li><a href="c++-virtual-tables.html">C++ virtual tables</a></li>
</ul>
</li>
......
......@@ -26,10 +26,25 @@
<atom:link href="https://bbguimaraes.com/blog/rss.xml" rel="self" type="application/rss+xml" />
<description>assert("this should not be happening");</description>
<language>en-us</language>
<pubDate>Mon, 22 Feb 2022 20:09:10 GMT</pubDate>
<lastBuildDate>Mon, 22 Feb 2022 20:09:10 GMT</lastBuildDate>
<pubDate>Sun, 17 Apr 2022 10:34:57 GMT</pubDate>
<lastBuildDate>Sun, 17 Apr 2022 10:34:57 GMT</lastBuildDate>
<docs>http://www.rssboard.org/rss-specification</docs>
<generator>vim</generator>
<item>
<title>strace prelude in C</title>
<link>https://bbguimaraes.com/blog/strace-prelude-in-c.html</link>
<guid>https://bbguimaraes.com/blog/strace-prelude-in-c.html</guid>
<pubDate>Sun, 17 Apr 2022 10:34:57 GMT</pubDate>
<category>assembly</category>
<category>c</category>
<category>debugging</category>
<category>linux</category>
<category>man</category>
<category>programming</category>
<category>strace</category>
<category>unix</category>
<description>Much has been written about the venerable <a href="https://strace.io/"><code>strace</code></a>, one of the most important allies of the systems programmer. However, the focus is often on the specifics of the particular program being examined, not on the functioning of <code>strace</code> itself and the operating system environment involved in the execution of the process. Today we explore this neglected part of the system call trace.</description>
</item>
<item>
<title>C++ virtual tables</title>
<link>https://bbguimaraes.com/blog/c++-virtual-tables.html</link>
......
This diff is collapsed.
execve("./a.out", ["./a.out"], 0x7ffdbf7c30d0 /* 0 vars */) = 0
brk(NULL) = 0x55ccf3f95000
arch_prctl(0x3001 /* ARCH_??? */, 0x7ffc92198690) = -1 EINVAL (Invalid argument)
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=156427, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 156427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f576c5e2000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\324\2\0\0\0\0\0"..., 832) = 832
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
pread64(3, "\4\0\0\0@\0\0\0\5\0\0\0GNU\0\2\0\0\300\4\0\0\0\3\0\0\0\0\0\0\0"..., 80, 848) = 80
pread64(3, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0\205vn\235\204X\261n\234|\346\340|q,\2"..., 68, 928) = 68
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=2463384, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f576c5e0000
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
mmap(NULL, 2136752, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f576c3d6000
mprotect(0x7f576c402000, 1880064, PROT_NONE) = 0
mmap(0x7f576c402000, 1531904, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2c000) = 0x7f576c402000
mmap(0x7f576c578000, 344064, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1a2000) = 0x7f576c578000
mmap(0x7f576c5cd000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1f6000) = 0x7f576c5cd000
mmap(0x7f576c5d3000, 51888, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f576c5d3000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f576c3d4000
arch_prctl(ARCH_SET_FS, 0x7f576c5e1600) = 0
set_tid_address(0x7f576c5e18d0) = 2974699
set_robust_list(0x7f576c5e18e0, 24) = 0
rseq(0x7f576c5e1fa0, 0x20, 0, 0x53053053) = 0
mprotect(0x7f576c5cd000, 12288, PROT_READ) = 0
mprotect(0x55ccf2f54000, 4096, PROT_READ) = 0
mprotect(0x7f576c63e000, 8192, PROT_READ) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
munmap(0x7f576c5e2000, 156427) = 0
exit_group(0) = ?
+++ exited with 0 +++
execve("./a.out", ["./a.out"], 0x7ffc71f9cfc0 /* 0 vars */) = 0
arch_prctl(ARCH_SET_FS, 0x404158) = 0
set_tid_address(0x404290) = 2961014
exit_group(0) = ?
+++ exited with 0 +++
#include <stdnoreturn.h>
noreturn void _start() {
__asm__("mov $0x3c,%al\nsyscall");
__builtin_unreachable();
}
execve("./a.out", ["./a.out"], 0x7ffd8a6c9e20 /* 0 vars */) = 0
exit(0) = ?
+++ exited with 0 +++
.equ vaddr, 0x400000
ehdr:
# e_ident
.byte 0x7f, 'E', 'L', 'F' # EI_MAG
.byte 2 # EI_CLASS = ELFCLASS64
.byte 1 # EI_DATA = ELFDATA2LSB
.byte 1 # EI_VERSION = EV_CURRENT
.byte 0 # EI_OSABI = ELFOSABI_NONE
.quad 0 # EI_PAD
.word 2 # e_type = ET_EXEC
.word 0x3e # e_machine = EM_X86_64
.long 1 # e_version = EV_CURRENT
.quad vaddr + _start - ehdr # e_entry
.quad ehdrsize # e_phoff
.quad 0 # e_shoff
.long 0 # e_flags
.word ehdrsize # e_ehsize
.word phdrsize # e_phentsize
.word 1 # e_phnum
.word 0 # e_shentsiz
.word 0 # e_shnum
.word 0 # e_shstrndx
.equ ehdrsize, . - ehdr
phdr:
.long 1 # p_type = PT_LOAD
.long 5 # p_flags = PF_R | PF_X
.quad 0 # p_offset
.quad vaddr # p_vaddr
.quad vaddr # p_paddr
.quad 0x7d # p_filesz
.quad 0x7d # p_memsz
.quad 0x200000 # p_align
.equ phdrsize, . - phdr
.globl _start
_start:
mov $0x3c,%al
# cltd
syscall
execve("./min", ["./min"], 0x7ffec174db90 /* 0 vars */) = 0
exit(0) = ?
+++ exited with 0 +++
......@@ -25,6 +25,7 @@
</nav>
<h1>tag - assembly</h1>
<ul>
<li><a href="../strace-prelude-in-c.html">strace prelude in C</a></li>
<li><a href="../sigfpe.html">SIGFPE</a></li>
<li><a href="../99-bottles-of-beer.html">99 Bottles of Beer</a></li>
</ul>
......
......@@ -25,6 +25,7 @@
</nav>
<h1>tag - c</h1>
<ul>
<li><a href="../strace-prelude-in-c.html">strace prelude in C</a></li>
<li><a href="../nngn-lua-wasm.html">nngn - lua &amp; wasm</a></li>
<li><a href="../sigfpe.html">SIGFPE</a></li>
<li><a href="../2014-books.html">2014 books</a></li>
......
......@@ -25,6 +25,7 @@
</nav>
<h1>tag - debugging</h1>
<ul>
<li><a href="../strace-prelude-in-c.html">strace prelude in C</a></li>
<li><a href="../sigfpe.html">SIGFPE</a></li>
<li><a href="../pip-extra-index.html"> pip --extra-index</a></li>
</ul>
......
......@@ -25,6 +25,7 @@
</nav>
<h1>tag - linux</h1>
<ul>
<li><a href="../strace-prelude-in-c.html">strace prelude in C</a></li>
<li><a href="../sigfpe.html">SIGFPE</a></li>
<li><a href="../college-research-projects.html">College research projects</a></li>
<li><a href="../2014-books.html">2014 books</a></li>
......
......@@ -25,6 +25,7 @@
</nav>
<h1>tag - man</h1>
<ul>
<li><a href="../strace-prelude-in-c.html">strace prelude in C</a></li>
<li><a href="../calculating-pi-the-unix-way.html">Calculating π the unix way</a></li>
<li><a href="../pip-extra-index.html"> pip --extra-index</a></li>
<li><a href="../uploading-files-the-unix-way.html">Uploading files the unix way</a></li>
......
......@@ -25,6 +25,7 @@
</nav>
<h1>tag - programming</h1>
<ul>
<li><a href="../strace-prelude-in-c.html">strace prelude in C</a></li>
<li><a href="../nngn-lua-wasm.html">nngn - lua &amp; wasm</a></li>
<li><a href="../nngn-lua.html">nngn - lua</a></li>
<li><a href="../nngn.html">nngn</a></li>
......
......@@ -25,6 +25,7 @@
</nav>
<h1>tag - strace</h1>
<ul>
<li><a href="../strace-prelude-in-c.html">strace prelude in C</a></li>
<li><a href="../pip-extra-index.html"> pip --extra-index</a></li>
</ul>
</div>
......
......@@ -25,6 +25,7 @@
</nav>
<h1>tag - unix</h1>
<ul>
<li><a href="../strace-prelude-in-c.html">strace prelude in C</a></li>
<li><a href="../nngn-lua.html">nngn - lua</a></li>
<li><a href="../sigfpe.html">SIGFPE</a></li>
<li><a href="../2014-books.html">2014 books</a></li>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment