return_val DumpASMSection( section_ptr section, unsigned_8 *contents, dis_sec_size size, unsigned pass ) { hash_data *h_data; label_list sec_label_list; label_entry l_entry; ref_list sec_ref_list; ref_entry r_entry; return_val err; hash_key h_key; h_key.u.sec_handle = section->shnd; h_data = HashTableQuery( HandleToLabelListTable, h_key ); if( h_data != NULL ) { sec_label_list = h_data->u.sec_label_list; l_entry = sec_label_list->first; } else { sec_label_list = NULL; l_entry = NULL; } r_entry = NULL; h_data = HashTableQuery( HandleToRefListTable, h_key ); if( h_data != NULL ) { sec_ref_list = h_data->u.sec_ref_list; if( sec_ref_list != NULL ) { r_entry = sec_ref_list->first; } } if( pass == 1 ) { DoPass1Relocs( contents, r_entry, 0, size ); return( RC_OKAY ); } if( size == 0 ) { if( IsMasmOutput() ) { PrintHeader( section ); dumpAsmLabel( l_entry, section, 0, 0, NULL, NULL ); PrintTail( section ); } return( RC_OKAY ); } PrintHeader( section ); err = DumpASMDataFromSection( contents, 0, size, &l_entry, &r_entry, section ); if( size > 0 ) { l_entry = dumpAsmLabel( l_entry, section, size, size, NULL, NULL ); } BufferConcatNL(); BufferPrint(); if( err == RC_OKAY ) { PrintTail( section ); } return( err ); }
return_val DumpASMSection( section_ptr sec, unsigned_8 *contents, orl_sec_size size, unsigned pass ) { hash_data *data_ptr; label_list sec_label_list; label_entry l_entry; ref_list sec_ref_list; ref_entry r_entry; return_val err; data_ptr = HashTableQuery( HandleToLabelListTable, (hash_value) sec->shnd ); if( data_ptr ) { sec_label_list = (label_list) *data_ptr; l_entry = sec_label_list->first; } else { sec_label_list = NULL; l_entry = NULL; } r_entry = NULL; data_ptr = HashTableQuery( HandleToRefListTable, (hash_value) sec->shnd ); if( data_ptr ) { sec_ref_list = (ref_list) *data_ptr; if( sec_ref_list != NULL ) { r_entry = sec_ref_list->first; } } if( pass == 1 ) { DoPass1Relocs( contents, r_entry, 0, size ); return( RC_OKAY ); } if( size == 0 ) { if( IsMasmOutput() ) { PrintHeader( sec ); dumpAsmLabel( l_entry, sec, 0, 0, NULL, NULL ); PrintTail( sec ); } return( RC_OKAY ); } PrintHeader( sec ); err = DumpASMDataFromSection( contents, 0, size, &l_entry, &r_entry, sec ); if( size > 0 ) { l_entry = dumpAsmLabel( l_entry, sec, size, size, NULL, NULL ); } BufferConcatNL(); BufferPrint(); if( err == RC_OKAY ) { PrintTail( sec ); } return( err ); }
return_val DumpASMDataFromSection( unsigned_8 *contents, orl_sec_offset start, orl_sec_offset end, label_entry *labent, ref_entry *refent, section_ptr sec ) { size_t curr_pos; size_t curr_size; size_t tmp_size; size_t size; label_entry l_entry; ref_entry r_entry; char *buffer; l_entry = *labent; r_entry = *refent; size = end - start; if( size < sizeof( unsigned_32 ) ) size = sizeof( unsigned_32 ); buffer = MemAlloc( size + 1 ); if( !buffer ) { PrintErrorMsg( RC_OUT_OF_MEMORY, WHERE_PRINT_SECTION ); return( RC_OUT_OF_MEMORY ); } for( curr_pos = start; curr_pos < end; curr_pos += curr_size ) { /* dump labels */ l_entry = dumpAsmLabel( l_entry, sec, curr_pos, end, contents, buffer ); curr_size = end - curr_pos; if( l_entry != NULL ) { tmp_size = l_entry->offset - curr_pos; if( tmp_size < curr_size ) { curr_size = tmp_size; } } /* Skip over pair relocs */ while( r_entry != NULL && (r_entry->type == ORL_RELOC_TYPE_PAIR || r_entry->offset < curr_pos) ) { r_entry = r_entry->next; } if( r_entry != NULL && r_entry->offset < (curr_pos + curr_size) ) { if( r_entry->offset == curr_pos ) { BufferConcat(" "); curr_size = HandleRefInData(r_entry, contents + curr_pos, TRUE); BufferConcatNL(); BufferPrint(); continue; } else { tmp_size = r_entry->offset - curr_pos; if( tmp_size < curr_size ) { curr_size = tmp_size; } } } memcpy( buffer, (contents + curr_pos), curr_size ); buffer[ curr_size ] = 0; printOut( buffer, curr_pos, curr_size ); } *labent = l_entry; *refent = r_entry; MemFree( buffer ); return( RC_OKAY ); }