unsigned long ObjPass1( void ) /****************************/ /* Pass 1 of 8086 linker. */ { unsigned long loc; char *savename; DEBUG(( DBG_BASE, "1 : file = %s, module = %s", CurrMod->f.source->file->name, CurrMod->name )); CurrMod->modinfo |= MOD_DONE_PASS_1; SymModStart(); DBIInitModule( CurrMod ); RelocStartMod(); P1Start(); loc = CallPass1[ GET_FMT_IDX( ObjFormat ) ](); CollapseLazyExtdefs(); SymModEnd(); if( !(CurrMod->modinfo & MOD_GOT_NAME) ) { savename = CurrMod->name; CurrMod->name = AddStringStringTable( &PermStrings, savename ); _LnkFree( savename ); CurrMod->modinfo |= MOD_GOT_NAME; } DBIP1ModuleScanned(); ReleaseNames(); PermEndMod( CurrMod ); FreeObjInfo(); ObjFormat = 0; //clear flags for processing obj file return( loc ); }
symbol *SymOpNWPfx( sym_flags op, char *name, size_t length, char * prefix, size_t prefixLen ) /**********************************************************************************************/ { symbol *retsym = SymOp( op, name, length ); if( NULL == retsym ) return( NULL ); if( ( NULL != prefix ) && ( 0 != prefixLen ) || ( NULL != CmdFile->symprefix ) ) { char *pfxname = alloca( 255 + 1 ); /* max len of PString - used to be prefixLen+1 */ if( NULL == pfxname ) { LnkMsg( ERR+MSG_SYMBOL_NAME_TOO_LONG, "s", prefix ); return( NULL ); } if( prefix ) { memcpy( pfxname, prefix, prefixLen ); pfxname[ prefixLen] = '\0'; } else { strcpy( pfxname, CmdFile->symprefix ); } if( NULL == (retsym->prefix = AddStringStringTable( &PrefixStrings, pfxname )) ) { LnkMsg( ERR+MSG_INTERNAL, "s", "no memory for prefix symbol"); return( NULL ); } } return( retsym ); }
static void *GetString( perm_write_info *info, char *str ) /*********************************************************/ { unsigned idx; idx = GetStringTableSize( &info->strtab ); AddStringStringTable( &info->strtab, str ); return( (void *)idx ); }
void SetupFakeModule( void ) /*********************************/ { if( FmtData.type & MK_PE ) { FakeModule = NewModEntry(); FakeModule->modinfo = DBI_ALL|MOD_LAST_SEG|MOD_NEED_PASS_2|FMT_PE_XFER; FakeModule->name = AddStringStringTable( &PermStrings, LinkerModule ); DBIInitModule( FakeModule ); } }
static infilelist * AllocEntry( char *name, path_entry *path ) /************************************************************/ { infilelist * entry; _PermAlloc( entry, sizeof(infilelist) ); entry->name = AddStringStringTable( &PermStrings, name ); entry->path_list = path; entry->prefix = NULL; entry->handle = NIL_HANDLE; entry->cache = NULL; entry->len = 0; entry->flags = 0; return entry; }
void AddSecName( ElfHdr *hdr, Elf32_Shdr *sh, char *name ) /***************************************************************/ { sh->sh_name = GetStringTableSize( &hdr->secstrtab ); AddStringStringTable( &hdr->secstrtab, name ); }
static orl_return ProcSymbol( orl_symbol_handle symhdl ) /******************************************************/ { orl_symbol_type type; char *name; orl_symbol_value value; orl_sec_handle sechdl; symbol *sym; size_t namelen; sym_flags symop; extnode *newnode; segnode *snode; bool isweak; orl_symbol_handle assocsymhdl; symbol *assocsym; orl_symbol_binding binding; sechdl = ORLSymbolGetSecHandle( symhdl ); snode = FindSegNode( sechdl ); type = ORLSymbolGetType( symhdl ); name = ORLSymbolGetName( symhdl ); if( type & ORL_SYM_TYPE_FILE ) { if( (CurrMod->modinfo & MOD_GOT_NAME) == 0 ) { CurrMod->modinfo |= MOD_GOT_NAME; _LnkFree( CurrMod->name ); CurrMod->name = AddStringStringTable( &PermStrings, name ); } return( ORL_OKAY ); } if( type & ORL_SYM_TYPE_DEBUG ) return( ORL_OKAY ); if( type & (ORL_SYM_TYPE_OBJECT|ORL_SYM_TYPE_FUNCTION) || (type & (ORL_SYM_TYPE_NOTYPE|ORL_SYM_TYPE_UNDEFINED) && name != NULL)) { namelen = strlen( name ); if( namelen == 0 ) { BadObject(); } if( CurrMod->modinfo & MOD_IMPORT_LIB ) { ImpProcSymbol( snode, type, name, namelen ); return( ORL_OKAY ); } newnode = AllocNode( ExtNodes ); newnode->handle = symhdl; binding = ORLSymbolGetBinding( symhdl ); symop = ST_CREATE; if( binding == ORL_SYM_BINDING_LOCAL ) { symop |= ST_STATIC | ST_NONUNIQUE; } if( (type & ORL_SYM_TYPE_UNDEFINED) && binding != ORL_SYM_BINDING_ALIAS ){ symop |= ST_REFERENCE; } else { symop |= ST_NOALIAS; } sym = SymOp( symop, name, namelen ); CheckIfTocSym( sym ); if( type & ORL_SYM_TYPE_COMMON ) { value = ORLSymbolGetValue( symhdl ); sym = MakeCommunalSym( sym, value.u._32[I64LO32], false, true ); } else if( type & ORL_SYM_TYPE_UNDEFINED ) { DefineReference( sym ); isweak = false; switch( binding ) { case ORL_SYM_BINDING_WEAK: isweak = true; case ORL_SYM_BINDING_ALIAS: case ORL_SYM_BINDING_LAZY: assocsymhdl = ORLSymbolGetAssociated( symhdl ); name = ORLSymbolGetName( assocsymhdl ); namelen = strlen(name); if( binding == ORL_SYM_BINDING_ALIAS ) { MakeSymAlias( sym->name, strlen(sym->name), name, namelen ); } else { assocsym = SymOp( ST_CREATE | ST_REFERENCE, name, namelen ); DefineLazyExtdef( sym, assocsym, isweak ); newnode->isweak = true; } } } else { newnode->isdefd = true; value = ORLSymbolGetValue( symhdl ); if( (type & ORL_SYM_TYPE_COMMON) && (type & ORL_SYM_TYPE_OBJECT) && sechdl == NULL) { sym = MakeCommunalSym( sym, value.u._32[I64LO32], false, true ); } else if( snode != NULL && snode->entry != NULL && snode->entry->iscdat ) { DefineComdatSym( snode, sym, value ); } else { sym->info |= SYM_DEFINED; DefineSymbol( sym, snode, value.u._32[I64LO32], 0 ); } } newnode->entry = sym; } else if( (type & ORL_SYM_TYPE_SECTION) && (type & ORL_SYM_CDAT_MASK) && snode != NULL && !(snode->info & SEG_DEAD) ) { snode->entry->select = (type & ORL_SYM_CDAT_MASK) >> ORL_SYM_CDAT_SHIFT; }