C++

RTT 编译动态模块mo或lib, 如果有析构函数, 会出错

发布于 2021-03-12 10:01:39    浏览:266

修改了示例仓中的
rtthread-apps
cxx
仅添加了class A的析构函数, 无论编译成 mo还是 so 都会报错
mo 编译完成后,没有任何打印信息
而编译的so, dlopen的时候就会提示打开so失败
请问是什么原因?

查看更多

2 个回答
lt6210925
lt6210925 认证专家 2021-03-19
This guy hasn't written anything yet

可以贴一下错误截图看下

EZQQ_1775
EZQQ_1775 2021-03-22
This guy hasn't written anything yet

1.带析构函数:

dlmodule_load file: /sdcard/cxx.so, fd: 8
dlmodule_load file: /sdcard/cxx.so, length: 2592
rt_module_load: cxx, e_type: 3
dlmodule_load_shared_object.
LOAD segment: 1, 0x000000b0, 0x000005ec
LOAD segment: 2, 0x0000069c, 0x000000bc
module size: 1704, vstart_addr: 0x000000b0
relocate symbol _ZN1AC1Ev shndx 7
relocate symbol __cxa_end_cleanup shndx 0
relocate symbol: __cxa_end_cleanup
Module: can't find __cxa_end_cleanup in kernel symbol table
relocate symbol _ZN1A4setAEi shndx 7
relocate symbol rt_kprintf shndx 0
relocate symbol: rt_kprintf
relocate symbol _Z5Atestv shndx 7
relocate symbol _ZN1A8toStringEv shndx 7
relocate symbol _ZN1AD1Ev shndx 7
dlmodule_load finish ret: -1
dlopen /sdcard/cxx.so failed!
  1. 无虚构函数,正常编译的c++ so,dlopen能打开,但无法找到符号.

函数为 main_xx, 然后dlopen, 找不到此符号, 匹配时, 符号表里面是 _Z7main_xxv

详细log:

msh />dlmodule_sample
open file:/sdcard/cxx.so
open in filesystem:elm
Actual file path: /cxx.so
open successful
dlmodule_load file: /sdcard/cxx.so, fd: 6
dlmodule_load file: /sdcard/cxx.so, length: 2140
rt_module_load: cxx, e_type: 3
dlmodule_load_shared_object.
LOAD segment: 1, 0x000000a0, 0x000004ac
LOAD segment: 2, 0x0000054c, 0x00000090
module size: 1340, vstart_addr: 0x000000a0
relocate symbol _ZN1AC1Ev shndx 5
relocate symbol _ZN1A4setAEi shndx 5
relocate symbol rt_kprintf shndx 0
relocate symbol: rt_kprintf
relocate symbol _Z5Atestv shndx 5
relocate symbol _ZN1A8toStringEv shndx 5
dlmodule_load finish ret: 0
dlsym dst symbol: module_init
dlsym compare table name: _ZN1AC2Ev
dlsym compare table name: _ZN1AC1Ev
dlsym compare table name: _ZN1A4setAEi
dlsym compare table name: _Z5Atestv
dlsym compare table name: _ZN1A4getAEv
dlsym compare table name: _ZN1A8toStringEv
dlsym compare table name: _Z7main_xxv
dlsym dst symbol: module_cleanup
dlsym compare table name: _ZN1AC2Ev
dlsym compare table name: _ZN1AC1Ev
dlsym compare table name: _ZN1A4setAEi
dlsym compare table name: _Z5Atestv
dlsym compare table name: _ZN1A4getAEv
dlsym compare table name: _ZN1A8toStringEv
dlsym compare table name: _Z7main_xxv
dlsym dst symbol: main_xx
dlsym compare table name: _ZN1AC2Ev
dlsym compare table name: _ZN1AC1Ev
dlsym compare table name: _ZN1A4setAEi
dlsym compare table name: _Z5Atestv
dlsym compare table name: _ZN1A4getAEv
dlsym compare table name: _ZN1A8toStringEv
dlsym compare table name: _Z7main_xxv
dlsym 20061398 failed!

撰写答案

请登录后再发布答案,点击登录
关注者
0
被浏览
266

发布
问题

分享
好友

手机
浏览

扫码手机浏览