mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-10-29 15:13:44 +00:00
Update 计算机操作系统 - 链接.md
重新绘制配图。
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 93 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 141 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 135 KiB |
@@ -31,7 +31,7 @@ gcc -o hello hello.c
|
||||
|
||||
这个过程大致如下:
|
||||
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/b396d726-b75f-4a32-89a2-03a7b6e19f6f.jpg" width="800"/> </div><br>
|
||||
<div align="center"> <img src="pics/compile-pipeline.png" width="760px"/> </div><br>
|
||||
|
||||
- 预处理阶段:处理以 # 开头的预处理命令;
|
||||
- 编译阶段:翻译成汇编文件;
|
||||
@@ -45,7 +45,7 @@ gcc -o hello hello.c
|
||||
- 符号解析:每个符号对应于一个函数、一个全局变量或一个静态变量,符号解析的目的是将每个符号引用与一个符号定义关联起来。
|
||||
- 重定位:链接器通过把每个符号定义与一个内存位置关联起来,然后修改所有对这些符号的引用,使得它们指向这个内存位置。
|
||||
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/47d98583-8bb0-45cc-812d-47eefa0a4a40.jpg"/> </div><br>
|
||||
<div align="center"> <img src="pics/static-link.png" width="760px"/> </div><br>
|
||||
|
||||
## 目标文件
|
||||
|
||||
@@ -65,4 +65,4 @@ gcc -o hello hello.c
|
||||
- 在给定的文件系统中一个库只有一个文件,所有引用该库的可执行目标文件都共享这个文件,它不会被复制到引用它的可执行文件中;
|
||||
- 在内存中,一个共享库的 .text 节(已编译程序的机器代码)的一个副本可以被不同的正在运行的进程共享。
|
||||
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/76dc7769-1aac-4888-9bea-064f1caa8e77.jpg"/> </div><br>
|
||||
<div align="center"> <img src="pics/dynamic-link.png" width="760px"/> </div><br>
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="230" viewBox="0 0 760 230">
|
||||
<style>
|
||||
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
|
||||
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
|
||||
.b { font-weight: bold; }
|
||||
.c { text-anchor: middle; }
|
||||
.e { text-anchor: end; }
|
||||
.sub { font-size: 11px; fill: #6E6E6E; }
|
||||
.note { fill: #C0605A; }
|
||||
.ok { fill: #6A9F68; }
|
||||
.mono { font-family: Menlo, Consolas, monospace; }
|
||||
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
|
||||
.red { stroke: #C0605A; marker-end: url(#r); }
|
||||
.green { stroke: #6A9F68; marker-end: url(#g); }
|
||||
.dash { stroke-dasharray: 5 4; }
|
||||
.line { stroke: #555; stroke-width: 1.1; fill: none; }
|
||||
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
|
||||
.shadow { fill: #DADADA; }
|
||||
</style>
|
||||
<defs>
|
||||
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
|
||||
</marker>
|
||||
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
|
||||
</marker>
|
||||
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="#FFFFFF"/>
|
||||
|
||||
<text x="380" y="28" class="title">gcc -o hello hello.c 的四个阶段</text>
|
||||
<path d="M60,60 h31 l9,9 v41 h-40 z" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<path d="M91,60 v9 h9" fill="none" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<line x1="66" y1="77" x2="93" y2="77" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<line x1="66" y1="84" x2="93" y2="84" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<line x1="66" y1="91" x2="93" y2="91" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="80" y="130" class="c sub mono b" style="fill:#444">hello.c</text>
|
||||
<text x="80" y="146" class="c sub">源程序</text>
|
||||
<line x1="108" y1="85" x2="202" y2="85" class="arrow "/>
|
||||
<text x="155" y="76" class="c sub">预处理器 cpp</text>
|
||||
<text x="155" y="104" class="c sub mono" style="fill:#296898">gcc -E</text>
|
||||
<path d="M210,60 h31 l9,9 v41 h-40 z" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1.2"/>
|
||||
<path d="M241,60 v9 h9" fill="none" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="216" y1="77" x2="243" y2="77" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="216" y1="84" x2="243" y2="84" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="216" y1="91" x2="243" y2="91" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="230" y="130" class="c sub mono b" style="fill:#444">hello.i</text>
|
||||
<text x="230" y="146" class="c sub">预处理后的源程序</text>
|
||||
<line x1="258" y1="85" x2="352" y2="85" class="arrow "/>
|
||||
<text x="305" y="76" class="c sub">编译器 cc1</text>
|
||||
<text x="305" y="104" class="c sub mono" style="fill:#296898">gcc -S</text>
|
||||
<path d="M360,60 h31 l9,9 v41 h-40 z" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1.2"/>
|
||||
<path d="M391,60 v9 h9" fill="none" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="366" y1="77" x2="393" y2="77" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="366" y1="84" x2="393" y2="84" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="366" y1="91" x2="393" y2="91" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="380" y="130" class="c sub mono b" style="fill:#444">hello.s</text>
|
||||
<text x="380" y="146" class="c sub">汇编程序</text>
|
||||
<line x1="408" y1="85" x2="502" y2="85" class="arrow "/>
|
||||
<text x="455" y="76" class="c sub">汇编器 as</text>
|
||||
<text x="455" y="104" class="c sub mono" style="fill:#296898">gcc -c</text>
|
||||
<path d="M510,60 h31 l9,9 v41 h-40 z" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1.2"/>
|
||||
<path d="M541,60 v9 h9" fill="none" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="516" y1="77" x2="543" y2="77" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="516" y1="84" x2="543" y2="84" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="516" y1="91" x2="543" y2="91" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="530" y="130" class="c sub mono b" style="fill:#444">hello.o</text>
|
||||
<text x="530" y="146" class="c sub">可重定位目标文件</text>
|
||||
<line x1="558" y1="85" x2="652" y2="85" class="arrow "/>
|
||||
<text x="605" y="76" class="c sub">链接器 ld</text>
|
||||
<path d="M660,60 h31 l9,9 v41 h-40 z" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1.2"/>
|
||||
<path d="M691,60 v9 h9" fill="none" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<line x1="666" y1="77" x2="693" y2="77" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<line x1="666" y1="84" x2="693" y2="84" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<line x1="666" y1="91" x2="693" y2="91" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<text x="680" y="130" class="c sub mono b" style="fill:#444">hello</text>
|
||||
<text x="680" y="146" class="c sub">可执行目标文件</text>
|
||||
<path d="M590,160 h23 l9,9 v31 h-32 z" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1.2"/>
|
||||
<path d="M613,160 v9 h9" fill="none" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<line x1="596" y1="177" x2="615" y2="177" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<line x1="596" y1="184" x2="615" y2="184" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<line x1="596" y1="191" x2="615" y2="191" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="630" y="178" class="sub mono">printf.o 等</text>
|
||||
<text x="630" y="194" class="sub">库中的目标文件</text>
|
||||
<line x1="606" y1="158" x2="606" y2="92" class="arrow "/>
|
||||
<text x="30" y="216" class="sub">前三步各自可以用 gcc 的选项单独执行;.i、.s 是文本文件,.o 和 hello 是二进制的 ELF 文件。</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.7 KiB |
@@ -0,0 +1,74 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="300" viewBox="0 0 760 300">
|
||||
<style>
|
||||
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
|
||||
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
|
||||
.b { font-weight: bold; }
|
||||
.c { text-anchor: middle; }
|
||||
.e { text-anchor: end; }
|
||||
.sub { font-size: 11px; fill: #6E6E6E; }
|
||||
.note { fill: #C0605A; }
|
||||
.ok { fill: #6A9F68; }
|
||||
.mono { font-family: Menlo, Consolas, monospace; }
|
||||
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
|
||||
.red { stroke: #C0605A; marker-end: url(#r); }
|
||||
.green { stroke: #6A9F68; marker-end: url(#g); }
|
||||
.dash { stroke-dasharray: 5 4; }
|
||||
.line { stroke: #555; stroke-width: 1.1; fill: none; }
|
||||
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
|
||||
.shadow { fill: #DADADA; }
|
||||
</style>
|
||||
<defs>
|
||||
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
|
||||
</marker>
|
||||
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
|
||||
</marker>
|
||||
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="#FFFFFF"/>
|
||||
|
||||
<text x="380" y="28" class="title">动态链接:链接时只记录依赖,运行时再加载共享库</text>
|
||||
<rect x="20" y="46" width="340" height="200" rx="8" class="frame"/>
|
||||
<text x="30" y="64" class="b">构建时</text>
|
||||
<rect x="390" y="46" width="350" height="200" rx="8" class="frame"/>
|
||||
<text x="400" y="64" class="b">运行时</text>
|
||||
<path d="M50,80 h27 l9,9 v35 h-36 z" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1.2"/>
|
||||
<path d="M77,80 v9 h9" fill="none" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="56" y1="97" x2="79" y2="97" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="56" y1="104" x2="79" y2="104" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="56" y1="111" x2="79" y2="111" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="68" y="140" class="c sub mono">main.o</text>
|
||||
<path d="M130,80 h27 l9,9 v35 h-36 z" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1.2"/>
|
||||
<path d="M157,80 v9 h9" fill="none" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<line x1="136" y1="97" x2="159" y2="97" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<line x1="136" y1="104" x2="159" y2="104" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<line x1="136" y1="111" x2="159" y2="111" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="148" y="140" class="c sub mono">libmath.so</text>
|
||||
<text x="148" y="156" class="c sub">只读取符号表</text>
|
||||
<rect x="200" y="84" width="70" height="34" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
|
||||
<text x="235" y="105.5" class="c sub b">ld</text>
|
||||
<line x1="90" y1="100" x2="196" y2="100" class="arrow "/>
|
||||
<line x1="168" y1="112" x2="198" y2="112" class="arrow "/>
|
||||
<path d="M290,80 h27 l9,9 v35 h-36 z" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1.2"/>
|
||||
<path d="M317,80 v9 h9" fill="none" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<line x1="296" y1="97" x2="319" y2="97" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<line x1="296" y1="104" x2="319" y2="104" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<line x1="296" y1="111" x2="319" y2="111" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<text x="308" y="140" class="c sub mono">prog</text>
|
||||
<line x1="272" y1="101" x2="286" y2="101" class="arrow "/>
|
||||
<text x="40" y="186" class="sub">prog 中只记下依赖 libmath.so 和 libc.so,</text>
|
||||
<text x="40" y="202" class="sub">不包含它们的代码</text>
|
||||
<rect x="410" y="84" width="110" height="34" rx="6" fill="#EAE9E7" stroke="#BFBEBA"/>
|
||||
<text x="465" y="105.5" class="c sub">execve 加载 prog</text>
|
||||
<line x1="522" y1="101" x2="552" y2="101" class="arrow "/>
|
||||
<rect x="556" y="84" width="170" height="34" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
|
||||
<text x="641" y="105.5" class="c sub b">动态链接器 ld-linux.so</text>
|
||||
<text x="641" y="140" class="c sub">把 libmath.so、libc.so</text>
|
||||
<text x="641" y="156" class="c sub">映射进内存,完成重定位</text>
|
||||
<text x="410" y="196" class="sub">多个进程共享同一份库的代码(.text),</text>
|
||||
<text x="410" y="212" class="sub">库更新后不用重新链接程序</text>
|
||||
<text x="30" y="280" class="sub">用 ldd prog 可以查看程序依赖的共享库;找不到某个库时程序启动失败,报 cannot open shared object file。</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.6 KiB |
@@ -0,0 +1,85 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="300" viewBox="0 0 760 300">
|
||||
<style>
|
||||
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
|
||||
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
|
||||
.b { font-weight: bold; }
|
||||
.c { text-anchor: middle; }
|
||||
.e { text-anchor: end; }
|
||||
.sub { font-size: 11px; fill: #6E6E6E; }
|
||||
.note { fill: #C0605A; }
|
||||
.ok { fill: #6A9F68; }
|
||||
.mono { font-family: Menlo, Consolas, monospace; }
|
||||
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
|
||||
.red { stroke: #C0605A; marker-end: url(#r); }
|
||||
.green { stroke: #6A9F68; marker-end: url(#g); }
|
||||
.dash { stroke-dasharray: 5 4; }
|
||||
.line { stroke: #555; stroke-width: 1.1; fill: none; }
|
||||
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
|
||||
.shadow { fill: #DADADA; }
|
||||
</style>
|
||||
<defs>
|
||||
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
|
||||
</marker>
|
||||
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
|
||||
</marker>
|
||||
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="#FFFFFF"/>
|
||||
|
||||
<text x="380" y="28" class="title">静态链接:符号解析和重定位</text>
|
||||
<rect x="30" y="50" width="260" height="70" rx="5" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1.2"/>
|
||||
<line x1="30" y1="64" x2="290" y2="64" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<circle cx="39" cy="57" r="2.2" fill="#BBBBBB"/>
|
||||
<circle cx="47" cy="57" r="2.2" fill="#BBBBBB"/>
|
||||
<circle cx="55" cy="57" r="2.2" fill="#BBBBBB"/>
|
||||
<text x="39" y="80" class="sub mono">// main.c</text>
|
||||
<text x="39" y="96" class="sub mono">int sum(int *a, int n);</text>
|
||||
<text x="39" y="112" class="sub mono">int main() { return sum(arr, 2); }</text>
|
||||
<rect x="310" y="50" width="200" height="70" rx="5" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1.2"/>
|
||||
<line x1="310" y1="64" x2="510" y2="64" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<circle cx="319" cy="57" r="2.2" fill="#BBBBBB"/>
|
||||
<circle cx="327" cy="57" r="2.2" fill="#BBBBBB"/>
|
||||
<circle cx="335" cy="57" r="2.2" fill="#BBBBBB"/>
|
||||
<text x="319" y="80" class="sub mono">// sum.c</text>
|
||||
<text x="319" y="96" class="sub mono">int sum(int *a, int n) {</text>
|
||||
<text x="319" y="112" class="sub mono"> ... }</text>
|
||||
<path d="M120,146 h27 l9,9 v35 h-36 z" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1.2"/>
|
||||
<path d="M147,146 v9 h9" fill="none" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="126" y1="163" x2="149" y2="163" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="126" y1="170" x2="149" y2="170" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="126" y1="177" x2="149" y2="177" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="162" y="164" class="sub mono b" style="fill:#444">main.o</text>
|
||||
<text x="162" y="180" class="sub note">引用 sum,地址未知</text>
|
||||
<path d="M360,146 h27 l9,9 v35 h-36 z" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1.2"/>
|
||||
<path d="M387,146 v9 h9" fill="none" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="366" y1="163" x2="389" y2="163" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="366" y1="170" x2="389" y2="170" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<line x1="366" y1="177" x2="389" y2="177" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="402" y="164" class="sub mono b" style="fill:#444">sum.o</text>
|
||||
<text x="402" y="180" class="sub ok">定义 sum</text>
|
||||
<line x1="145" y1="122" x2="140" y2="144" class="arrow "/>
|
||||
<line x1="390" y1="122" x2="380" y2="144" class="arrow "/>
|
||||
<rect x="200" y="214" width="180" height="34" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
|
||||
<text x="290" y="235.5" class="c sub b">链接器 ld</text>
|
||||
<line x1="140" y1="192" x2="240" y2="212" class="arrow "/>
|
||||
<line x1="380" y1="192" x2="340" y2="212" class="arrow "/>
|
||||
<line x1="384" y1="231" x2="470" y2="231" class="arrow "/>
|
||||
<path d="M476,208 h27 l9,9 v35 h-36 z" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1.2"/>
|
||||
<path d="M503,208 v9 h9" fill="none" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<line x1="482" y1="225" x2="505" y2="225" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<line x1="482" y1="232" x2="505" y2="232" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<line x1="482" y1="239" x2="505" y2="239" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<text x="520" y="226" class="sub mono b" style="fill:#444">prog</text>
|
||||
<text x="520" y="242" class="sub">可执行目标文件</text>
|
||||
<text x="560" y="80" class="sub" style="fill:#444">① 符号解析:把 main.o 中</text>
|
||||
<text x="560" y="96" class="sub" style="fill:#444">对 sum 的引用对应到</text>
|
||||
<text x="560" y="112" class="sub" style="fill:#444">sum.o 中的定义</text>
|
||||
<text x="560" y="144" class="sub" style="fill:#444">② 重定位:合并代码后确定</text>
|
||||
<text x="560" y="160" class="sub" style="fill:#444">sum 的地址,填回 main 中</text>
|
||||
<text x="560" y="176" class="sub" style="fill:#444">调用指令的地址字段</text>
|
||||
<text x="30" y="286" class="sub">找不到定义时报 undefined reference,出现两个同名的强定义时报 multiple definition,都是在符号解析这一步发现的。</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.5 KiB |
Reference in New Issue
Block a user