dyld&ld

作者: tom__zhu | 来源:发表于2022-02-01 00:53 被阅读0次

一直对Xcode编译用到的ld和dyld存有疑问,开始以为都是链接器,简单了解一下发现理解错了。

NAME
dyld - the dynamic linker
DESCRIPTION
The dynamic linker (dyld) checks the following environment variables during the launch of each process.

这是man page显示dyld的定义,很明显ld是链接器而dyld是动态链接器(或许应该成为加载器),或许把dyld理解为dynamic loader更能说明含义。dyld是用于把动态库加载早进程地址空间的程序,因为操作系统的ASLR机制,dyld需要处理内部符号重定位外部符号重绑定,所有它也包含链接能力。但是我们永远也不会调动dyld,你只会只用ld,典型的场景就是编译器会替你调用ld做链接步骤,dyld只会在启动时被调用。当然iOS还存在另外两种dylib加载器,dlsym和dlopen,只是受限于苹果爸爸的审核,这两个加载器不能过审。捎带些私活,NSBundle load本质是调用dlopen,可以在注册制跳转中使用,但是没有UI界面的功能库需要另外处理了。

NAME
     ld – linker
DESCRIPTION
     The ld command combines several object files and libraries, resolves
     references, and produces an output file.  ld can produce a final linked
     image (executable, dylib, or bundle), or with the -r option, produce
     another object file.  If the -o option is not used, the output file
     produced is named "a.out".

上面是man page对ld的定义,ld是链接器,用来处理静态链接或是动态链接。

相关文章

  • dyld&ld

    一直对Xcode编译用到的ld和dyld存有疑问,开始以为都是链接器,简单了解一下发现理解错了。 这是man pa...

网友评论

      本文标题:dyld&ld

      本文链接:https://www.haomeiwen.com/subject/gxhkkrtx.html