--unresolved-symbols=ignore-in-shared-libs 和 --allow-shlib-undefined 标志之间有什么区别

What's the difference between --unresolved-symbols=ignore-in-shared-libs and --allow-shlib-undefined flags

以下链接器 (ld) 标志之间的区别是什么:

--unresolved-symbols=ignore-in-shared-libs

--allow-shlib-undefined

?

作为后续跟进,此命名法中未解析符号和未定义符号之间有什么区别?

链接器选项:

--unresolved-symbols=method

让您可以为链接器指定 4 个不同标准(方法)中的任何一个 报告或忽略链接中未解析的符号引用。 The manual 说:

--unresolved-symbols=method

Determine how to handle unresolved symbols. There are four possible values for ‘method’:

‘ignore-all’

   Do not report any unresolved symbols.

‘report-all’

   Report all unresolved symbols. This is the default.

‘ignore-in-object-files’

   Report unresolved symbols that are contained in shared libraries, but ignore them if they come from regular object files.

‘ignore-in-shared-libs’

   Report unresolved symbols that come from regular object files, but ignore them if they come from shared libraries. This can be useful when creating a dynamic binary and it is known that all the shared libraries that it should be referencing are included on the linker’s command line.

The behaviour for shared libraries on their own can also be controlled by the --[no-]allow-shlib-undefined option.

Normally the linker will generate an error message for each reported unresolved symbol but the option --warn-unresolved-symbols can change this to a warning.

正如我强调的句子所示,链接器选项:

--allow-shlib-undefined

只是简写:

--unresolved-symbols=ignore-in-shared-libs

在此上下文中,undefinedunresolved 的含义没有区别: 差异的建议只是这个古老工具的一部分。