finish up

This commit is contained in:
Kagura 2024-07-01 22:20:24 +08:00
parent d3b8ec2e9a
commit 5fa719042e
4 changed files with 31 additions and 46 deletions

View file

@ -1,23 +0,0 @@
\relax
\providecommand\hyper@newdestlabel[2]{}
\providecommand*\HyPL@Entry[1]{}
\HyPL@Entry{0<</S/D>>}
\@writefile{toc}{\contentsline {section}{\numberline {1}数据表示与存储}{1}{section.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {1.1}数据的类型及大小}{1}{subsection.1.1}\protected@file@percent }
\@writefile{lot}{\contentsline {table}{\numberline {1}{\ignorespaces 数据的类型及大小}}{1}{table.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {1.2}计算值域}{1}{subsection.1.2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {1.3}补码}{1}{subsection.1.3}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {1.4}GDB查看数据}{1}{subsection.1.4}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {1.5}浮点数}{2}{subsection.1.5}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.5.1}规格化数 $ \text {exp} \ne 0$$\text {exp} \ne 11 \dots 1$}{2}{subsubsection.1.5.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.5.2}非规格化数 $\text {exp} = 0$}{2}{subsubsection.1.5.2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.5.3}特殊值 $\text {exp} = 11 \dots 1$}{2}{subsubsection.1.5.3}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.5.4}舍入(到偶数)}{2}{subsubsection.1.5.4}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {2}程序的机器级表示}{3}{section.2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {2.1}计算数组元素的地址}{3}{subsection.2.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {2.2}其他内容}{3}{subsection.2.2}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {3}链接}{3}{section.3}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {3.1}符号表 (.symtab)}{3}{subsection.3.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {3.2}链接顺序}{3}{subsection.3.2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {3.3}重定位}{3}{subsection.3.3}\protected@file@percent }
\gdef \@abspage@last{3}

Binary file not shown.

View file

View file

@ -33,7 +33,7 @@
\pagestyle{myfancypagestyle}
\tcbuselibrary{listings}
\tcbset{colback=white,boxrule=0.3mm,enhanced}
\tcbset{colback=white,boxrule=0.3mm,enhanced,size=small}
\lstset{basicstyle=\ttfamily,columns=fullflexible}
@ -45,7 +45,6 @@
\section{数据表示与存储}
\subsection{数据的类型及大小}
\begin{table}[h]
\caption{数据的类型及大小}
\begin{tabular}{|c|c|c|c|c|}
\hline
类型 & 字节数 & 最小值 & 最大值(signed) & 最大值(unsigned) \\ \hline
@ -140,7 +139,7 @@ T: 用 $n$ 位表示数字
$\text{(unsigned)} \ \text{exp} \ = \ E \ + \text{Bias}$
$\text{Bias (偏置值)} = 2^{k-1}-1$ , k 为 $exp$ 的二进制位数
$\text{Bias (偏置值)} = 2^{k-1}-1$ , \(k\) 为 exp 的二进制位数
\begin{multicols}{2}
例1:十进制整数$\rightarrow$二进制浮点数
@ -240,7 +239,15 @@ frac \(\ne 00\dots0\) 表示 NaN
\end{table}
\pagebreak
\vspace{-0.5em}
\InsertBoxR{0}{\tcboxmath{\begin{matrix}
\text{寻址模式} & \text{p. 121} \\
\text{栈帧结构} & \text{p. 164} \\
\text{gdb 操作} & \text{p. 194} \\
\end{matrix}}\hspace{2cm}}
\vspace{-1.5em}
\section{程序的机器级表示}
\subsection{计算数组元素的地址}
@ -256,29 +263,17 @@ frac \(\ne 00\dots0\) 表示 NaN
2 \ leaq (\%rdi,\%rax,\$k), \%rax \\
3 \ movl (\%rax,\%rdx,\$k), \%rax \\
}
结果为 \texttt{D+ k $\cdot$ C $\cdot$ i + k $\cdot$ j} \\
结果为 \texttt{D + k $\cdot$ C $\cdot$ i + k $\cdot$ j} \\
\texttt{D + sizeof(T) $\times$ (C $\cdot$ i + j)}
\end{multicols}
\vspace{-1cm}
\subsection{其他内容}
\vspace{-2mm}
\begin{table}[h]
\begin{tabular}{c|c|c|c} \hline
内容 & 操作数计算方式&&gdb常用操作\\ \hline
页码 & P121&P164&P194 \\
\hline
\end{tabular}
\end{table}
\vspace{-2em}
\vspace{-2.5em}
\section{链接}
\vspace{-1em}
\vspace{-1.5em}
\subsection{符号表 (.symtab)}
\vspace{-1em}
\begin{table}[h]
\begin{tabular}{l|c|c|c|l}
\hline
@ -308,9 +303,11 @@ frac \(\ne 00\dots0\) 表示 NaN
& --- & --- & --- & \makecell[l]{链接不涉及静态函数\\链接不涉及非静态局部变量} \\ \hline
\end{tabular}
\end{table}
\vspace{-2em}
\subsection{链接顺序}
\vspace{-0.5em}
\texttt{\$ gcc -static -o prog2c main2.o ./libvector.a} \\
E 将被合并以组成可执行文件的所有目标文件集合\\
U 当前所有未解析的引用符号的集合\\
@ -318,12 +315,23 @@ D 当前所有定义符号的集合\\
开始 E、U、D为空首先扫描 \texttt{main2.o},将其加入 E将未找到的符号加入 U, 定义的符号加入 D。 \\
再扫描 \texttt{./libvector.a},将匹配到的 U 中的符号转移到 D 并加入到 E 同时将未找到的符号加入 U。 \\
最后搜索标准库 \texttt{libc.a},处理完\texttt{libc.a}U一定是空的D中符号唯一否则错误。
\vspace{-1em}
\subsection{重定位}
\vspace{-0.5em}
PC相对地址下重定位值计算公式\\
\texttt{ADDR(r.symbol)-((ADDR(.text)+r.offset)-r.addend)}\\
在asm中表示为 \texttt{4004de: e8 \underbar{05 00 00 00} \quad callq 4004e8 <sum>}
\begin{itemize}
\item 重定位 PC 相对引用(\texttt{R\_X86\_64\_PC32}): \\
重定位值 \( =\texttt{ADDR(r.symbol)} - \underbrace{\left(\texttt{ADDR(.text)} + \texttt{r.offset}\right)}_{\text{重定位值的地址}} + \texttt{r.addend}\)
在asm中表示为 \texttt{4004de: e8 \underbar{05 00 00 00} \quad callq 4004e8 <sum>}
\item 重定位绝对引用(\texttt{R\_X86\_64\_32}): \\
重定位值 = \(\texttt{ADDR(r.symbol)} + \texttt{r.addend}\) \\
在asm中直接以其绝对地址表示\texttt{4004d9: bf \underbar{18 10 60 00} \quad mov \$0x601018 \%edi}
\end{itemize}
\newpage