Skip to content

Commit 9514a38

Browse files
committedSep 9, 2015
[LLDB][MIPS] Added support for the debugging of N32/O32 applications on MIPS64 target.
Patch by Nitesh Jain Reviewers: clayborg, ovyalov. Subscribers: jaydeep, bhushan, mohit.bhakkad, sagar, nitesh.jain, lldb-commits. Differential Revision: http://reviews.llvm.org/D12671 llvm-svn: 247134
1 parent 025103c commit 9514a38

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed
 

‎lldb/include/lldb/Core/ArchSpec.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ class ArchSpec
6565
eMIPSAse_mips16 = 0x00000400, // MIPS16 ASE
6666
eMIPSAse_micromips = 0x00000800, // MICROMIPS ASE
6767
eMIPSAse_xpa = 0x00001000, // XPA ASE
68-
eMIPSAse_mask = 0x00001fff
68+
eMIPSAse_mask = 0x00001fff,
69+
eMIPSABI_O32 = 0x00002000,
70+
eMIPSABI_N32 = 0x00004000,
71+
eMIPSABI_N64 = 0x00008000,
72+
eMIPSABI_mask = 0x000ff000
6973
};
7074

7175
enum Core

‎lldb/source/Core/ArchSpec.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,15 @@ ArchSpec::GetAddressByteSize() const
602602
{
603603
const CoreDefinition *core_def = FindCoreDefinition (m_core);
604604
if (core_def)
605-
return core_def->addr_byte_size;
605+
{
606+
if (core_def->machine == llvm::Triple::mips64 || core_def->machine == llvm::Triple::mips64el)
607+
{
608+
// For N32/O32 applications Address size is 4 bytes.
609+
if (m_flags & (eMIPSABI_N32 | eMIPSABI_O32))
610+
return 4;
611+
}
612+
return core_def->addr_byte_size;
613+
}
606614
return 0;
607615
}
608616

‎lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

+20-10
Original file line numberDiff line numberDiff line change
@@ -1517,32 +1517,42 @@ ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl &section_headers,
15171517
I != section_headers.end(); ++I)
15181518
{
15191519
static ConstString g_sect_name_gnu_debuglink (".gnu_debuglink");
1520-
const ELFSectionHeaderInfo &header = *I;
1521-
const uint64_t section_size = header.sh_type == SHT_NOBITS ? 0 : header.sh_size;
1520+
const ELFSectionHeaderInfo &sheader = *I;
1521+
const uint64_t section_size = sheader.sh_type == SHT_NOBITS ? 0 : sheader.sh_size;
15221522
ConstString name(shstr_data.PeekCStr(I->sh_name));
15231523

15241524
I->section_name = name;
15251525

15261526
if (arch_spec.GetMachine() == llvm::Triple::mips || arch_spec.GetMachine() == llvm::Triple::mipsel
15271527
|| arch_spec.GetMachine() == llvm::Triple::mips64 || arch_spec.GetMachine() == llvm::Triple::mips64el)
15281528
{
1529-
if (header.sh_type == SHT_MIPS_ABIFLAGS)
1529+
uint32_t arch_flags = arch_spec.GetFlags ();
1530+
DataExtractor data;
1531+
if (sheader.sh_type == SHT_MIPS_ABIFLAGS)
15301532
{
1531-
DataExtractor data;
1532-
if (section_size && (data.SetData (object_data, header.sh_offset, section_size) == section_size))
1533+
1534+
if (section_size && (data.SetData (object_data, sheader.sh_offset, section_size) == section_size))
15331535
{
15341536
lldb::offset_t ase_offset = 12; // MIPS ABI Flags Version: 0
1535-
uint32_t arch_flags = arch_spec.GetFlags ();
15361537
arch_flags |= data.GetU32 (&ase_offset);
1537-
arch_spec.SetFlags (arch_flags);
15381538
}
15391539
}
1540+
// Settings appropriate ArchSpec ABI Flags
1541+
if (header.e_flags & llvm::ELF::EF_MIPS_ABI2)
1542+
{
1543+
arch_flags |= lldb_private::ArchSpec::eMIPSABI_N32;
1544+
}
1545+
else if (header.e_flags & llvm::ELF::EF_MIPS_ABI_O32)
1546+
{
1547+
arch_flags |= lldb_private::ArchSpec::eMIPSABI_O32;
1548+
}
1549+
arch_spec.SetFlags (arch_flags);
15401550
}
15411551

15421552
if (name == g_sect_name_gnu_debuglink)
15431553
{
15441554
DataExtractor data;
1545-
if (section_size && (data.SetData (object_data, header.sh_offset, section_size) == section_size))
1555+
if (section_size && (data.SetData (object_data, sheader.sh_offset, section_size) == section_size))
15461556
{
15471557
lldb::offset_t gnu_debuglink_offset = 0;
15481558
gnu_debuglink_file = data.GetCStr (&gnu_debuglink_offset);
@@ -1552,7 +1562,7 @@ ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl &section_headers,
15521562
}
15531563

15541564
// Process ELF note section entries.
1555-
bool is_note_header = (header.sh_type == SHT_NOTE);
1565+
bool is_note_header = (sheader.sh_type == SHT_NOTE);
15561566

15571567
// The section header ".note.android.ident" is stored as a
15581568
// PROGBITS type header but it is actually a note header.
@@ -1564,7 +1574,7 @@ ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl &section_headers,
15641574
{
15651575
// Allow notes to refine module info.
15661576
DataExtractor data;
1567-
if (section_size && (data.SetData (object_data, header.sh_offset, section_size) == section_size))
1577+
if (section_size && (data.SetData (object_data, sheader.sh_offset, section_size) == section_size))
15681578
{
15691579
Error error = RefineModuleDetailsFromNote (data, arch_spec, uuid);
15701580
if (error.Fail ())

0 commit comments

Comments
 (0)
Please sign in to comment.