owl_section_handle OWLENTRY OWLSectionInit( owl_file_handle file, const char *name, owl_section_type type, owl_alignment align ) { //******************************************************************************************************************************** owl_section_handle section; section = _ClientAlloc( file, sizeof( owl_section_info ) ); section->file = file; section->name = OWLStringAdd( file->string_table, name ); section->type = type; section->align = align; section->buffer = ( type & OWL_SEC_ATTR_BSS ) ? NULL : OWLBufferInit( file ); section->linenum_buffer = NULL; section->num_linenums = 0; section->size = 0; section->location = 0; section->first_reloc = NULL; section->last_reloc = NULL; section->num_relocs = 0; section->comdat_sym = NULL; section->comdat_dep = NULL; addSection( file, section ); addSectionSymbol( section, name ); _Log(( file, "OWLSectionInit( %x, '%s', %x, %x ) -> %x\n", file, name, type, align, section )); return( section ); }
static void makeUniqueName( owl_file_handle file, owl_symbol_handle sym, unsigned index ) { //***************************************************************************************** char buffer[ INT_BUFFER_LEN ]; char *ptr; ptr = &buffer[ INT_BUFFER_LEN - 1 ]; *ptr-- = '\0'; do { *ptr-- = "0123456789abcdef"[ index % RADIX ]; index /= RADIX; } while( index != 0 ); *ptr-- = '$'; *ptr = 'L'; sym->name = OWLStringAdd( file->string_table, ptr ); }
static void addStrings( owl_string_table *table, char *buffer ) { char *s; char *last; last = buffer; for( s = buffer; *s; ) { if( isspace( *s ) ) { *s++ = 0; printf( "Inserting: '%s'\n", last ); OWLStringAdd( table, last ); while( isspace( *s ) ) s++; last = s; } else { s++; } } }
owl_file_handle OWLENTRY OWLFileInit( owl_handle handle, const char *name, owl_client_file client_handle, owl_format format, owl_file_type type ) { //************************************************************************************************************************************************* owl_file_handle file; file = handle->client_funcs.alloc( sizeof( *file ) ); file->info = handle; file->format = format; file->client_handle = client_handle; file->log = NULL; file->type = type; file->string_table = OWLStringInit( file ); file->symbol_table = OWLSymbolTableInit( file ); file->sections = NULL; file->next_index = 0; file->name = NULL; addFile( handle, file ); OWLFileSymbol( file, name ); file->name = OWLStringAdd( file->string_table, name ); return( file ); }