C++ name mangling
来源:互联网 发布:大螺距螺纹编程实例 编辑:程序博客网 时间:2024/06/05 09:25
a couple days ago, the boss asked me to convert a C++ project from X86 to X86_64. I thought it is easy for me, just do two the following steps:
- 1. replace all of the x86 libraries (SO)to their counterparts of x86_64
- 2. change the compile option from -m32 to -m 64
After that, I tried to make the project. it ended with the following error: libcommonldap.so: undefined reference to `NewDecryptStr(char*, unsigned int)
It is a usual link error. Using objdump to check if this symbol is there.
[root@centos src]# objdump -t output/libsupport.so | grep NewD
00000000000123af g F .text 00000000000000e7 _Z13NewDecryptStrPcm
Yes, it is there. but why ld can not find it? I konw the symbol _Z13NewDecryptStrPcjis what I wanted. The wired name is caused by c++ name mangling. But why the ld does not recognize it? What the ld really wants? Using objdump again to check:
[root@centos src]# objdump -t output/libcommonldap.so | grep NewD
0000000000000000 *UND*0000000000000000 _Z13NewDecryptStrPcj
int NewDecryptStr(char *sEncryptedPassword, const size_t sizeof_sEncryptedPassword)
I decoded the two symbols as follows:
NewDecryptStr(char*, unsigned long)
[root@centos commonsource]# c++filt _Z13NewDecryptStrPcj
NewDecryptStr(char*, unsigned int)
[root@centos commonsource]#
#ifndef size_t#define size_t unsigned int#endif
It is true for x86, but for x86_64, size_t should be ULONG. This is the reason
- name mangling & extern "C"
- Name Mangling
- Name Mangling
- Name Mangling
- C++中Name-mangling
- C++中Name-mangling
- Name-mangling(转)
- Name Mangling in C++
- name mangling
- Name Mangling in C++
- Name Mangling in C++
- C++ name mangling
- Name Mangling in C++
- Name Mangling in C++
- Name Mangling in C++
- Name Mangling in C++
- C++中的name mangling
- C++ name mangling
- 算法题目一:全排列(C++实现)
- [Django1.5]'url' requires a non-empty first argument. 错误
- 野指针
- Tomcat 报“ IOException while loading persisted sessions:”异常解决方法
- 将Flash 嵌入WPF 程序
- C++ name mangling
- HTML代码用例
- Android 4.0 中由ProGuard引发的一场血案
- 黑马程序员--java的classpath
- 算法题目二:寻找最长重复子序列(1) trie树
- JPA实体注解与hibernate主键生成策略
- UNICODE, GBK, UTF-8区别
- 如何学习linux编程
- sqlplus命令