How To Write Shared Libraries(6)

1.5 Startup in the Dynamic Linker

The second phase of the program startup happens in the dynamic linker. Its tasks include:
链接器启动第二阶段的任务包括:
• Determine and load dependencies;
• Relocate the application and all dependencies;
• Initialize the application and dependencies in the correct order.
判断加载依赖;
重定位应用和依赖;
正确顺序的初始化应用和依赖。

In the following we will discuss in more detail only the relocation handling. For the other two points the way for better performance is clear: have fewer dependen- cies. Each participating object is initialized exactly once but some topological sorting has to happen. The identify and load process also scales with the number dependen- cies; in most (all?) implementations this does not scale linearly.
接下来,我们更多的讨论重定位相关内容。
另外两点的优化效果很清晰:更少的依赖。
每个部分的对象在排序后可以正确的完成初始化。
识别和加载的过程随着依赖扩展。大部分这里不是线性扩展的。

The relocation process is normally the most expensive part of the dynamic linker’s work. It is a process which is asymptotically at least O(R + nr) where R is the number of relative relocations, r is the number of named reloca- tions, and n is the number of participating DSOs (plus the main executable). Deficiencies in the ELF hash ta- ble function and various ELF extensions modifying the symbol lookup functionality may well increase the factor to O(R + rn log s) where s is the number of symbols. This should make clear that for improved performance it is significant to reduce the number if relocations and sym- bols as much as possible. After explaining the relocation process we will do some estimates for actual numbers.
一般情况下重加载过程是最耗时的部分。接近O(R + nr):R是重定位的数量,r是命名的数量,n是DSO数量。
ELF缺少hash函数,ELF扩展修改语法查找函数可以增加到O(R + rn log s):s是语法数量。这样可以显著提高重定位效率。(待完善
解释完重定位内容,评估一下实际数量。

你可能感兴趣的:(How To Write Shared Libraries(6))