How To Write Shared Libraries(55)

3.2 Defining Stability(4)

Not making the changes can have negative results. Blindly changing the code will definitely have negative results. Making the change and still maintaining ABI stability requires the use of versioning.
不标记改变会导致异常结果。盲目修改代码一定会导致异常结果。标记改变,同时要求ABI兼容用法。

These incompatible changes to a DSO are not the only changes which can cause problems. Adding a new interface does not cause problems for existing applications. But if a new application uses the new interface it will run into problems if at runtime only the old version of the DSO, the one without the newly added symbol, is avail- able. The user can detect this by forcing the dynamic linker to perform all relocations at load-time by defining LD BIND NOW to an nonempty value in the environment before starting the application. The dynamic linker will abort with an error if an old DSO is used. But forcing the relocations introduces major performance penalties (which is the reason why lazy relocations were in- troduced in the first place). Instead the dynamic linker should detect the old DSO version without performing the relocations.
不兼容的修改不是唯一的问题原因。增加接口不会导致已有的应用出问题。但是如果一个新应用使用新接口,运行时使用老版本的DSO有问题。用户可以通过设置 LD BIND NOW来让动态链接器强制执行所有的重定向过程检查异常。如果使用老的DSO会abort。但是强制重定向会有性能问题(这是介绍lazy 重定向的原因)。代替方案是检查DSO版本,不用执行重定向。

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