char *GetARName( ar_header *header, file_list *list, unsigned long *loc ) /***********************************************************************/ { char *buf; char *name; unsigned long val; size_t len; name = NULL; if( header->name[0] == '/' ) { val = GetARValue( &header->name[1], AR_NAME_LEN - 1 ); buf = list->strtab + val; len = strlen( buf ); } else if( header->name[0] == '#' && header->name[1] == '1' && header->name[2] == '/') { len = GetARValue( &header->name[3], AR_NAME_LEN - 3 ); buf = CacheRead( list, *loc, len ); *loc += len; } else { len = AR_NAME_LEN; buf = memchr( header->name, '/', len ); if( buf != NULL ) { len = buf - header->name; } buf = header->name; } if( len > 0 ) { name = ChkToString( buf, len ); } return( name ); }
char *IdentifyObject( file_list *list, unsigned long *loc, unsigned long *size ) /******************************************************************************/ { ar_header *ar_hdr; char *name; unsigned long ar_loc; name = NULL; *size = 0; if( list->status & STAT_AR_LIB ) { ar_loc = MAKE_EVEN( *loc ); /* AR headers are word aligned. */ ar_hdr = CacheRead( list, ar_loc, sizeof( ar_header ) ); ar_loc += sizeof( ar_header ); name = GetARName( ar_hdr, list, &ar_loc ); *size = GetARValue( ar_hdr->size, AR_SIZE_LEN ); *loc = ar_loc; } if( !IsORL( list, *loc ) ) { if( IsOMF( list, *loc ) ) { ObjFormat |= FMT_OMF; name = GetOMFName( list, loc ); if( list->status & STAT_AR_LIB ) { *loc = ar_loc; /* Restore the location. */ } } } return( name ); }
static bool ReadARDict( file_list *list, unsigned long *loc, bool makedict ) /**************************************************************************/ { ar_header *ar_hdr; unsigned long size; int numdicts; numdicts = 0; if( makedict ) { if( list->u.dict == NULL ) { _ChkAlloc( list->u.dict, sizeof( dict_entry ) ); } } for( ;; ) { ar_hdr = CacheRead( list, *loc, sizeof( ar_header ) ); size = GetARValue( ar_hdr->size, AR_SIZE_LEN ); if( ar_hdr->name[0] == '/' && ar_hdr->name[1] == ' ' ) { ++numdicts; *loc += sizeof( ar_header ); if( makedict ) ReadARDictData( list, loc, size, numdicts ); *loc += MAKE_EVEN( size ); } else if( ar_hdr->name[0] == '/' && ar_hdr->name[1] == '/' ) { *loc += sizeof( ar_header ); ReadARStringTable( list, loc, size ); *loc += MAKE_EVEN( size ); } else { break; // found an actual object file } } if( makedict ) { if( numdicts == 0 ) { Locator( list->file->name, NULL, 0 ); LnkMsg( ERR+MSG_NO_DICT_FOUND, NULL ); _LnkFree( list->u.dict ); list->u.dict = NULL; return( FALSE ); } if( !(LinkFlags & CASE_FLAG) || numdicts == 1 ) { SortARDict( &list->u.dict->a ); } } return( TRUE ); }