尝试在 Solaris i86 中创建共享对象时出现奇怪的问题

发布于 2024-11-14 17:39:39 字数 3422 浏览 2 评论 0原文

我正在尝试在solaris中创建一个共享对象.so文件,这些是我正在执行的以下步骤...

  1. 我有一个源代码jags...如果我们尝试构建它将生成一个可执行文件..下面是创建该命令
g++ -g -O2 -o .libs/jags-terminal jags_terminal-parser.o jags_terminal-scanner.o jags_terminal-ReadData.o .libs/jags-terminalS.o  /JAGS-2.2.0/libltdl/./.libs/dlopen.a ../../libltdl/.libs/libltdlc.a ../../src/lib/.libs/libjags.so -L/usr/sfw/lib /usr/sfw/lib/libstdc++.so -lgcc_s -lm -Wl,-R -Wl,/usr/local/lib -Wl,-R -Wl,/usr/sfw/lib
  1. 现在我正在尝试使用相同的流程创建一个共享对象,该命令有点像
g++ -shared -o .libs/libjagsterminal.so jags_terminal-parser.o jags_terminal-scanner.o jags_terminal-ReadData.o .libs/jags-terminalS.o  /JAGS-2.2.0/libltdl/./.libs/dlopen.a ../../libltdl/.libs/libltdlc.a ../../src/lib/.libs/libjags.so -L/usr/sfw/lib /usr/sfw/lib/libstdc++.so -lgcc_s -lm -Wl,-R -Wl,/usr/local/lib -Wl,-R -Wl,/usr/sfw/lib

下面这样,这是执行上面一行后出现的问题。

std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)0x3ea      jags_terminal-ReadData.o
_Unwind_Resume                      0x4f9       jags_terminal-parser.o
_Unwind_Resume                      0x61f       jags_terminal-parser.o
_Unwind_Resume                      0xae7       jags_terminal-parser.o
_Unwind_Resume                      0xc0d       jags_terminal-parser.o
_Unwind_Resume                      0xe5f       jags_terminal-parser.o
_Unwind_Resume                      0xf7f       jags_terminal-parser.o
_Unwind_Resume                      0x10cf      jags_terminal-parser.o
_Unwind_Resume                      0x1371      jags_terminal-parser.o
_Unwind_Resume                      0x1a9b      jags_terminal-parser.o
_Unwind_Resume                      0x24f0      jags_terminal-parser.o
_Unwind_Resume                      0x2a95      jags_terminal-parser.o
_Unwind_Resume                      0x341a      jags_terminal-parser.o
_Unwind_Resume                      0x377a      jags_terminal-parser.o
_Unwind_Resume                      0x579c      jags_terminal-parser.o
_Unwind_Resume                      0x7021      jags_terminal-parser.o
_Unwind_Resume                      0x7417      jags_terminal-parser.o
_Unwind_Resume                      0x1169      jags_terminal-scanner.o
_Unwind_Resume                      0x17e0      jags_terminal-scanner.o
_Unwind_Resume                      0x685       jags_terminal-ReadData.o
_Unwind_Resume                      0x68e       jags_terminal-ReadData.o
_Unwind_Resume                      0x47        jags_terminal-parser.o
_Unwind_Resume                      0x79        jags_terminal-parser.o
_Unwind_Resume                      0x60        jags_terminal-parser.o
_Unwind_Resume                      0xd3        jags_terminal-parser.o
_Unwind_Resume                      0x33a       jags_terminal-parser.o
_Unwind_Resume                      0x3bc       jags_terminal-parser.o
_Unwind_Resume                      0x1dd       jags_terminal-parser.o
_Unwind_Resume                      0x299       jags_terminal-parser.o
_Unwind_Resume                      0x179       jags_terminal-parser.o
_Unwind_Resume                      0x87        jags_terminal-parser.o
_Unwind_Resume                      0x145       jags_terminal-parser.o
_Unwind_Resume                      0xb4        jags_terminal-ReadData.o
ld: fatal: relocations remain against allocatable but non-writable sections
collect2: ld returned 1 exit status

I am trying to create a shared object .so file in solaris these are the below steps which i am doing...

  1. I have a source code jags... if we try to build that it will generate an executable file.. below is the command to create that
