What does this imply: enhance

This commit is contained in:
Théophile Bastian 2019-10-19 07:56:54 +02:00
parent 660852ce0d
commit 24f53aa0de
3 changed files with 54 additions and 14 deletions

View file

@ -283,16 +283,16 @@ Segmentation fault.
\end{frame} \end{frame}
\begin{frame}{What does this imply?} \begin{frame}{What does this imply?}
Your compiler actually generates codes for \alert{two machines}: your Your compiler actually generates codes for \alert{two machines}:\\
processor and the DWARF VM\@. your processor and the DWARF VM\@.
\vfill{} \vfill{}
\begin{columns} \begin{columns}
\begin{column}{0.5\textwidth} \begin{column}{0.45\textwidth}
\begin{center} \begin{center}
\begin{tikzpicture} \begin{tikzpicture}
\begin{scope}[every node/.style={rectangle,thick,draw,scale=0.95}] \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} \lstbash{\$ gcc -S foo.c}
}; };
\node (asm) at (0, 0) { \node (asm) at (0, 0) {
@ -304,25 +304,36 @@ Segmentation fault.
\path [->] (cmd) -- (asm); \path [->] (cmd) -- (asm);
\end{scope} \end{scope}
\end{tikzpicture} \end{tikzpicture}
\medskip{} %\vspace{0.2em}
\textbf{The \lstc{.cfi_*} is inline DWARF!} \textbf{\lstc{.cfi_*}: \alert{inline DWARF!}}
\end{center} \end{center}
\end{column} \end{column}
\begin{column}{0.5\textwidth} \begin{column}{0.55\textwidth}
\begin{center} \begin{itemize}
\bf \item[$\implies$] \alert{Cumbersome} to generate for the
$\implies$ if you write inline asm, you must write inline DWARF! \alert{compiler}
\end{center} \begin{itemize}
\item[$\leadsto$] might do it wrong
\item[$\leadsto$] might not do it at all
\end{itemize}
In \prog{glibc}, \prog{lowlevellock.h}: \item[$\implies$] If you write \alert{inline asm}, \alert{you} must write
\alert{off by one error in unwinding data}. inline DWARF\@!
\end{itemize}
\lstinputlisting[language=gdb,numbers=none]{src/lowlevellock_backtrace}
\end{column} \end{column}
\end{columns} \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->{ \only<2->{
\begin{textblock*}{0.90\textwidth}[0.5,0](0.5\paperwidth,0.10\paperheight)% \begin{textblock*}{0.90\textwidth}[0.5,0](0.5\paperwidth,0.10\paperheight)%

View file

@ -6,3 +6,5 @@ pushq %rbp
movq %rsp, %rbp movq %rsp, %rbp
.cfi_def_cfa_register 6 .cfi_def_cfa_register 6
subq $32, %rsp subq $32, %rsp
movl %edi, -20(%rbp)
movq %rsi, -32(%rbp)

27
src/main_cfi_full.s Normal file
View file

@ -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