Linking Loading.ppt
《Linking Loading.ppt》由会员分享,可在线阅读,更多相关《Linking Loading.ppt(23页珍藏版)》请在麦多课文档分享上搜索。
1、Linking and Loading,CS-502 Fall 2007,1,Linking & Loading,CS-502 Operating SystemsSilbershatz et al barely touch on this topic in 8.1 Tanenbaum does not address it at all,Linking and Loading,CS-502 Fall 2007,2,What happens to your program ,after it is compiled, but before it can be run?,Linking and L
2、oading,CS-502 Fall 2007,3,Executable files,Every OS expects executable files to have a specific format Header info Code locations Data locations Code & data Symbol Table List of names of things defined in your program and where they are located within your program. List of names of things defined el
3、sewhere that are used by your program, and where they are used.,Linking and Loading,CS-502 Fall 2007,4,Example,#include int main () printf (“hello, worldn”),Symbol defined in your program and used elsewhere mainSymbol defined elsewhere and used by your program printf,Linking and Loading,CS-502 Fall
4、2007,5,Example,#include extern int errno;int main () printf (“hello, worldn”),Symbol defined in your program and used elsewhere mainSymbol defined elsewhere and used by your program printf errno,Linking and Loading,CS-502 Fall 2007,6,Two-step operation (in most systems),Linking: Combining a set of p
5、rograms, including library routines, to create a loadable image Resolving symbols defined within the set Listing symbols needing to be resolved by loaderLoading: Copying the loadable image into memory, connecting it with any other programs already loaded, and updating addresses as needed (In Unix) i
6、nterpreting file to initialize the process address space (in all systems) kernel image is special (own format),Linking and Loading,CS-502 Fall 2007,7,From source code to a process,Binding is the act of connecting names to addresses Most compilers produce relocatable object code Addresses relative to
7、 zero The linker combines multiple object files and library modules into a single executable file Addresses also relative to zero The Loader reads the executable file Allocates memory Maps addresses within file to memory addresses Resolves names of dynamic library items,Source (.c, .cc),Object (.o),
8、Executable,In-memory Image,Compiler,Linker,Loader,Other Objects (.o),Dynamic libraries (.dll),Static libraries (.a),Linking and Loading,CS-502 Fall 2007,8,Static Linking and Loading,Linking and Loading,CS-502 Fall 2007,9,Classic Unix,Linker lives inside of cc or gcc command Loader is part of exec sy
9、stem call Executable image contains all object and library modules needed by program Entire image is loaded at onceEvery image contains its own copy of common library routines Every loaded program contain duplicate copy of library routines,Linking and Loading,CS-502 Fall 2007,10,Dynamic Loading,Rout
10、ine is not loaded until it is called Better memory-space utilization; unused routine is never loaded. Useful when large amounts of code are needed to handle infrequently occurring cases. Silbershatz says incorrectly No special support from the operating system is required Must be implemented through
11、 program design,Linking and Loading,CS-502 Fall 2007,11,Program-controlled Dynamic Loading,Requires: A load system call to invoke loader (not in Unix) ability to leave symbols unresolved and resolve at run time (not in Unix) E.g., void myPrintf (*arg) static int loaded = 0;if (!loaded ) load (“print
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- LINKINGLOADINGPPT
