📄 ld65-4.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML><HEAD> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.20"> <TITLE>ld65 Users Guide: Detailed workings</TITLE> <LINK HREF="ld65-5.html" REL=next> <LINK HREF="ld65-3.html" REL=previous> <LINK HREF="ld65.html#toc4" REL=contents></HEAD><BODY><A HREF="ld65-5.html">Next</A><A HREF="ld65-3.html">Previous</A><A HREF="ld65.html#toc4">Contents</A><HR><H2><A NAME="s4">4.</A> <A HREF="ld65.html#toc4">Detailed workings</A></H2><P>The linker does several things when combining object modules:</P><P>First, the command line is parsed from left to right. For each object fileencountered (object files are recognized by a magic word in the header, sothe linker does not care about the name), imported and exportedidentifiers are read from the file and inserted in a table. If a libraryname is given (libraries are also recognized by a magic word, there are nospecial naming conventions), all modules in the library are checked if anexport from this module would satisfy an import from other modules. Allmodules where this is the case are marked. If duplicate identifiers arefound, the linker issues a warning.</P><P>This procedure (parsing and reading from left to right) does mean, that alibrary may only satisfy references for object modules (given directly or froma library) named <EM>before</EM> that library. With the command line</P><P><BLOCKQUOTE><CODE><PRE> ld65 crt0.o clib.lib test.o</PRE></CODE></BLOCKQUOTE></P><P>the module test.o may not contain references to modules in the libraryclib.lib. If this is the case, you have to change the order of the moduleson the command line:</P><P><BLOCKQUOTE><CODE><PRE> ld65 crt0.o test.o clib.lib</PRE></CODE></BLOCKQUOTE></P><P>Step two is, to read the configuration file, and assign start addressesfor the segments and define any linker symbols (see <A HREF="ld65-5.html#config-files">Configuration files</A>).</P><P>After that, the linker is ready to produce an output file. Before doing that,it checks it's data for consistency. That is, it checks for unresolvedexternals (if the output format is not relocatable) and for symbol typemismatches (for example a zero page symbol is imported by a module as absolutesymbol).</P><P>Step four is, to write the actual target files. In this step, the linker willresolve any expressions contained in the segment data. Circular references arealso detected in this step (a symbol may have a circular reference that goesunnoticed if the symbol is not used).</P><P>Step five is to output a map file with a detailed list of all modules,segments and symbols encountered.</P><P>And, last step, if you give the <CODE><A HREF="ld65-2.html#option-v">-v</A></CODE> switchtwice, you get a dump of the segment data. However, this may be quiteunreadable if you're not a developer:-)</P><HR><A HREF="ld65-5.html">Next</A><A HREF="ld65-3.html">Previous</A><A HREF="ld65.html#toc4">Contents</A></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -