欢迎来到麦多课文档分享! | 帮助中心 海量文档,免费浏览,给你所需,享你所想!
麦多课文档分享
全部分类
  • 标准规范>
  • 教学课件>
  • 考试资料>
  • 办公文档>
  • 学术论文>
  • 行业资料>
  • 易语言源码>
  • ImageVerifierCode 换一换
    首页 麦多课文档分享 > 资源分类 > PPT文档下载
    分享到微信 分享到微博 分享到QQ空间

    Linking Loading.ppt

    • 资源ID:372974       资源大小:119KB        全文页数:23页
    • 资源格式: PPT        下载积分:2000积分
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    二维码
    微信扫一扫登录
    下载资源需要2000积分(如需开发票,请勿充值!)
    邮箱/手机:
    温馨提示:
    如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如需开发票,请勿充值!如填写123,账号就是123,密码也是123。
    支付方式: 支付宝扫码支付    微信扫码支付   
    验证码:   换一换

    加入VIP,交流精品资源
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    Linking Loading.ppt

    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

    12、f”);loaded = 1;printf(arg); ,Linking and Loading,CS-502 Fall 2007,12,Linker-assisted Dynamic Loading,Programmer marks modules as “dynamic” to linker For function call to a dynamic function Call is indirect through a link table Each link table entry is initialized with address of small stub of code t

    13、o locate and load module. When loaded, loader replaces link table entry with address of loaded function When unloaded, loader restores table entry with stub address Works only for function calls, not static data,Linking and Loading,CS-502 Fall 2007,13,Example Linker-assisted loading (before),Your pr

    14、ogramvoid main () printf ();,Link table,Stub void load() load(“IOLib”); ,Linking and Loading,CS-502 Fall 2007,14,Example Linker-assisted loading (after),Your programvoid main () printf ();,Link table,IOLib read() printf() scanf() ,Linking and Loading,CS-502 Fall 2007,15,Shared Libraries,Observation

    15、“everyone” links to standard libraries (libc.a, etc.) These consume space in every executable image every process memory at runtime Would it be possible to share the common libraries? Automatically load at runtime?,Linking and Loading,CS-502 Fall 2007,16,Shared libraries (continued),Libraries design

    16、ated as “shared” .so, .dll, etc. Supported by corresponding “.a” libraries containing symbol information Linker sets up symbols to be resolved at runtime Loader: Is library already in memory? If yes, map into new process space “map,” an operation to be defined later in course If not, load and then m

    17、ap,Linking and Loading,CS-502 Fall 2007,17,Run-time Linking/Loading,Linking and Loading,CS-502 Fall 2007,18,Dynamic Linking,Complete linking postponed until execution time. Stub used to locate the appropriate memory-resident library routine. Stub replaces itself with the address of the routine, and

    18、executes the routine. Operating system needs to check if routine is in address space of process Dynamic linking is particularly useful for libraries.,Linking and Loading,CS-502 Fall 2007,19,Dynamic Shared Libraries,Static shared libraries requires address space pre-allocation Dynamic shared librarie

    19、s address binding at runtime Code must be position independent At runtime, references are resolved as Library_relative_address + library_base_address,Linking and Loading,CS-502 Fall 2007,20,Overlays (primarily of historical interest),Keep in memory only those instructions and data that are needed at

    20、 any given time. Needed when process is larger than amount of memory allocated to it. Can be implemented by user no special support needed from operating system, but programming design of overlay structure is complex Can be done with OS help think about Unix exec system call,Linking and Loading,CS-5

    21、02 Fall 2007,21,Linking Summary,Linker key part of OS not in kernel Combines object files and libraries into a “standard” format that the OS loader can interpret Resolves references and does static relocation of addresses Creates information for loader to complete binding process Supports dynamic sh

    22、ared libraries,Linking and Loading,CS-502 Fall 2007,22,Loader,An integral part of the OS Resolves addresses and symbols that could not be resolved at link-time May be small or large Small: Classic Unix Large: Linux, Windows XP, etc. May be invoke explicitly or implicitly Explicitly by stub or by program itself Implicitly as part of exec,Linking and Loading,CS-502 Fall 2007,23,Questions?,


    注意事项

    本文(Linking Loading.ppt)为本站会员(appealoxygen216)主动上传,麦多课文档分享仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文档分享(点击联系客服),我们立即给予删除!




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1 

    收起
    展开