From 24f53aa0de31d490ae56ba3d0be481aa43eded73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Sat, 19 Oct 2019 07:56:54 +0200 Subject: [PATCH] What does this imply: enhance --- slides.tex | 39 +++++++++++++++++++++++++-------------- src/main_cfi.s | 2 ++ src/main_cfi_full.s | 27 +++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 src/main_cfi_full.s diff --git a/slides.tex b/slides.tex index cb8bb2e..5803df6 100644 --- a/slides.tex +++ b/slides.tex @@ -283,16 +283,16 @@ Segmentation fault. \end{frame} \begin{frame}{What does this imply?} - Your compiler actually generates codes for \alert{two machines}: your - processor and the DWARF VM\@. + Your compiler actually generates codes for \alert{two machines}:\\ + your processor and the DWARF VM\@. \vfill{} \begin{columns} - \begin{column}{0.5\textwidth} + \begin{column}{0.45\textwidth} \begin{center} \begin{tikzpicture} \begin{scope}[every node/.style={rectangle,thick,draw,scale=0.95}] - \node (cmd) at (0, 2.5) { + \node (cmd) at (0, 3.0) { \lstbash{\$ gcc -S foo.c} }; \node (asm) at (0, 0) { @@ -304,25 +304,36 @@ Segmentation fault. \path [->] (cmd) -- (asm); \end{scope} \end{tikzpicture} - \medskip{} + %\vspace{0.2em} - \textbf{The \lstc{.cfi_*} is inline DWARF!} + \textbf{\lstc{.cfi_*}: \alert{inline DWARF!}} \end{center} \end{column} - \begin{column}{0.5\textwidth} - \begin{center} - \bf - $\implies$ if you write inline asm, you must write inline DWARF! - \end{center} + \begin{column}{0.55\textwidth} + \begin{itemize} + \item[$\implies$] \alert{Cumbersome} to generate for the + \alert{compiler} + \begin{itemize} + \item[$\leadsto$] might do it wrong + \item[$\leadsto$] might not do it at all + \end{itemize} - In \prog{glibc}, \prog{lowlevellock.h}: - \alert{off by one error in unwinding data}. + \item[$\implies$] If you write \alert{inline asm}, \alert{you} must write + inline DWARF\@! + \end{itemize} - \lstinputlisting[language=gdb,numbers=none]{src/lowlevellock_backtrace} \end{column} \end{columns} +\end{frame} +\begin{frame} + \todo{Actually add lowlevellock code} + + In \prog{glibc}, \prog{lowlevellock.h}: + \alert{off by one error in unwinding data}. + + \lstinputlisting[language=gdb,numbers=none]{src/lowlevellock_backtrace} \only<2->{ \begin{textblock*}{0.90\textwidth}[0.5,0](0.5\paperwidth,0.10\paperheight)% diff --git a/src/main_cfi.s b/src/main_cfi.s index 53838b7..dafd463 100644 --- a/src/main_cfi.s +++ b/src/main_cfi.s @@ -6,3 +6,5 @@ pushq %rbp movq %rsp, %rbp .cfi_def_cfa_register 6 subq $32, %rsp +movl %edi, -20(%rbp) +movq %rsi, -32(%rbp) diff --git a/src/main_cfi_full.s b/src/main_cfi_full.s new file mode 100644 index 0000000..352d89f --- /dev/null +++ b/src/main_cfi_full.s @@ -0,0 +1,27 @@ +main: +.LFB6: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + subq $32, %rsp + movl %edi, -20(%rbp) + movq %rsi, -32(%rbp) + movq -32(%rbp), %rax + addq $8, %rax + movq (%rax), %rax + movq %rax, %rdi + call atoi@PLT + movl %eax, -4(%rbp) + movl -4(%rbp), %eax + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE6: + .size main, .-main + .ident "GCC: (GNU) 9.2.0" + .section .note.GNU-stack,"",@progbits +