From the documentation's description, they seem to do the same thing except that "not all systems" support shared and "only some systems" support symbolic (it's unclear if these are the same set of systems):
从文档的描述中,他们似乎做了同样的事情,除了“并非所有系统”支持共享和“只有一些系统”支持符号(不清楚这些是否是同一组系统):
-shared Produce a shared object which can then be linked with other objects to form an executable. Not all systems support this option. For predictable results, you must also specify the same set of options that were used to generate code (-fpic, -fPIC, or model suboptions) when you specify this option.[1]
-shared生成一个共享对象,然后可以将其与其他对象链接以形成可执行文件。并非所有系统都支持此选项。对于可预测的结果,还必须指定在指定此选项时用于生成代码(-fpic,-fPIC或模型子选项)的同一组选项。[1]
-symbolic Bind references to global symbols when building a shared object. Warn about any unresolved references (unless overridden by the link editor option -Xlinker -z -Xlinker defs). Only a few systems support this option.
-symbolic在构建共享对象时绑定对全局符号的引用。警告任何未解析的引用(除非被链接编辑器选项-Xlinker -z -Xlinker defs覆盖)。只有少数系统支持此选项。
I suspect the difference is in the "Produce a shared object which can then be linked with other objects to form an executable" part, but that sounds like something that is true of any library. Does it mean that the resulting shared object can be linked statically too?
我怀疑区别在于“生成一个共享对象,然后可以与其他对象链接以形成可执行文件”部分,但这听起来像任何库都是如此。这是否意味着生成的共享对象也可以静态链接?
1 个解决方案
#1
6
Summary: -symbolic prevents intra-shared object function interposition
摘要:-symbolic防止内部共享对象功能插入
Linking with shared objects allows for a feature called symbol interposition. The idea is that you can 'interpose' a new definition of a global symbol so that it is called rather then the 'regular' definition.
与共享对象链接允许称为符号插入的功能。我们的想法是,您可以“插入”全局符号的新定义,以便调用它而不是“常规”定义。
One classic example is malloc(). In the most common case, malloc() is defined within libc. But you can interpose your own version of malloc by loading a library that defines that symbol before you load libc (most runtime linkers allow you to use LD_PRELOAD to specific libraries to load before the executable).
一个典型的例子是malloc()。在最常见的情况下,malloc()在libc中定义。但是,您可以通过在加载libc之前加载定义该符号的库来插入您自己的malloc版本(大多数运行时链接器允许您在可执行文件之前使用LD_PRELOAD来加载特定的库)。
By default, any function within a shared object that is not static is a global symbol. Because of that, any functions within the shared object can be interposed on. Consider a scenario where a shared object has function high_level() and low_level() and high_level() calls low_level() as part of it's implementation and neither high_level() nor low_level() are static functions.
默认情况下,共享对象中非静态的任何函数都是全局符号。因此,可以插入共享对象中的任何函数。考虑一个场景,其*享对象具有函数high_level()和low_level()以及high_level()调用low_level()作为其实现的一部分,并且high_level()和low_level()都不是静态函数。
It's possible to interpose low_level() such that high_level() is calling a low_level() from a different shared object.
可以插入low_level(),以便high_level()从另一个共享对象调用low_level()。
This is where -symbolic comes in. When creating your shared object, the linker will see that low_level() is defined in the same shared object as high_level() and bind the call such that it can't be interposed on. This way, you know that any calls from one function in your shared object to another in the same shared object will never be interposed on.
这就是-symbolic的用武之地。在创建共享对象时,链接器将看到low_level()在与high_level()相同的共享对象中定义,并绑定调用,使其无法插入。这样,您就知道从共享对象中的一个函数到同一共享对象中的另一个函数的任何调用都不会被插入。
#1
6
Summary: -symbolic prevents intra-shared object function interposition
摘要:-symbolic防止内部共享对象功能插入
Linking with shared objects allows for a feature called symbol interposition. The idea is that you can 'interpose' a new definition of a global symbol so that it is called rather then the 'regular' definition.
与共享对象链接允许称为符号插入的功能。我们的想法是,您可以“插入”全局符号的新定义,以便调用它而不是“常规”定义。
One classic example is malloc(). In the most common case, malloc() is defined within libc. But you can interpose your own version of malloc by loading a library that defines that symbol before you load libc (most runtime linkers allow you to use LD_PRELOAD to specific libraries to load before the executable).
一个典型的例子是malloc()。在最常见的情况下,malloc()在libc中定义。但是,您可以通过在加载libc之前加载定义该符号的库来插入您自己的malloc版本(大多数运行时链接器允许您在可执行文件之前使用LD_PRELOAD来加载特定的库)。
By default, any function within a shared object that is not static is a global symbol. Because of that, any functions within the shared object can be interposed on. Consider a scenario where a shared object has function high_level() and low_level() and high_level() calls low_level() as part of it's implementation and neither high_level() nor low_level() are static functions.
默认情况下,共享对象中非静态的任何函数都是全局符号。因此,可以插入共享对象中的任何函数。考虑一个场景,其*享对象具有函数high_level()和low_level()以及high_level()调用low_level()作为其实现的一部分,并且high_level()和low_level()都不是静态函数。
It's possible to interpose low_level() such that high_level() is calling a low_level() from a different shared object.
可以插入low_level(),以便high_level()从另一个共享对象调用low_level()。
This is where -symbolic comes in. When creating your shared object, the linker will see that low_level() is defined in the same shared object as high_level() and bind the call such that it can't be interposed on. This way, you know that any calls from one function in your shared object to another in the same shared object will never be interposed on.
这就是-symbolic的用武之地。在创建共享对象时,链接器将看到low_level()在与high_level()相同的共享对象中定义,并绑定调用,使其无法插入。这样,您就知道从共享对象中的一个函数到同一共享对象中的另一个函数的任何调用都不会被插入。