g++ -g -O2 -o .libs/jags-terminal jags_terminal-parser.o jags_terminal-scanner.o jags_terminal-ReadData.o .libs/jags-terminalS.o  /JAGS-2.2.0/libltdl/./.libs/dlopen.a ../../libltdl/.libs/libltdlc.a ../../src/lib/.libs/libjags.so -L/usr/sfw/lib /usr/sfw/lib/libstdc++.so -lgcc_s -lm -Wl,-R -Wl,/usr/local/lib -Wl,-R -Wl,/usr/sfw/lib
  1. Now i am trying to create a shared object using same flow changed the command a little bit like this
g++ -shared -o .libs/libjagsterminal.so jags_terminal-parser.o jags_terminal-scanner.o jags_terminal-ReadData.o .libs/jags-terminalS.o  /JAGS-2.2.0/libltdl/./.libs/dlopen.a ../../libltdl/.libs/libltdlc.a ../../src/lib/.libs/libjags.so -L/usr/sfw/lib /usr/sfw/lib/libstdc++.so -lgcc_s -lm -Wl,-R -Wl,/usr/local/lib -Wl,-R -Wl,/usr/sfw/lib

below is the the problem after executiing above line..

std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)0x3ea      jags_terminal-ReadData.o
_Unwind_Resume                      0x4f9       jags_terminal-parser.o
_Unwind_Resume                      0x61f       jags_terminal-parser.o
_Unwind_Resume                      0xae7       jags_terminal-parser.o
_Unwind_Resume                      0xc0d       jags_terminal-parser.o
_Unwind_Resume                      0xe5f       jags_terminal-parser.o
_Unwind_Resume                      0xf7f       jags_terminal-parser.o
_Unwind_Resume                      0x10cf      jags_terminal-parser.o
_Unwind_Resume                      0x1371      jags_terminal-parser.o
_Unwind_Resume                      0x1a9b      jags_terminal-parser.o
_Unwind_Resume                      0x24f0      jags_terminal-parser.o
_Unwind_Resume                      0x2a95      jags_terminal-parser.o
_Unwind_Resume                      0x341a      jags_terminal-parser.o
_Unwind_Resume                      0x377a      jags_terminal-parser.o
_Unwind_Resume                      0x579c      jags_terminal-parser.o
_Unwind_Resume                      0x7021      jags_terminal-parser.o
_Unwind_Resume                      0x7417      jags_terminal-parser.o
_Unwind_Resume                      0x1169      jags_terminal-scanner.o
_Unwind_Resume                      0x17e0      jags_terminal-scanner.o
_Unwind_Resume                      0x685       jags_terminal-ReadData.o
_Unwind_Resume                      0x68e       jags_terminal-ReadData.o
_Unwind_Resume                      0x47        jags_terminal-parser.o
_Unwind_Resume                      0x79        jags_terminal-parser.o
_Unwind_Resume                      0x60        jags_terminal-parser.o
_Unwind_Resume                      0xd3        jags_terminal-parser.o
_Unwind_Resume                      0x33a       jags_terminal-parser.o
_Unwind_Resume                      0x3bc       jags_terminal-parser.o
_Unwind_Resume                      0x1dd       jags_terminal-parser.o
_Unwind_Resume                      0x299       jags_terminal-parser.o
_Unwind_Resume                      0x179       jags_terminal-parser.o
_Unwind_Resume                      0x87        jags_terminal-parser.o
_Unwind_Resume                      0x145       jags_terminal-parser.o
_Unwind_Resume                      0xb4        jags_terminal-ReadData.o
ld: fatal: relocations remain against allocatable but non-writable sections
collect2: ld returned 1 exit status

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

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

发布评论

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

评论(2

短暂陪伴 2024-11-21 17:39:39

如果 gcc 使用 /usr/ccs/bin/ld 则将 -shared 替换为 -G

If gcc uses /usr/ccs/bin/ld then replace -shared with -G

找回味觉 2024-11-21 17:39:39

需要构建共享对象位置无关,因此您要添加 -fPIC 标志到 GCC 调用。

Shared objects need to be build position-independent, so you want to add the -fPIC flag to GCC invocation.

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