コード例 #1
0
ファイル: unrealfmt.cpp プロジェクト: roman5566/foo_dumb
// load the type_names
void upkg::get_type(char *buf, int e, int d)
{
	int i, j, index;
	signed long tmp;
	char *chtmp;

	index = 0;

	for (i = 0, j = strlen(export_desc[d].order); i < j; i++) {
		switch (export_desc[d].order[i]) {
		case UPKG_DATA_FCI:
			tmp = get_fci(&buf[index]);
			index += data_size;
			break;
		case UPKG_DATA_32:
			tmp = get_s32(&buf[index]);
			index += data_size;
			break;
		case UPKG_DATA_16:
			tmp = get_s16(&buf[index]);
			index += data_size;
			break;
		case UPKG_DATA_8:
			tmp = get_s8(&buf[index]);
			index += data_size;
			break;
		case UPKG_DATA_ASCIC:
			chtmp =
			    get_string(&buf[index + 1],
				       get_s8(&buf[index++]));
			index += data_size;
			break;
		case UPKG_DATA_ASCIZ:
			chtmp = get_string(&buf[index], UPKG_NAME_NOCOUNT);
			index += data_size;
			break;
		case UPKG_OBJ_JUNK:	// do nothing!!!
			break;
		case UPKG_OBJ_NAME:
			exports[e].type_name = tmp;
			break;
		case UPKG_EXP_SIZE:	// maybe we'll do something later on
			break;
		case UPKG_OBJ_SIZE:
			exports[e].object_size = tmp;
			break;
		default:
			exports[e].type_name = -1;
			return;
		}
	}

	exports[e].object_offset = exports[e].serial_offset + index;
}
コード例 #2
0
ファイル: wsect.c プロジェクト: Azarien/open-watcom-v2
static void DmpLoc( uint_8 const *p, uint length, uint addr_size )
/****************************************************************/
{
    uint_8 const    *end;
    uint_8          op;
    dw_locop_op     opr;
    int_32          op1s;
    uint_32         op1u;
    int_32          op2s;
    uint_32         addr;

    end = &p[length];

    Wdputslc( "\n            Loc expr: " );
    if( p == end ) {
      Wdputslc( "<NULL>\n" );
    }
    while( p  < end ) {
        op = *p;
        ++p;

        Wdputs( OpName[ op ] );
        opr = LocOpr[ op ];
        if( opr == DW_LOP_REG1 || opr == DW_LOP_BRG1 ) {
            Wdputs( "/" );
        } else {
            Wdputs( " " );
        }
        switch( opr ) {
        case DW_LOP_NOOP:
            break;
        case DW_LOP_ADDR:
            if( addr_size == 4 ) {
                addr = *(uint_32 *)p;
            } else if( addr_size == 2 ) {
                addr = *(uint_16 *)p;
            } else if( addr_size == 1 ) {
                addr = *(uint_8 *)p;
            } else {
                addr = 0;
            }
            Puthex( addr, addr_size * 2 );
            p += addr_size;
            break;
        case DW_LOP_OPU1:
            op1u = *(uint_8 *)p;
            p += sizeof( uint_8 );
            Putdec( op1u );
            break;
        case DW_LOP_OPS1:
            op1s = *(int_8 *)p;
            p += sizeof(int_8 );
            Putdec( op1s );
            break;
        case DW_LOP_OPU2:
            op1u = get_u16( (uint_16 *)p );
            p += sizeof( uint_16 );
            Putdec( op1u );
            break;
        case DW_LOP_OPS2:
            op1s = get_s16( (int_16 *)p );
            p += sizeof( int_16 );
            Putdec( op1s );
            break;
        case DW_LOP_OPU4:
            op1u = get_u32( (uint_32 *)p );
            p += sizeof( uint_32 );
            Putdec( op1u );
            break;
        case DW_LOP_OPS4:
            op1s = get_s32( (int_32 *)p );
            p += sizeof( int_32 );
            Putdec( op1s );
            break;
        case DW_LOP_U128:
            p = DecodeULEB128( p, &op1u );
            Putdec( op1u );
            break;
        case DW_LOP_S128:
            p = DecodeSLEB128( p, &op1s );
            Putdecs( op1s );
            break;
        case DW_LOP_U128_S128:
            p = DecodeULEB128( p, &op1u );
            p = DecodeSLEB128( p, &op2s );
            Putdec( op1u );
            Wdputs( "," );
            Putdecs( op2s );
            break;
        case DW_LOP_LIT1:
            op1u = op-DW_OP_lit0;
            op = DW_OP_lit0;
            break;
        case DW_LOP_REG1:
            op1u = op-DW_OP_reg0;
            op = DW_OP_reg0;
            Wdputs( RegName[ op1u] );
            break;
        case DW_LOP_BRG1:
            op1u = op-DW_OP_breg0;
            p = DecodeSLEB128( p, &op2s );
            Wdputs( RegName[ op1u] );
            if( op2s < 0 ) {
                Wdputs( " -" );
                op2s = -op2s;
            } else {
                Wdputs( " +" );
            }
            Putdec( op2s );
            op = DW_OP_breg0;
            break;
        }
        Wdputslc( " " );
    }
        Wdputslc( "\n" );
}