[Lldb-commits] [PATCH] Support indirect dyld link information (used on MIPS)

Greg Clayton gclayton at apple.com
Thu Oct 10 12:55:30 PDT 2013


Since "indirect" is required, we should probably make it a reference instead of a pointer so no one has to NULL check "indirect". You will need to update all of the other ObjectFilePlugins (machO, COFF, etc).

On Oct 10, 2013, at 11:52 AM, Ed Maste <emaste at freebsd.org> wrote:

> MIPS's .dyanamic section is read-only, and so instead of using DT_DEBUG it uses a separate field DT_MIPS_RLD_MAP which points to storage in the RW .rld_map section, which in turn points to the dyld information.
> 
> http://llvm-reviews.chandlerc.com/D1890
> 
> Files:
>  include/lldb/Symbol/ObjectFile.h
>  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
>  source/Plugins/ObjectFile/ELF/ObjectFileELF.h
>  source/Plugins/Process/POSIX/ProcessPOSIX.cpp
>  source/Plugins/Process/elf-core/ProcessElfCore.cpp
> 
> Index: include/lldb/Symbol/ObjectFile.h
> ===================================================================
> --- include/lldb/Symbol/ObjectFile.h
> +++ include/lldb/Symbol/ObjectFile.h
> @@ -506,7 +506,7 @@
>     ///     The address of any auxiliary tables, or an invalid address if this
>     ///     object file format does not support or contain such information.
>     virtual lldb_private::Address
> -    GetImageInfoAddress () { return Address(); }
> +    GetImageInfoAddress (bool *indirect) { *indirect = false; return Address(); }
> 
>     //------------------------------------------------------------------
>     /// Returns the address of the Entry Point in this object file - if
> Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
> ===================================================================
> --- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
> +++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
> @@ -515,7 +515,7 @@
> }
> 
> Address
> -ObjectFileELF::GetImageInfoAddress()
> +ObjectFileELF::GetImageInfoAddress(bool *indirect)
> {
>     if (!ParseDynamicSymbols())
>         return Address();
> @@ -539,8 +539,9 @@
>     {
>         ELFDynamic &symbol = m_dynamic_symbols[i];
> 
> -        if (symbol.d_tag == DT_DEBUG)
> +        if (symbol.d_tag == DT_DEBUG || symbol.d_tag == DT_MIPS_RLD_MAP)
>         {
> +            *indirect = (symbol.d_tag == DT_MIPS_RLD_MAP);
>             // Compute the offset as the number of previous entries plus the
>             // size of d_tag.
>             addr_t offset = i * dynsym_hdr->sh_entsize + GetAddressByteSize();
> Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.h
> ===================================================================
> --- source/Plugins/ObjectFile/ELF/ObjectFileELF.h
> +++ source/Plugins/ObjectFile/ELF/ObjectFileELF.h
> @@ -127,7 +127,7 @@
>     GetDependentModules(lldb_private::FileSpecList& files);
> 
>     virtual lldb_private::Address
> -    GetImageInfoAddress();
> +    GetImageInfoAddress(bool *indirect);
> 
>     virtual lldb_private::Address
>     GetEntryPointAddress ();
> Index: source/Plugins/Process/POSIX/ProcessPOSIX.cpp
> ===================================================================
> --- source/Plugins/Process/POSIX/ProcessPOSIX.cpp
> +++ source/Plugins/Process/POSIX/ProcessPOSIX.cpp
> @@ -289,12 +289,21 @@
> {
>     Target *target = &GetTarget();
>     ObjectFile *obj_file = target->GetExecutableModule()->GetObjectFile();
> -    Address addr = obj_file->GetImageInfoAddress();
> +    bool indirect;
> +    Address addr = obj_file->GetImageInfoAddress(&indirect);
> 
> -    if (addr.IsValid()) 
> -        return addr.GetLoadAddress(target);
> -    else
> -        return LLDB_INVALID_ADDRESS;
> +    if (addr.IsValid())
> +    {
> +        if (indirect)                                                          
> +        {                                                                      
> +            Error error;                                                       
> +            Address ind_addr;                                                  
> +            if (target->ReadPointerFromMemory(addr.GetLoadAddress(target), false, error, ind_addr))
> +                return ind_addr.GetLoadAddress(target);                        
> +        }                                                                      
> +         return addr.GetLoadAddress(target);                                    
> +    }                                                                          
> +    return LLDB_INVALID_ADDRESS;
> }
> 
> Error
> Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
> ===================================================================
> --- source/Plugins/Process/elf-core/ProcessElfCore.cpp
> +++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
> @@ -338,10 +338,20 @@
> {
>     Target *target = &GetTarget();
>     ObjectFile *obj_file = target->GetExecutableModule()->GetObjectFile();
> -    Address addr = obj_file->GetImageInfoAddress();
> +    bool indirect;
> +    Address addr = obj_file->GetImageInfoAddress(&indirect);
> 
> -    if (addr.IsValid()) 
> +    if (addr.IsValid())
> +    {
> +        if (indirect)
> +        {
> +            Error error;
> +            Address ind_addr;
> +            if (target->ReadPointerFromMemory(addr.GetLoadAddress(target), false, error, ind_addr))
> +                return ind_addr.GetLoadAddress(target);
> +        }
>         return addr.GetLoadAddress(target);
> +    }
>     return LLDB_INVALID_ADDRESS;
> }
> <D1890.1.patch>_______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits




More information about the lldb-commits mailing list