[llvm-dev] Finding the entry point function in a LLVM IR

David Chisnall via llvm-dev llvm-dev at lists.llvm.org
Mon Oct 23 01:03:38 PDT 2017


On 21 Oct 2017, at 12:51, mohie pokhriyal via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> I want to be able to find out that main is the entry point function of the program. 
> main and boo both do not have any predecessors or successors , such that I can make a cfg to figure out who’s calling whom ?
> 
> Is there a way I can achieve this ?

The fact that main is the entry point is not known to LLVM (except in a couple of places that special-case main, such as the internalise pass), because it is an artefact of C/C++, not a generic property.  On most *NIX platforms, the real entry point for a program is something like __start or _start, which then call main.  In most compilation units, there is no single entry point, because they do not contain the program entry point and so can be entered by any externally visible function.

It might help if you explained why you need this.

David



More information about the llvm-dev mailing list