How to get the entry point of a target like the one in --stop-at-entry


LLDB has provided an option to –stop-at-entry. I would like to

Get the address of this entry point by a way. I checked API

I didn’t found a function that could get this information. Could

Anyone help me on this?



lldb doesn't implement "stop at entry" by putting a breakpoint on some function and hitting it. Traditionally on ptrace based systems this was implemented using the "PT_TRACEME" ptrace argument run in the child side of the fork that will create the target process, and on MacOS X, we use a posix_spawn option to start a process suspended that does basically the same thing.

So we don't know in advance where this entry point will be. We just tell the OS to start the target suspended and then assume when it starts, that's where it is...

I note that in one place (following exec's on OS X) we hard code the knowledge that _dyld_start is where "start suspended" is expected to end up. That's informally done there, it's not a property of the dynamic linker plugin. If this is generally determinable in advance, we could make this an API on the dynamic linker plugin.

Anyway, maybe we could be more help if we knew why you wanted to know this.


Hi Jim,

In gdb, after an executable is loaded, if you run
Info target, it will tell the information of its entry point.
I believe the Mach-O/ELF/PE should have this defined so OS
Knows where to start the text section.

Our debugger GUI uses this information to help users do
Better to analyze an executable in assembly level when
Debugger symbol is not available. So I am wondering if lldb can
provide this information also by some ways.



Ah, turns out you are asking a slightly different question there. You want the entry point of the code in an object file, which isn't actually where "process launch --stop-at-entry" will stop you. The -stop-at-entry actually stops before the first instruction of the program is executed - which is usually well before the entry point (e.g. main) of an object file.

Anyway, there is an API - ObjectFile::GetEntryPointAddress that will return the "place the dynamic loader will jump to when it starts to execute code from a main executable." It isn't currently available through the SB API's, but it would be trivial to make it available. Feel free to do this if you need it.


Hi Jim,

Thank you for the reply. I don't know there is the difference
Between -stop-at-entry address and entry point address. I originally
thought stop at entry would stop at entry point address.

Could provide me a basic flow about how make it available to python API.
I need to use the python script way instead of linked way. When I google this
issue, I found a patch about GetEntryPointAddress function. However,
I don't have idea how to bring it to python with any prebuilt lldb.



Internally ObjectFile has:

    virtual lldb_private::Address
    GetEntryPointAddress ();

If you want this externally, you will want to add it to the SBModule:

class SBModule {



This isn't currently exposed, but it could easily be.