[lldb-dev] [RFC] Extend ObjectFile interface.

Stephen Wilson wilsons at start.ca
Wed Jan 12 14:20:49 PST 2011


Greg Clayton <gclayton at apple.com> writes:
> On Jan 11, 2011, at 8:17 PM, Stephen Wilson wrote:
[snip]
>> The second bit is to provide the DynamicLoader plugin with a method to
>> synchronize with the runtime linker.  A simple strategy is to set a
>> breakpoint on the entry address for the executable and to parse the
>> rendezvous structure after the linker has had a chance to populate it.
>> Hence the following addition:
>> 
>>    //------------------------------------------------------------------
>>    /// Returns the virtual address of the entry point for this object 
>>    /// file.
>>    ///
>>    /// @return
>>    ///     The virtual address of the entry point or 
>>    ///     LLDB_INVALID_ADDRESS if an entry point is not defined.
>>    //------------------------------------------------------------------
>>    virtual lldb::addr_t
>>    GetEntryPoint () const { return LLDB_INVALID_ADDRESS; }
>> 
>> 
>> The above two methods are enough to get a minimal DynamicLoader plugin
>> functioning on Linux.  I would very much appreciate any
>> feedback/comments on the above.
>
> I would rather see this added as:
>
>    virtual Address
>    GetEntryPoint () const { return Address(); }
>
> So that you know what module the entry point came from. The linux
> dynamic loader would then just know that the file and load addresses
> for a linux executable (not shared library, just executable files) are
> the same (is this true? Do the virtual addresses in the ELF file for
> an executable never change?) and it could get the entry point as an
> addr_t by doing:

OK, using an Address does make sense.  One issue that I have not sorted
out yet is how to deal with position independent executable (so yes, the
virtual addresses in the ELF file for an executable can change in this
case).  I will try to have initial support for PIE's in the preliminary
DynamicLoader plugin.

> ModuleSP exe_module_sp (target->GetExecutableModule ());
> if (exe_module_sp)
> {
> 	ObjectFile *exe_objfile = exe_module_sp->GetObjectFile();
> 	if (exe_objfile)
> 	{
> 		Address entry_point (exe_objfile->GetEntryPoint());
> 		addr_t entry_point_load_addr = entry_point.GetFileAddress();
> 	}
> }
>
> The other thing you might want to do, is in the linix dynamic loader
> plug-in, if you know that the executable is always at the same address
> as the virtual addresses in the file, you can automatically register
> the load address of the sections as soon as you construct the
> DynamicLoaderLinux object. Because when setting a breakoint, it will
> eventually turn into a section/offset breakpoint and the breakpoint
> won't set itself until the section gets loaded.

Currently I am waiting until the process is launched or attached before
updating the section load lists -- will adjust.


Thanks so much for your input!

> Let me know if you have any questions on this.
>
> Greg Clayton
>

--
steve



More information about the lldb-dev mailing list