将函数签名从编译器语言转换为 c++
大家好,我需要列出链接器输出中列出的一些函数。我得到的语法如下:
int foo(int num,double dnum, Temp & temp) (in namespace "funcsns")
变成:
.text._ZN7funcsns3fooEidRNS_4TempE
(您可能从“未定义符号”和打印函数名称的其他一些链接错误中知道它)
现在,我可以编写一个脚本以某种方式将其转换变成一些可读的东西,但我想知道是否有一种智能的方法来做到这一点。
请分享您的想法!
谢谢。
Hey guys, I need to make a list of some functions that are listed in the linker output. The syntax i get is as follows:
int foo(int num,double dnum, Temp & temp) (in namespace "funcsns")
Turns into:
.text._ZN7funcsns3fooEidRNS_4TempE
(You might know it from the "undefined symbol" and some other linking errors that print functions names)
Now, i can write a script that somehow turns it into something readable but i wonder if there is a smart way of doing it.
Please share your ideas!
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在使用 GNU 工具链的系统上,
c++filt
程序正是您所寻找的。它是“binutils”包的一部分。不知道其他系统。“.text”。不是损坏名称的一部分。运行
c++filt _ZN7funcsns3fooEidRNS_4TempE
会产生funcsns::foo(int, double, funcsns::Temp&)
。On a system using the GNU toolchain, the
c++filt
program does exactly what you're looking for. It's part of the "binutils" package. Dunno about other systems.The ".text." isn't part of the mangled name. Running
c++filt _ZN7funcsns3fooEidRNS_4TempE
yieldsfuncsns::foo(int, double, funcsns::Temp&)
.这称为装饰或名称修改。以下是有关它如何适用于各种编译器的一些信息
http://www.kegel.com/mangle.html< /a>
This is called decoration or name mangling. Here is some information on how it works for various compilers
http://www.kegel.com/mangle.html
正如其他人指出的,
c++filt
是 GNU 工具链的最佳选择。这也可以通过编程方式完成(甚至可以从 C 程序):参见
abi::__cxa_demangle
(这实际上是c++filt
的作用)。As indicated by other,
c++filt
is the way to go for the GNU toolchain.This can also be done programmaticaly (even from a C program) : see
abi::__cxa_demangle
(which is actually whatc++filt
does).Visual Studio 提供的 undname 实用程序(至少我当前使用的 VC2005)与 microsoft Visual C++ 的 c++filt 的作用相同
The undname utility provided with visual studio (At least VC2005 that I'm currently using) does the same as c++filt for microsoft visual c++