diff options
author | Kamil Rytarowski <n54@gmx.com> | 2017-03-26 15:34:57 +0000 |
---|---|---|
committer | Kamil Rytarowski <n54@gmx.com> | 2017-03-26 15:34:57 +0000 |
commit | 12801f1e0f2f505ecf0a172341a6eccb2f930b28 (patch) | |
tree | 625a9714d14f81aff640be060ee6a4005dc787f0 /lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | |
parent | 8096a8c86ff03213f43ed3cda182ae3005c3cdf7 (diff) | |
download | bcm5719-llvm-12801f1e0f2f505ecf0a172341a6eccb2f930b28.tar.gz bcm5719-llvm-12801f1e0f2f505ecf0a172341a6eccb2f930b28.zip |
[LLDB] OpenBSD support
Summary:
Add basic OpenBSD support. This is enough to be able to analyze core dumps for OpenBSD/amd64, OpenBSD/arm, OpenBSD/arm64 and OpenBSD/i386.
Note that part of the changes to source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp fix a bug that probably affects other platforms as well. The GetProgramHeaderByIndex() interface use 1-based indices, but in some case when looping over the headers the, the loop starts at 0 and misses the last header. This caused problems on OpenBSD since OpenBSD core dumps have the PT_NOTE segment as the last program header.
Reviewers: joerg, labath, krytarowski
Reviewed By: krytarowski
Subscribers: aemerson, emaste, rengolin, srhines, krytarowski, mgorny, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D31131
llvm-svn: 298810
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp')
-rw-r--r-- | lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 10213f572b8..a218782b32f 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -52,6 +52,7 @@ namespace { const char *const LLDB_NT_OWNER_FREEBSD = "FreeBSD"; const char *const LLDB_NT_OWNER_GNU = "GNU"; const char *const LLDB_NT_OWNER_NETBSD = "NetBSD"; +const char *const LLDB_NT_OWNER_OPENBSD = "OpenBSD"; const char *const LLDB_NT_OWNER_CSR = "csr"; const char *const LLDB_NT_OWNER_ANDROID = "Android"; const char *const LLDB_NT_OWNER_CORE = "CORE"; @@ -832,7 +833,7 @@ bool ObjectFileELF::SetLoadAddress(Target &target, lldb::addr_t value, if (section_list) { if (!value_is_offset) { bool found_offset = false; - for (size_t i = 0, count = GetProgramHeaderCount(); i < count; ++i) { + for (size_t i = 1, count = GetProgramHeaderCount(); i <= count; ++i) { const elf::ELFProgramHeader *header = GetProgramHeaderByIndex(i); if (header == nullptr) continue; @@ -1369,6 +1370,12 @@ ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data, "ObjectFileELF::%s detected NetBSD, min version constant %" PRIu32, __FUNCTION__, version_info); } + // Process OpenBSD ELF notes. + else if (note.n_name == LLDB_NT_OWNER_OPENBSD) { + // Set the elf OS version to OpenBSD. Also clear the vendor. + arch_spec.GetTriple().setOS(llvm::Triple::OSType::OpenBSD); + arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::UnknownVendor); + } // Process CSR kalimba notes else if ((note.n_type == LLDB_NT_GNU_ABI_TAG) && (note.n_name == LLDB_NT_OWNER_CSR)) { @@ -3349,7 +3356,7 @@ bool ObjectFileELF::GetArchitecture(ArchSpec &arch) { // headers // that might shed more light on the architecture if (ParseProgramHeaders()) { - for (size_t i = 0, count = GetProgramHeaderCount(); i < count; ++i) { + for (size_t i = 1, count = GetProgramHeaderCount(); i <= count; ++i) { const elf::ELFProgramHeader *header = GetProgramHeaderByIndex(i); if (header && header->p_type == PT_NOTE && header->p_offset != 0 && header->p_filesz > 0) { |