[Bug 17209] New: ObjectFileELF::GetModuleSpecifications overrides OS and Vendor name with those from host

Bug ID 17209
Summary ObjectFileELF::GetModuleSpecifications overrides OS and Vendor name with those from host
Product lldb
Version unspecified
Hardware PC
Status NEW
Severity normal
Priority P
Component All Bugs
Assignee lldb-dev@cs.uiuc.edu
Reporter emaste@freebsd.org
Classification Unclassified


We would like to be able to open Linux and FreeBSD core files on any of Linux,
FreeBSD, and OS X.

Michael provided a reference for the GNU ABI tag already:

Note that the build ID page reports that "the name is not normative, and the
section can be merged with other SHT_NOTE sections."
We should apply the same logic for ABI tag parsing, using the note name and not
relying on the section name.

We can fall back to using the Host's OS/Vendor if the note is not found.

A handy reference:

** Linux **
Name: GNU
Type: NT_GNU_ABI_TAG (1)
Desc: Four 4-byte words, as follows
 OS (0=linux)
 major version (minimum compatible kernel version)
 minor version
 dot version

** FreeBSD **
Name: FreeBSD
Desc: One 4-byte word

** NetBSD **
Name: NetBSD
Type: NT_NETBSD_IDENT(?) (1)
Desc: One 4-byte word containing the version constant


** OpenBSD **
Name: OpenBSD

emaste@freebsd.org changed bug 17209

What Removed Added
Resolution FIXED

Comment # 3 on bug 17209 from emaste@freebsd.org

Fixed by Todd Fiala in r211907:

    Fix ObjectFileELF to determine architectures independent of host.           

    Previously ObjectFileELF was simplifying and assuming the object file it
    looking at was the same as the host architecture/triple.  This would break  
    attempts to run, say, lldb on MacOSX against lldb-gdbserver on Linux since  
    the MacOSX lldb would say that the linux elf file was really an Apple
    architecture.  Chaos would ensue.                                           

    This change allows the elf file to parse ELF notes for Linux, FreeBSD and   
    NetBSD, and determine the OS appropriately from them.  It also initializes  
    the OS type from the ELF header OSABI if it is set (which it is for FreeBSD 
    but not for Linux).                                                         

    Added a test with freebsd and linux images that verify that                 
    '(lldb) image list -t -A' prints out the expected architecture for each.