防止 IBM Visual Age C/C++ 中的符号被剥离对于 AIX

发布于 2024-08-31 07:26:48 字数 637 浏览 10 评论 0原文

我正在构建一个共享库,我使用 IBM 的 VisualAge C/C++ 编译器将其动态加载(使用 dlopen)到我的 AIX 应用程序中。不幸的是,它似乎删除了必要的符号:

rtld: 0712-002 fatal error: exiting.
rtld: 0712-001 Symbol setVersion__Q2_3CIF17VersionReporterFRCQ2_3std12basic_stringXTcTQ2_3std11char_traitsXTc_TQ2_3std9allocatorXTc__ was referenced
from module ./object/AIX-6.1-ppc/plugins/plugin.so(), but a runtime definition
of the symbol was not found.

共享库和加载共享库的应用程序都针对包含错误消息中提到的 VersionReporter 的静态库进行编译/链接。

要链接共享库,我使用以下选项:-bM:SRE -bnoentry -bexpall 要链接应用程序,我使用此选项: -brtl

是否有一个选项可以用来防止此符号在应用程序中被删除?我尝试过使用 IBM 文档中所述的 -nogc ,但这会导致共享库格式无效或应用程序无法链接(取决于我将其与哪一个一起使用)。

I'm building a shared library which I dynamically load (using dlopen) into my AIX application using IBM's VisualAge C/C++ compiler. Unfortunately, it appears to be stripping out necessary symbols:

rtld: 0712-002 fatal error: exiting.
rtld: 0712-001 Symbol setVersion__Q2_3CIF17VersionReporterFRCQ2_3std12basic_stringXTcTQ2_3std11char_traitsXTc_TQ2_3std9allocatorXTc__ was referenced
from module ./object/AIX-6.1-ppc/plugins/plugin.so(), but a runtime definition
of the symbol was not found.

Both the shared library and the application which loads the shared library compile/link against the static library which contains the VersionReporter mentioned in the error message.

To link the shared library I'm using these options: -bM:SRE -bnoentry -bexpall
To link the application, I'm using this option: -brtl

Is there an option I can use to prevent this symbol from being stripped in the application? I've tried using -nogc as stated in the IBM docs, but that causes the shared library to be in an invalid format or the application to fail to link (depending on which one I use it with).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

匿名的好友 2024-09-07 07:26:48

是的。这与特定语言或编译器没有真正的联系。例如,相同的通用技术也用于 gcc。 -bI:foo.exp 用于告诉链接器 foo.exp 中列出的符号将来自顶部的名称。同样,-BE:dog.exp 用于告诉链接器,dog.exp 中列出的符号已导出并可供其他人使用。

您可以看到 /bin/ldd 和 /bin/dump 可用于查看这些符号。

Yes. This is not really connected to a particular language or compiler. The same general technique is used for gcc for example. -bI:foo.exp is used to tell the linker that the symbols listed in foo.exp will come from the name at the top. Likewise, -BE:dog.exp is used to tell the linker that the symbols listed in dog.exp are exported and can be used by others.

You can see /bin/ldd and /bin/dump can be used to review these symbols.

醉殇 2024-09-07 07:26:48

我想通了。诀窍是使用导出列表,以便插件中使用但二进制文件中未使用的符号不会被删除。

# version.exp:
setVersion__Q2_3CIF17VersionReporterFRCQ2_3std12basic_stringXTcTQ2_3std11char_traitsXTc_TQ2_3std9allocatorXTc__

然后在链接应用程序时使用: -brtl -bexpfull -bE:version.exp

这里有更多信息: 在 AIX 上开发和移植 C 和 C++ 应用程序

I figured this out. The trick is to use an export list so that symbols used in the plugin but not used in the binary aren't stripped out.

# version.exp:
setVersion__Q2_3CIF17VersionReporterFRCQ2_3std12basic_stringXTcTQ2_3std11char_traitsXTc_TQ2_3std9allocatorXTc__

And then when linking the application use: -brtl -bexpfull -bE:version.exp

There's more information here: Developing and Porting C and C++ Applications on AIX.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文