diff options
author | Ed Maste <emaste@freebsd.org> | 2015-06-05 13:03:08 +0000 |
---|---|---|
committer | Ed Maste <emaste@freebsd.org> | 2015-06-05 13:03:08 +0000 |
commit | f6a1312f1b30a335889f74d92e5ce5e5a6970f4a (patch) | |
tree | f9bbf864e03000d59b73a818c765c51ab8b4b59b /lldb/source/Core/ArchSpec.cpp | |
parent | acd1cd66c17fed8adeb7108ae8c6ae1f7671bac2 (diff) | |
download | bcm5719-llvm-f6a1312f1b30a335889f74d92e5ce5e5a6970f4a.tar.gz bcm5719-llvm-f6a1312f1b30a335889f74d92e5ce5e5a6970f4a.zip |
Improve OSType initialization in elf object file's arch_spec
Setting the OSType in the ArchSpec triple is needed to correctly setup
up the register context plugin. ArchSpec::SetArchitecture, for Mach-O
only, sets the OSType. For ELF it was left to the ObjectFileELF to fill
in the missing OSType.
This change moves the ObjectFileELF logic into ArchSpec.
A new optional 'os' parameter has been added to SetArchitecture.
For ELF, this value is the from the ELF header.e_ident[EI_OSABI].
The default value is 0 or ELFOSABI_NONE.
The real work of determining the OSType was done by the ObjectFileELF
helper function GetOsFromOSABI. This logic has been moved
SetArchitecture.
GetOsFromOSABI has been commented as being deprectated. It is left in
to support asserts.
For ELF the vendor value returned from SetArchitecture should be
UnknownVendor. An unneeded resetting in ObjectFileELF has been removed
and replaced with an assert.
This fixes a problem reading a core file on FreeBSD/ARM because the spec
triple was arm-unknown-unknown.
Patch by Tom Rix.
Differential Revision: http://reviews.llvm.org/D9292
llvm-svn: 239148
Diffstat (limited to 'lldb/source/Core/ArchSpec.cpp')
-rw-r--r-- | lldb/source/Core/ArchSpec.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lldb/source/Core/ArchSpec.cpp b/lldb/source/Core/ArchSpec.cpp index d171fb19c09..34a201e6abc 100644 --- a/lldb/source/Core/ArchSpec.cpp +++ b/lldb/source/Core/ArchSpec.cpp @@ -840,7 +840,7 @@ ArchSpec::MergeFrom(const ArchSpec &other) } bool -ArchSpec::SetArchitecture (ArchitectureType arch_type, uint32_t cpu, uint32_t sub) +ArchSpec::SetArchitecture (ArchitectureType arch_type, uint32_t cpu, uint32_t sub, uint32_t os) { m_core = kCore_invalid; bool update_triple = true; @@ -885,6 +885,23 @@ ArchSpec::SetArchitecture (ArchitectureType arch_type, uint32_t cpu, uint32_t su break; } } + else if (arch_type == eArchTypeELF) + { + llvm::Triple::OSType ostype; + switch (os) + { + case llvm::ELF::ELFOSABI_AIX: ostype = llvm::Triple::OSType::AIX; break; + case llvm::ELF::ELFOSABI_FREEBSD: ostype = llvm::Triple::OSType::FreeBSD; break; + case llvm::ELF::ELFOSABI_GNU: ostype = llvm::Triple::OSType::Linux; break; + case llvm::ELF::ELFOSABI_NETBSD: ostype = llvm::Triple::OSType::NetBSD; break; + case llvm::ELF::ELFOSABI_OPENBSD: ostype = llvm::Triple::OSType::OpenBSD; break; + case llvm::ELF::ELFOSABI_SOLARIS: ostype = llvm::Triple::OSType::Solaris; break; + default: + ostype = llvm::Triple::OSType::UnknownOS; + } + m_triple.setOS (ostype); + m_triple.setVendor (llvm::Triple::UnknownVendor); + } // Fall back onto setting the machine type if the arch by name failed... if (m_triple.getArch () == llvm::Triple::UnknownArch) m_triple.setArch (core_def->machine); |