[Lldb-commits] [PATCH] Support indirect dyld link information (used on MIPS)
Ed Maste
emaste at freebsd.org
Thu Oct 10 11:52:26 PDT 2013
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1890.1.patch
Type: text/x-patch
Size: 4390 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20131010/730e4782/attachment.bin>
More information about the lldb-commits
mailing list