转自: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. react中对于key值的理解

    1.key是用来帮助react识别哪些内容被更改.添加或者删除.key需要写在用数组渲染出来的元素内部,并且需要赋予其一个稳定的值.如果key值发生了变更,react则会触发UI的重渲染. 2.在相邻 ...

  2. Typora学习笔记

    Typora学习笔记 标题 用"#"表示 快捷键:ctrl+1,2,3,4,5 居中 居中可用center标签 强调 使用强调 加粗 使用加粗 下划线 使用u标签:下划线 有序列表 ...

  3. django admin使用-后台数据库管理界面

    admin是django提供的基于web的管理数据库的工具,它是django.contrib 的一部分,可以在项目的settings.py中的INSTALLED_APPS看到. 一.admin管理工具 ...

  4. P2598 [ZJOI2009]狼和羊的故事(网络流)

    P2598 [ZJOI2009]狼和羊的故事 源点和所有狼连 $inf$ 的边 所有羊和汇点连 $inf$ 的边 所有点向四周连 $1$ 的边 这样所有狼和羊之间的边都被割掉了 统计最小割就好辣 #i ...

  5. win7有多条隧道适配器(isatap、teredo、6to4)的原因及关闭方法

    问题:sdp协商时,带有IPV6的信息,需要将IPV6相关信息去掉 原因:网卡启用了ipv6通道 解决:关闭IPv6数据接口 netsh interface isatap set state disa ...

  6. CentOS 7离线安装CDH 5.16.1完全指南(含各种错误处理)

    安装包下载 1.CM软件包下载 从http://archive.cloudera.com/cm5/redhat/7/x86_64/cm/5.16.1/RPMS/x86_64/下载rpm包,如下: 其实 ...

  7. js去除数组里重复的条目,返回被删除的条目的新数组

    我爱撸码,撸码使我感到快乐! 大家好,我是Counter. 今天给大家分享的是利用js进行数组的去重,还是老样子,该注释的都注释在代码里了 欢迎一起技术探讨,一起成长. 效果如下: 代码给出: // ...

  8. pam密码策略

    PAM 的使用历史 PAM 是关注如何为服务验证用户的 API.在使用 PAM 之前,诸如 login(和 rlogin.telnet.rsh)之类的应用程序在 /etc/passwd 中查找用户名, ...

  9. 面试被问之-----sql优化中in与exists的区别

    曾经一次去面试,被问及in与exists的区别,记得当时是这么回答的:''in后面接子查询或者(xx,xx,xx,,,),exists后面需要一个true或者false的结果",当然这么说也 ...

  10. 大数据Hadoop——初识Hadoop

    Hadoop简介 官方网站:  http://hadoop.apache.org/ 中文网站:  http://hadoop.apache.org/docs/r1.0.4/cn/ Hadoop设计来源 ...