Пример #1
0
bool Dmp_ar_head( void )
/**********************/
{
    char                sig[AR_IDENT_LEN];
    ar_header           hdr;
    unsigned long       filesize;
    unsigned long       size;

    Wlseek( 0 );
    Wread( sig, AR_IDENT_LEN );
    if( memcmp( sig, AR_IDENT, AR_IDENT_LEN ) != 0 ) return 0;
    filesize = WFileSize();
    Coff_off = AR_IDENT_LEN;
    for(;;) {
        if( Coff_off + sizeof(ar_header) >= filesize ) break;
        Wread( &hdr, sizeof(ar_header) );
        Coff_off += sizeof(ar_header);
        hdr.date[0]='\0';
        Wdputs( "ar name = " );
        Wdputs( hdr.name );
        Wdputslc( "\n" );
        hdr.header_ident[0] = '\0';
        size = strtoul( hdr.size, NULL, 10 );
        if( strcmp( hdr.name, "/               " ) == 0 ||
                        strcmp( hdr.name, "//              " ) == 0 ) {
            Dmp_seg_data( Coff_off, size );
        } else if( !Dmp_coff_head() ) {
            // then try and see if it's ELF
            Wlseek( Coff_off );
            if( !Dmp_elf_header( Coff_off ) ) {
                Wdputslc( "archive entry not identified\n" );
                Dmp_seg_data( Coff_off, size );
                Wdputslc( "\n" );
            }
        }
        if( size & 1 ) {
            size++;
        }
        Coff_off += size;
        Wlseek( Coff_off );
    }
    return 1;
}
Пример #2
0
bool Dmp_lib_head( void )
/***********************/
{
    char                sig[LIBMAG_LEN];
    Lib32_Hdr           hdr;
    long                filesize;
    unsigned long       size;
    unsigned long       Elf_off;

    Wlseek( 0 );
    Wread( sig, LIBMAG_LEN );
    if( memcmp( sig, LIBMAG, LIBMAG_LEN ) != 0 ) return 0;
    filesize = WFileSize();
    Elf_off = LIBMAG_LEN + LIB_CLASS_LEN + LIB_DATA_LEN;
    Wlseek( Elf_off );
    for( ;; ) {
        if( Elf_off + LIB_HEADER_SIZE >= filesize ) break;
        Wread( &hdr, LIB_HEADER_SIZE );
        Elf_off += LIB_HEADER_SIZE;
        hdr.lib_date[0]='\0';
        Wdputs( "lib name = " );
        Wdputs( hdr.lib_name );
        Wdputslc( "\n" );
        hdr.lib_fmag[0] = '\0';
        size = strtoul( hdr.lib_size, NULL, 10 );
        if( !Dmp_elf_header( Elf_off ) ) {
            if( strcmp( hdr.lib_name, LIB_SYMTAB_NAME ) &&
                strcmp( hdr.lib_name, LIB_LFTAB_NAME ) &&
                strcmp( hdr.lib_name, LIB_FFTAB_NAME ) ) {
                Wdputslc( "archive entry not identified\n" );
            }
            Dmp_seg_data( Elf_off, size );
            Wdputslc( "\n" );
        }
        if( size & 1 ) {
            size++;
        }
        Elf_off += size;
        Wlseek( Elf_off );
    }
    return 1;
}
Пример #3
0
/*
 * Dump the ELF header, if any.
 */
bool Dmp_elf_head( void )
/***********************/
{
    Wlseek( 0 );
    return( Dmp_elf_header( 0 ) );
}