Improve OSType initialization in elf object file's arch_spec
authorEd Maste <emaste@freebsd.org>
Fri, 5 Jun 2015 13:03:08 +0000 (13:03 +0000)
committerEd Maste <emaste@freebsd.org>
Fri, 5 Jun 2015 13:03:08 +0000 (13:03 +0000)
commitf6a1312f1b30a335889f74d92e5ce5e5a6970f4a
treef9bbf864e03000d59b73a818c765c51ab8b4b59b
parentacd1cd66c17fed8adeb7108ae8c6ae1f7671bac2
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
lldb/include/lldb/Core/ArchSpec.h
lldb/source/Core/ArchSpec.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp