Fix [vdso] handling on Android (x86 and aarch64)
* Add in-memory object file handling to the core dynamic loader * Fix in memory object file handling in ObjectFileELF (previously only part of the file was loaded before parsing) * Fix load address setting in ObjectFileELF for 32-bit targets when the load bias is negative * Change hack in DYLDRendezvous.cpp to be more specific and not to interfere with object files with fixed load address Differential revision: http://reviews.llvm.org/D10800 llvm-svn: 241057
This commit is contained in:
@@ -807,10 +807,10 @@ ObjectFileELF::ObjectFileELF (const lldb::ModuleSP &module_sp,
|
||||
}
|
||||
|
||||
ObjectFileELF::ObjectFileELF (const lldb::ModuleSP &module_sp,
|
||||
DataBufferSP& data_sp,
|
||||
DataBufferSP& header_data_sp,
|
||||
const lldb::ProcessSP &process_sp,
|
||||
addr_t header_addr) :
|
||||
ObjectFile(module_sp, process_sp, LLDB_INVALID_ADDRESS, data_sp),
|
||||
ObjectFile(module_sp, process_sp, header_addr, header_data_sp),
|
||||
m_header(),
|
||||
m_uuid(),
|
||||
m_gnu_debuglink_file(),
|
||||
@@ -860,7 +860,14 @@ ObjectFileELF::SetLoadAddress (Target &target,
|
||||
// if (section_sp && !section_sp->IsThreadSpecific())
|
||||
if (section_sp && section_sp->Test(SHF_ALLOC))
|
||||
{
|
||||
if (target.GetSectionLoadList().SetSectionLoadAddress (section_sp, section_sp->GetFileAddress() + value))
|
||||
lldb::addr_t load_addr = section_sp->GetFileAddress() + value;
|
||||
|
||||
// On 32-bit systems the load address have to fit into 4 bytes. The rest of
|
||||
// the bytes are the overflow from the addition.
|
||||
if (GetAddressByteSize() == 4)
|
||||
load_addr &= 0xFFFFFFFF;
|
||||
|
||||
if (target.GetSectionLoadList().SetSectionLoadAddress (section_sp, load_addr))
|
||||
++num_loaded_sections;
|
||||
}
|
||||
}
|
||||
@@ -933,7 +940,28 @@ bool
|
||||
ObjectFileELF::ParseHeader()
|
||||
{
|
||||
lldb::offset_t offset = 0;
|
||||
return m_header.Parse(m_data, &offset);
|
||||
if (!m_header.Parse(m_data, &offset))
|
||||
return false;
|
||||
|
||||
if (!IsInMemory())
|
||||
return true;
|
||||
|
||||
// For in memory object files m_data might not contain the full object file. Try to load it
|
||||
// until the end of the "Section header table" what is at the end of the ELF file.
|
||||
addr_t file_size = m_header.e_shoff + m_header.e_shnum * m_header.e_shentsize;
|
||||
if (m_data.GetByteSize() < file_size)
|
||||
{
|
||||
ProcessSP process_sp (m_process_wp.lock());
|
||||
if (!process_sp)
|
||||
return false;
|
||||
|
||||
DataBufferSP data_sp = ReadMemory(process_sp, m_memory_addr, file_size);
|
||||
if (!data_sp)
|
||||
return false;
|
||||
m_data.SetData(data_sp, 0, file_size);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
Reference in New Issue
Block a user