简体   繁体   English

获取 llvm::module 的入口点

[英]Get entry point of llvm::module

I've parsed a bitcode file with llvm::parseBitcodeFile and I've got the llvm::Module , I can iterate over the functions of the module:我已经用llvm::parseBitcodeFile解析了一个位码文件,并且得到了llvm::Module ,我可以迭代模块的功能:

std::unique_ptr<llvm::Module>& M = *parsed;
for(auto& func : M->functions())
{
    // how to identify the entry point?
}

And I would like to identify the entry point of the module (and thus of the application - if there are multiple modules, one of them should have an entry point..) , but I wasn't able to find anything in func to do that, what would be the proper way to identify the entry point?而且我想确定模块的入口点(以及应用程序的入口点 - 如果有多个模块,其中一个应该有一个入口点..),但我无法在func中找到任何事情要做那,识别入口点的正确方法是什么? (In most cases it will be the main function, so looking for the name seems to work, but not always). (在大多数情况下,它将是main功能,因此查找名称似乎可行,但并非总是如此)。

More generically, I'm looking for a way to find the entry point (if any - perhaps main ) of a/many bitcode file that I'm given..更一般地说,我正在寻找一种方法来找到我得到的一个/许多位码文件的入口点(如果有的话 - 也许是main )。

There is no "entry point" in a LLVM Module. LLVM 模块中没有“入口点”。 Entry point is a feature of an application and could be very different depending on eg source language, etc. Also, since LLVM Module represents somehow a translation unit there might be no "main function at all.入口点是应用程序的一项功能,并且可能因源语言等而有很大不同。此外,由于 LLVM 模块以某种方式代表翻译单元,因此可能根本没有“主要功能”。

If you happen to know the name of the function you're looking for, then you can certainly use Module::getFunction call to perform name-based lookup.如果您碰巧知道要查找的函数的名称,那么您当然可以使用Module::getFunction调用来执行基于名称的查找。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM