转自:http://unix.stackexchange.com/questions/5719/linux-gnu-gcc-ld-version-scripts-and-the-elf-binary-format-how-does-it-wor/10317#10317

First of all, ELF is the specification use by Linux for executable files (programs), shared libraries, and also object files which are the intermediate files found when compiling software. Object files end in .o, shared libraries end with .so followed by zero or more digits separated by periods, and executable files don't have any extension normally.

There are typically three forms to name a shared library, the first form simply ends in .so. For example, a library called readline is stored in a file called libreadline.so and is located under one of /lib, /usr/lib, or /usr/local/lib normally. That file is located when compiling software with an option like -lreadline. -l tells the compiler to link with the following library. Because libraries change from time to time, it may become obsolete so libraries embed something called a SONAME. The SONAME for readline might look like libreadline.so.2 for the second version major version of libreadline. There may also be many minor versions of readline that are compatible and do not require software to be recompiled. A minor version of readline might be named libreadline.so.2.14. Normally libreadline.so is just a symbolic link to the most recent major version of readline, libreadline.so.2 in this case. libreadline.so.2 is also a symbolic link to libreadline.so.2.14 which is actually the file being used.

The SONAME of a library is embedded inside the library file itself. Somewhere inside the file libreadline.so.2.14 is the string libreadline.so.2. When a program is compiled and linked with readline, it will look for the file libreadline.so and read the SONAME embedded in it. Later, when the program is actually executed, it will load libreadline.so.2, not just libreadline.so, since that was the SONAME that was read when it was first linked. This allows a system to have multiple incompatible versions of readline installed, and each program will load the appropriate major version it was linked with. Also, when upgrading readline, say, to 2.17, I can just install libreadline.so.2.17 alongside the existing library, and once I move the symbolic link libreadline.so.2 from libreadline.so.2.13 to libreadline.so.2.17, all software using that same major version will now see the new minor update to it.

随机推荐

  1. element-ui表单form和rules踩坑

    问题: 代码: <el-form ref="form" :rules="rules" :model="form" label-widt ...

  2. quill富文本编辑器 API

    //1. 从第三个开始删除,删除4个 // console.log(this.quill.deleteText(2, 4)); // 12345678 1278 // 2.(返回对象)返回从第三个开始 ...

  3. 第十一节 JS事件基础

    空白点击事件(没什么用处,做个介绍) <!DOCTYPE html> <html lang="en"> <head> <meta char ...

  4. 聊天斗图神器aidou mac中文版

    aidou mac中文版是mac上一款专为斗图设计的聊天斗图神器,让您在聊天的时候不怕没有表情用,炫酷的表情即时更新,让您每时每刻都有新表情用!一键下载的表情包!小编现为您带来aidou斗图神器免费版 ...

  5. Eclipse如何导入maven项目,以及配置maven

    Eclipse如何导入maven项目,以及配置maven 一.准备工作 1. eclipse,安装了eclipse 2. 一个需要导入的maven项目 3. 下载好了的压缩包apache-maven- ...

  6. Html5 Page Creator,简易h5页面场景制作

  7. sonarqube安装部署

    环境:Os:Centos 71.下载下载地址:https://www.sonarqube.org/sonarqube-7-7/我这里下载的是sonarqube-7-7sonarqube-7.7.zip ...

  8. 使用go-template自定义kubectl get输出

    kubectl get相关资源,默认输出为kubectl内置,一般我们也可以使用-o json或者-o yaml查看其完整的资源信息.但是很多时候,我们需要关心的信息并不全面,因此我们需要自定义输出的 ...

  9. windos下安装pgAdmin

    1.进入pgAdmin官方网址 https://www.pgadmin.org/download/ 2.下载安装包 版本下载地址:https://www.pgadmin.org/download/pg ...

  10. ES6中的类和继承

    class的写法及继承 JavaScript 语言中,生成实例对象的传统方法是通过构造函数.下面是一个例子     function Point(x, y) {  this.x = x;  this. ...