void OWLENTRY OWLFileFini( owl_file_handle file ) { //************************************************* owl_section_handle curr; owl_section_handle next; resolveRelativeRelocs( file ); resolveLabelNames( file ); resolveComdefSymbols( file ); if( file->format == OWL_FORMAT_COFF ) { COFFFileEmit( file ); } else { ELFFileEmit( file ); } for( curr = file->sections; curr != NULL; curr = next ) { next = curr->next; OWLSectionFree( curr ); } OWLSymbolTableFini( file->symbol_table ); OWLStringFini( file->string_table ); deleteFile( file->info, file ); _ClientFree( file, file ); }
void main( int argc, char *argv[] ) { char buffer[ BUFFER_SIZE ]; owl_handle owl; owl_file_handle file; owl_string_table *table; owl_client_funcs funcs = { NULL, NULL, NULL, malloc, free }; char *t_buff; owl = OWLInit( &funcs, OWL_CPU_PPC ); file = OWLFileInit( owl, "test", NULL, OWL_FORMAT_ELF, OWL_FILE_OBJECT ); table = OWLStringInit( file ); while( fgets( buffer, BUFFER_SIZE, stdin ) != NULL ) { addStrings( table, buffer ); OWLStringDump( table ); } t_buff = malloc( OWLStringTableSize( table ) + 1 ); OWLStringEmit( table, t_buff ); write( STDOUT_FILENO, t_buff, OWLStringTableSize( table ) ); free( t_buff ); OWLStringFini( table ); OWLFileFini( file ); OWLFini( owl ); }