Linker Use static Libraries
来源:互联网 发布:软件开发毕业论文题目 编辑:程序博客网 时间:2024/06/09 01:43
While static libraries are useful and essential tools, they are also a source of confusion to programmers because of the way the Unix linker uses them to resolve external references.During the symbol resolution phase, the linker scans the relocatable object files and archives left to right in the same requential order that they appear on the complier driver's command line.(The driver automatically translates any .c files on the command line into .o files) During this scan, the linker maintains a set E of relocatable object files that will be merged to form the executable, a set U of unresolved symbols (i.e., symbols referred to , but not yet defined), and a set D of unresolved symbols (i.e., symbols referred to , but not ye defined), and a set D of symbols that have been defined in previous input files. Initially, E, U, and D are empty.
For each input file f on the command line, the linker determines if f is an object file or an archive. If f is an object file, the linker add f to E, updates U and D to reflect the symbol definitions and referrences in f, and proceeds to the next input file.
if f is an archive, the linker attempts to match the unresolved symbols in U against the symbols defined by the members of the archive. If some archive member, m, defines a symbol that resolves a reference in U, then m is added to E, and the linker updates U and D to reflect the symbol definitions and referencces in m. This process iterates over the member object files in the archive until a fixed point is reached where U and D no longer change. At this point, any member object files not contained in E are simply discarded and the linker proceeds to the next input file.
if U is nonempty when the linker finishes scanning the input files on the command line, it prints an error and terminates . Otherwise, it merges and relocates the object files in E to build the output executable file.
Unfortunately, this algorithm can result in some baffling link-time errors because the ordering of libraries and object files on the command line is significant. If the library that defines a symbol appears on the command line before the object file that references that symbol, then the reference will not be resolved and linking will fail.
- Linker Use static Libraries
- How Linkers Use Static Libraries to Resolve References
- Static Libraries
- Linker and Libraries Guide(1)
- Linker and Libraries Guide Chapter 3 Runtime Linker
- Static Libraries in Xcode
- Static and dynamic libraries
- Linker and Libraries Guide Appendix D Linker and Libraries Updates and New Features
- Creating Static Libraries For iOS
- MinGW Static and Dynamic Libraries
- Linker and Libraries Guide --Chapter 2 Link-Editor
- Linker and Libraries Guide Chapter 4 Shared Objects
- Linker and Libraries Guide Chapter 6 Support Interfaces
- Linker and Libraries Guide Chapter 7 Object File Format
- Linker and Libraries Guide Chapter 8 Thread-Local Storage
- Linker and Libraries Guide Chapter 9 Mapfile Option
- Linker and Libraries Guide Appendix A Link-Editor Quick Reference
- Linker and Libraries Guide Appendix B Versioning Quick Reference
- database psu 11.2.0.3.0 到11.2.0.3.9
- 病毒—Win32/Gamarue
- -------------------Android代码优化——使用Android lint工具
- 携程编程大赛决赛-1004-最短路径的代价
- ant 打包android应用
- Linker Use static Libraries
- ProxyFactory的xml配置方式
- C语言里面的栈和堆
- Makefile文件变量的定义规则
- Python __new__与__init__说明
- struct 字节对齐详解
- android开发笔记之一些有用资料的汇总
- ACM中java的使用
- 上午9时15分许,习近平来到空军机关指挥楼