// DIE's signature file
// Author: anonymous

init("compiler","Oracle Solaris Studio");

function getOSSVersion()
{
    var sResult="";
    var nSection=ELF.getSectionNumber(".comment");
    if(nSection!=-1)
    {
        var nSectionOffset=ELF.getSectionFileOffset(nSection);
        var nSectionSize=ELF.getSectionFileSize(nSection);
        var nOffset=ELF.findString(nSectionOffset,nSectionSize,"Sun WorkShop");
        if(nOffset!=-1)
        {
            return ELF.getString(nOffset+13,100);
        }
        nOffset=ELF.findString(nSectionOffset,nSectionSize,"acomp: Sun C");
        if(nOffset!=-1)
        {
            return ELF.getString(nOffset+13,100);
        }
        nOffset=ELF.findString(nSectionOffset,nSectionSize,"SUNWCC.h");
        if(nOffset!=-1)
        {
            return "5.X";
        }
    }

    return sResult;
}

function detect(bShowType,bShowVersion,bShowOptions)
{
    if(ELF.compareEP("bc1020..e003....1300....e022....a203a0..1300....e222....1300....e222....a52c20..a404a0..a40440122700....e804....80a520"))
    //SPARC instruction set
    {
        if(ELF.isSectionNamePresent(".SUNW_version"))
        {
            bDetected=1;
        }
        var sOSSVersion=getOSSVersion();
        if(sOSSVersion!="")
        {
            bDetected=1;
            sVersion=sOSSVersion;
        }
    }
    return result(bShowType,bShowVersion,bShowOptions);
}
