// DIE's signature file
// Author: Levis <levintaeyeon@live.com>
// EP sigs by hypn0 <hypn0@mail.ru>
// Lazarus Free Pascal

init("compiler","Free Pascal");

function detect(bShowType,bShowVersion,bShowOptions)
{
    if(ELF.compareEP("5989e38d44....83e4..8915........a3........890d........891d........e8........8925........31ede8........c3"))
    {
        sVersion="2.6.0";
        bDetected=1;
    }
    else if(ELF.compareEP("31ED5989E3"))
    {
        bDetected=1;
    }
    else if(ELF.isSectionNamePresent(".fpc.resources"))
    {
        bDetected=1;
    }
    else if(ELF.isSectionNamePresent(".data"))
    {
        var nSection=ELF.getSectionNumber(".data");
        var nOffset=ELF.getSectionFileOffset(nSection);
        var nSize=ELF.getSectionFileSize(nSection);

        if(nSize>=0x100)
        {
            var nStringOffset=ELF.findString(nOffset+nSize-0x100,0x100,"FPC ");
            if(nStringOffset!=-1)
            {
                sVersion=ELF.getString(nStringOffset+4);
                bDetected=1;
            }
        }
    }

    return result(bShowType,bShowVersion,bShowOptions);
}
