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

标签 linker ld elf

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

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

--allow-shlib-未定义

?

作为跟进,此命名法中未解析的符号和 undefined symbol 之间有什么区别?

最佳答案

链接器选项:

--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
undefined之间的意思没有区别和 unresolved在这种情况下:
差异的建议只是这个古老工具的一部分。

关于linker - --unresolved-symbols=ignore-in-shared-libs 和 --allow-shlib-undefined 标志有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55928308/

相关文章:

c++ - Node-expat 错误的 ELF 类 : ELFCLASS64

c++ - 修改程序入口点时未调用全局变量的构造函数

c++ - 未定义引用 [USRP] [UHD]

c - 如何查看 .bss 中静态变量的内存位置?

c++ - 如果仍然可以间接执行(通过回调函数),将 C 函数声明为静态函数是不好的做法吗?

Linux ld : What's the meaning of `-m` option and the command `ld -melf_32 -Ttext 0 -e startup_32`

linux - 使用 Linux binutils 设置 ELF 镜像基地址的优雅方法?

elf - 使用 binutils/readelf 确定符号地址

c - 如何让gcc只生成可以直接加载到内存中执行的机器码?

在C文件中执行嵌入式lua编译错误