Changeset 541


Ignore:
Timestamp:
Aug 6, 2003, 9:47:24 PM (22 years ago)
Author:
bird
Message:

bugfixing...

Location:
trunk/src/emx/src/emxomf
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/emxomf/emxomf.c

    • Property cvs2svn:cvs-rev changed from 1.20 to 1.21
    r540 r541  
    13371337                || (sym_ptr[i].n_type >= N_WEAKU && sym_ptr[i].n_type <= N_WEAKB) )
    13381338              {
    1339                 if ((sym_ptr[i].n_type & N_EXT) && out_lib != NULL)
     1339                /* for weaksymbols we may have to decorate the name */
     1340                if (   !weak_list_filename
     1341                    && sym_ptr[i].n_type >= N_WEAKU && sym_ptr[i].n_type <= N_WEAKB )
     1342                    name = weak_process_name(&sym_ptr[i], name, szName, sizeof(szName));
     1343
     1344                if (    out_lib != NULL
     1345                    &&  (   (   (sym_ptr[i].n_type & N_EXT)
     1346                             && sym_ptr[i].n_type != N_WEAKB
     1347                             && sym_ptr[i].n_type != N_WEAKU)
     1348                         ||  sym_ptr[i].n_type == N_WEAKT
     1349                         ||  sym_ptr[i].n_type == N_WEAKD ) )
    13401350                  {
    13411351                    pub_name = name;
     
    13461356                      error (lib_errmsg);
    13471357                  }
    1348 
    1349                 /* for weaksymbols we may have to decorate the name */
    1350                 if (   !weak_list_filename
    1351                     && sym_ptr[i].n_type >= N_WEAKU && sym_ptr[i].n_type <= N_WEAKB )
    1352                     name = weak_process_name(&sym_ptr[i], name, szName, sizeof(szName));
    13531358
    13541359                if (started && !fits (strlen (name) + 6))
     
    36783683                      calculated_page_size <<= 1;
    36793684                }
    3680               if (1)
    3681                 printf("calculated page size %d\n", calculated_page_size);
    36823685            }
    36833686
     
    38903893  opt_o = NULL; opt_O = NULL;
    38913894  opterr = FALSE;
     3895
     3896  tmp = getenv("EMXOMFLD_TYPE");
     3897  if (tmp && !stricmp(tmp, "LINK386"))
     3898      hll_version = 3;
    38923899
    38933900  /* Parse the command line options. */
  • trunk/src/emx/src/emxomf/emxomfld.c

    • Property cvs2svn:cvs-rev changed from 1.21 to 1.22
    r540 r541  
    640640  if (opt_t)
    641641      fFlags |= WLDC_VERBOSE;
     642  if (!stricmp(linker_type, "LINK386"))
     643      fFlags |= WLDC_LINKER_LINK386;
     644
    642645  for (pOpt = options; pOpt; pOpt = pOpt->next)
    643646    if (    !strnicmp(pOpt->name, "/NOE", 4)
     
    668671  if (opt_t)
    669672    fprintf(stderr, "*** Invoking weak prelinker with flags %x.\n", fFlags);
    670   pwld = wldCreate (fFlags);
     673  pwld = WLDCreate (fFlags);
    671674  if (pwld)
    672675    {
     
    679682        {
    680683          phfile = fopen (def_fname, "r");
    681           rc = wldAddDefFile (pwld, phfile, def_fname);
     684          rc = WLDAddDefFile (pwld, phfile, def_fname);
    682685        }
    683686
     
    687690          static const char * objexts[] = { ".obj", ".o", NULL };
    688691          phfile = find_objlib (szname, pcur->name, objexts, TRUE);
    689           rc = wldAddObject (pwld, phfile, szname);
     692          rc = WLDAddObject (pwld, phfile, szname);
    690693        }
    691694
     
    695698          static const char * libexts[] = { ".lib", ".a", NULL };
    696699          phfile = find_objlib (szname, pcur->name, libexts, TRUE);
    697           rc = wldAddLibrary (pwld, phfile, szname);
     700          rc = WLDAddLibrary (pwld, phfile, szname);
    698701          free(pcur->name);
    699702          pcur->name = xstrdup(szname);
     
    703706      if (!rc)
    704707        {
    705           rc = wldPass1 (pwld);
     708          rc = WLDPass1 (pwld);
    706709          /* ignore unresolved externals for now. */
    707710          if (rc == 42)
     
    714717      /* generate weak aliases. */
    715718      if (!rc)
    716         rc = wldGenerateWeakAliases (pwld, weakobj_fname, weakdef_fname);
     719        rc = WLDGenerateWeakAliases (pwld, weakobj_fname, weakdef_fname);
    717720      if (!rc && weakobj_fname[0])
    718721        add_name_list (&add_obj_fnames, weakobj_fname);
    719722      if (!rc && weakdef_fname[0])
    720         strcpy (def_fname, weakdef_fname);
     723        def_fname = weakdef_fname;
    721724
    722725      /* cleanup the linker */
    723       wldDestroy (pwld);
     726      WLDDestroy (pwld);
    724727     
    725728      /* last words */
     
    10891092    }
    10901093
    1091   /* Build the environment for LINK386. */
     1094  /* Build the environment for the linker. */
    10921095
    10931096  make_env ();
    1094 
    1095   /* Do the weak prelinking unless GCC_WEAKSYMS are set.
    1096      Important that this is done after make_env(). */
    1097 
    1098   if (!getenv("GCC_WEAKSYMS"))
    1099       weak_prelink ();
    1100   else
    1101     {
    1102       /* apply library hack */
    1103       name_list *pcur;
    1104       for (pcur = lib_fnames; !rc && pcur; pcur = pcur->next)
    1105         {
    1106           static const char * libexts[] = { ".lib", ".a", NULL };
    1107           char szname[_MAX_PATH];
    1108           FILE *phfile = find_objlib (szname, pcur->name, libexts, TRUE);
    1109           if (!phfile)
    1110             continue;
    1111           free(pcur->name);
    1112           pcur->name = xstrdup(szname);
    1113           fclose(phfile);
    1114         }
    1115 
    1116     }
    11171097
    11181098  /* EMXOMFLD_TYPE contains VAC365, VAC308 or LINK386 if set. If non of these
     
    11391119
    11401120
     1121
     1122  /* Do the weak prelinking unless GCC_WEAKSYMS are set.
     1123     Important that this is done after make_env(). */
     1124
     1125  if (!getenv("GCC_WEAKSYMS"))
     1126      weak_prelink ();
     1127  else
     1128    {
     1129      /* apply library hacks */
     1130      name_list *pcur;
     1131      for (pcur = lib_fnames; !rc && pcur; pcur = pcur->next)
     1132        {
     1133          static const char * libexts[] = { ".lib", ".a", NULL };
     1134          char szname[_MAX_PATH];
     1135          FILE *phfile = find_objlib (szname, pcur->name, libexts, TRUE);
     1136          if (!phfile)
     1137            continue;
     1138          free(pcur->name);
     1139          pcur->name = xstrdup(szname);
     1140          fclose(phfile);
     1141        }
     1142
     1143    }
    11411144
    11421145  /* Start building the linker command line.  We can use a response
     
    12011204      if (map_flag)
    12021205        put_arg ("/map", FALSE, FALSE); 
    1203 
    1204       /* VAC365: check if we have os2stub.bin. */
    1205       if (!stricmp (linker_type, "VAC365"))
    1206         {
    1207           struct stat s;
    1208           _execname(&execname[0], sizeof(execname));
    1209           strcpy(_getname(&execname[0]), "os2stub.bin");
    1210 
    1211           if (!stat (execname, &s))
    1212             {
    1213               sprintf (tmp, "/STUB:%s", &execname[0]);
    1214               put_arg (tmp, FALSE, FALSE);
    1215             }
    1216         }
    12171206    }
    12181207  put_arg ("/nol", FALSE, FALSE);
     
    12201209  put_arg ("/noi", FALSE, FALSE);
    12211210  put_arg ("/packc", FALSE, FALSE);
     1211
     1212 
     1213  /* VAC365: check if we have os2stub.bin.
     1214     We must to this after the above stuff else /nol might end up in the
     1215     response file and we'll get the component output. */
     1216
     1217  if (!stricmp (linker_type, "VAC365"))
     1218    {
     1219      struct stat s;
     1220      _execname(&execname[0], sizeof(execname));
     1221      strcpy(_getname(&execname[0]), "os2stub.bin");
     1222
     1223      if (!stat (execname, &s))
     1224        {
     1225          sprintf (tmp, "/STUB:%s", &execname[0]);
     1226          put_arg (tmp, FALSE, FALSE);
     1227        }
     1228    }
    12221229
    12231230  /* Add the /INFORMATION option if the -i or -t option was given.  This is
  • trunk/src/emx/src/emxomf/weakld.c

    • Property cvs2svn:cvs-rev changed from 1.16 to 1.17
    r540 r541  
    13691369    int         cch = *pachPascalString;
    13701370    const char *psz = pachPascalString + 1;
     1371    const char *pszWeak;
    13711372    int (*pfn)(const char *, const char *, size_t) = (pWld->fFlags & WLDC_CASE_INSENSITIVE) ? strnicmp : strncmp;
    13721373
     1374    /* look for weak suffix */
     1375    for (pszWeak = psz + cch - 1; pszWeak > psz; pszWeak--)
     1376        if (    pszWeak[0] == '$'
     1377            &&  pszWeak[1] == 'w'
     1378            &&  pszWeak[2] == '$')
     1379        {
     1380            cch = pszWeak - psz;
     1381            break;
     1382        }
     1383
     1384    /* compare */
    13731385    if (pSym)
    13741386        return !pfn(pSym->pszName, psz, cch) && !pSym->pszName[cch];
    13751387    else
    13761388    {
    1377 #if 1   /* hashed */
    1378         unsigned uHash = symHash(psz, cch);
     1389        /* @todo: this isn't 100% correct when we're talking case in sensitivity. */
     1390        unsigned uHash = symHash(psz, cch); 
    13791391        for (pSym = pWld->Global.ap[uHash]; pSym; pSym = pSym->pHashNext)
    13801392        {
     
    13851397            }
    13861398        }
    1387 #else
    1388         /* raw */
    1389         int i;
    1390         for (i = 0; i < sizeof(pWld->Global.ap) / sizeof(pWld->Global.ap[0]); i++)
    1391         {
    1392             for (pSym = pWld->Global.ap[i]; pSym; pSym = pSym->pHashNext);
    1393             {
    1394                 if ((pSym->fFlags & (WLDSF_TYPEMASK | WLDSF_WEAK)) == WLDSF_UNDEF)
    1395                 {
    1396                     if (!pfn(pSym->pszName, psz, cch) && !pSym->pszName[cch])
    1397                         return 1;
    1398                 }
    1399             }
    1400         }
    1401 #endif
    14021399    }
    14031400    return 0;
     
    14551452 * Actually if the symbol exists we'll perform any required symbol 'merger' and
    14561453 * either fail due to symbol errors or return the 'merged' one.
    1457  *
    1458  * We'll simply return existing symbol when:
    1459  *      1. adding a UNDEF where a PUBLIC, COMM, !WEAK UNDEF or IMPORT exists.
    1460  *      2. adding a WKEXT where a PUBLIC or COMM exists.
    1461  *      3. adding a WKEXT where a UNDEF which isn't UNCERTAIN exists.
    1462  *      4. adding a COMM where a !WEAK COMM exists.
    1463  *      5. adding a WEAK PUBLIC or WEAK COMM where a PUBLIC or COMM exists.
    1464  *      6. adding a WEAK UNDEF where WEAK UNDEF exists.
    1465  *
    1466  * We'll warn and return existing symbol when:
    1467  *      1. adding a IMPORT LIBSEARCH where a PUBLIC or COMM exists.
    1468  *
    1469  * We'll return upgraded existing symbol when:
    1470  *      1. adding a PUBLIC, COMM or IMPORT where a UNDEF or WKEXT exists.
    1471  *      2. adding a !WEAK PUBLIC or !WEAK COMM where a WEAK PUBLIC or WEAK COMM exists.
    1472  *      3. adding a !WEAK UNDEF where a WEAK UNDEF exists.
    1473  *      4. adding a UNDEF where a WKEXT exists.
    1474  *
    1475  * We'll warn and upgraded existing symbol when:
    1476  *      1. adding a PUBLIC or COMM where a IMPORT LIBSEARCH exists.
    1477  *
    1478  * The rest is failures.
    1479  *
    1480  * There migth be errors in the algorithm. Like adding the same import twice
    1481  * shouldn't harm anybody, but it's unlikely and it requires quite some extra parameters.
    1482  * Also the caller must resolve any conflicting exports (which normally only yields
    1483  * warnings anyway it seems).
    14841454 *
    14851455 * @returns Pointer to symbold.
     
    14961466 * @param   pflAction   What we actually did.
    14971467 *                      WLDSA_NEW, WLDSA_UP, WLDSA_OLD, WLDSA_ERR.
     1468 * @sketch
     1469 *
     1470 * We'll simply return existing symbol when:
     1471 *      1. adding a UNDEF where a PUBLIC, COMM, !WEAK UNDEF or IMPORT exists.
     1472 *      2. adding a WKEXT where a PUBLIC or COMM exists.
     1473 *      3. adding a WKEXT where a UNDEF which isn't UNCERTAIN exists.
     1474 *      4. adding a COMM where a !WEAK COMM exists.
     1475 *      5. adding a WEAK PUBLIC or WEAK COMM where a PUBLIC or COMM exists.
     1476 *      6. adding a WEAK UNDEF where WEAK UNDEF exists.
     1477 *
     1478 * We'll warn and return existing symbol when:
     1479 *      1. adding a IMPORT LIBSEARCH where a PUBLIC or COMM exists.
     1480 *
     1481 * We'll return upgraded existing symbol when:
     1482 *      1. adding a PUBLIC, COMM or IMPORT where a UNDEF or WKEXT exists.
     1483 *      2. adding a !WEAK PUBLIC or !WEAK COMM where a WEAK PUBLIC or WEAK COMM exists.
     1484 *      3. adding a !WEAK UNDEF where a WEAK UNDEF exists.
     1485 *      4. adding a UNDEF where a WKEXT exists.
     1486 *      5. adding a IMPORT where a WEAK exists.
     1487 *
     1488 * We'll warn and upgraded existing symbol when:
     1489 *      1. adding a PUBLIC or COMM where a IMPORT LIBSEARCH exists.
     1490 *
     1491 * The rest is failures.
     1492 *
     1493 * There migth be errors in the algorithm. Like adding the same import twice
     1494 * shouldn't harm anybody, but it's unlikely and it requires quite some extra parameters.
     1495 * Also the caller must resolve any conflicting exports (which normally only yields
     1496 * warnings anyway it seems).
     1497 *
    14981498 */
    14991499static PWLDSYM      symAdd(PWLD pWld, PWLDMOD pMod, unsigned fFlags, const char *pachName, int cchName, PWLDSYMACTION peAction)
     
    16111611         *      3. adding a !WEAK UNDEF where a WEAK UNDEF exists.
    16121612         *      4. adding a UNDEF where a WKEXT exists.
     1613         *      5. adding a IMPORT where a WEAK exists.
    16131614         */
    16141615        else
     
    16251626                (fFlags & WLDSF_TYPEMASK) == WLDSF_UNDEF
    16261627            &&  (pSym->fFlags & WLDSF_TYPEMASK) == WLDSF_WKEXT
     1628            ) || ( /* 5 */
     1629                (fFlags & WLDSF_TYPEMASK) == WLDSF_IMPORT
     1630            &&  (pSym->fFlags & WLDSF_WEAK) == WLDSF_WEAK
    16271631            ))
    16281632        {
     
    24422446 * @param   fFlags  Linker flags as defined by enum wld_create_flags.
    24432447 */
    2444 PWLD    wldCreate(unsigned fFlags)
     2448PWLD    WLDCreate(unsigned fFlags)
    24452449{
    24462450    PWLD    pWld = xmalloc(sizeof(*pWld));
     
    24662470 * @param   pWld    Linker instance to destroy.
    24672471 */
    2468 int     wldDestroy(PWLD pWld)
     2472int     WLDDestroy(PWLD pWld)
    24692473{
    24702474    PWLDMOD     pObj;
     
    25242528 *          or wld_generate_weaklib()!
    25252529 */
    2526 int     wldAddObject(PWLD pWld, FILE *phFile, const char *pszName)
     2530int     WLDAddObject(PWLD pWld, FILE *phFile, const char *pszName)
    25272531{
    25282532    OMFREC  OmfRec = {0,0};
     
    26142618 *                  On failure, we'll update the structures rc member.
    26152619 */
    2616 static int wldDefCallback(struct _md *pMD, const _md_stmt *pStmt, _md_token eToken, void *pvArg)
     2620static int      wldDefCallback(struct _md *pMD, const _md_stmt *pStmt, _md_token eToken, void *pvArg)
    26172621{
    26182622    unsigned        fFlags;
     
    27062710 *          or wld_generate_weaklib()!
    27072711 */
    2708 int     wldAddDefFile(PWLD pWld, FILE *phFile, const char *pszName)
     2712int     WLDAddDefFile(PWLD pWld, FILE *phFile, const char *pszName)
    27092713{
    27102714    struct _md *    pMD;
     
    27672771 * @author  Don't call wld_add_library after wld_generate_weaklib()!
    27682772 */
    2769 int     wldAddLibrary(PWLD pWld, FILE *phFile, const char *pszName)
     2773int     WLDAddLibrary(PWLD pWld, FILE *phFile, const char *pszName)
    27702774{
    27712775    PWLDLIB     pLib;
     
    28232827 * @param   pWld    Linker Instance.
    28242828 */
    2825 int     wldPass1(PWLD pWld)
     2829int     WLDPass1(PWLD pWld)
    28262830{
    28272831    int     fMore;
     
    28942898
    28952899
     2900/** Parameter structure for wldGenerateObjEnum(). */
    28962901typedef struct wldGenerateObjEnum_param
    28972902{
     
    29022907} WLDGOEPARAM, *PWLDGOEPARAM;
    29032908
    2904 #define GENERATE_LIBRARY
    29052909
    29062910/**
     
    29142918 * @param   pvUser  Pointer to a FILE stream.
    29152919 */
    2916 static int wldGenerateObjEnum(PWLD pWld, PWLDSYM pSym, void *pvUser)
     2920static int      wldGenerateObjEnum(PWLD pWld, PWLDSYM pSym, void *pvUser)
    29172921{
    29182922    if (pSym->pszWeakName)
     
    29472951        }
    29482952
    2949         #ifdef GENERATE_LIBRARY
    29502953        /* end the current object? */
    2951         if (pParam->cAliases > 32)
     2954        if ((pWld->fFlags & WLDC_LINKER_LINK386) && pParam->cAliases > 1)//32)
    29522955        {
    29532956            off_t   off;
     
    29652968       
    29662969        /* make new object ? */
    2967         if (!pParam->cAliases)
     2970        if ((pWld->fFlags & WLDC_LINKER_LINK386) && !pParam->cAliases)
    29682971        {
    29692972            omf.hdr.chType = THEADR;
     
    29782981            }
    29792982        }
    2980         #endif
     2983       
    29812984
    29822985        /* Alias record */
     
    30333036 *  copied to the new file.
    30343037 */
    3035 static int wldGenerateDefCallback(struct _md *pMD, const _md_stmt *pStmt, _md_token eToken, void *pvArg)
     3038static int      wldGenerateDefCallback(struct _md *pMD, const _md_stmt *pStmt, _md_token eToken, void *pvArg)
    30363039{
    30373040    PWLDGDCPARAM     pParam = (PWLDGDCPARAM)pvArg;
     
    31713174 *                      This is an empty string if changes was required!
    31723175 */
    3173 int     wldGenerateWeakAliases(PWLD pWld, char *pszObjName, char *pszDefName)
     3176int     WLDGenerateWeakAliases(PWLD pWld, char *pszObjName, char *pszDefName)
    31743177{
    31753178    FILE *      phFile;
     
    32523255    if (!rc && pszObjName)
    32533256    {
    3254         #ifdef GENERATE_LIBRARY
    3255         rc = wldTempFile(pWld, pszObjName, "wk", ".lib");
    3256         #else
    3257         rc = wldTempFile(pWld, pszObjName, "wk", ".obj");
    3258         #endif
     3257        rc = wldTempFile(pWld, pszObjName, "wk", (pWld->fFlags & WLDC_LINKER_LINK386) ? ".lib" : ".obj");
    32593258        if (!rc)
    32603259        {
     
    32623261
    32633262            /* open it */
    3264             phFile = fopen(pszObjName, "wr");
     3263            phFile = fopen(pszObjName, "wb");
    32653264            if (phFile)
    32663265            {
     
    32793278                off_t           offAlias;
    32803279
    3281                 #ifdef GENERATE_LIBRARY
    3282                 /* Write library file header. */
    3283                 memset(&omf, 0, sizeof(omf));
    3284                 omf.hdr.chType = LIBHDR;
    3285                 omf.hdr.cb = 32 - 3;
    3286                 omf.libhdr.offDict = 0;
    3287                 omf.libhdr.cDictBlocks = 0;
    3288                 omf.libhdr.fchFlags = 0;
    3289                
    3290                 #else
    3291                 /* Write object file header. */
    3292                 /* todo: link386 doesn't like if there are too many alias in one module btw. */
    3293                 int cch = strlen("wk.obj");
    3294                 omf.hdr.chType = THEADR;
    3295                 omf.hdr.cb = cch + 2;           /* name + crc */
    3296                 omf.ach[0] = cch;           /* module name */
    3297                 memcpy(&omf.ach[1], "wk.obj", cch);
    3298                 omf.ach[1+cch] = 0;         /* crc */
    3299                 #endif
     3280                if (pWld->fFlags & WLDC_LINKER_LINK386)
     3281                {
     3282                    /* Write library file header. */
     3283                    memset(&omf, 0, sizeof(omf));
     3284                    omf.hdr.chType = LIBHDR;
     3285                    omf.hdr.cb = 32 - 3;
     3286                    omf.libhdr.offDict = 0;
     3287                    omf.libhdr.cDictBlocks = 0;
     3288                    omf.libhdr.fchFlags = 1;
     3289                }
     3290                else
     3291                {
     3292                    /* Write object file header. */
     3293                    /* todo: link386 doesn't like if there are too many alias in one module btw. */
     3294                    int cch = strlen("wk.obj");
     3295                    omf.hdr.chType = THEADR;
     3296                    omf.hdr.cb = cch + 2;           /* name + crc */
     3297                    omf.ach[0] = cch;           /* module name */
     3298                    memcpy(&omf.ach[1], "wk.obj", cch);
     3299                    omf.ach[1+cch] = 0;         /* crc */
     3300                }
    33003301                fwrite(&omf, omf.hdr.cb + sizeof(OMFREC), 1, phFile);
    33013302
  • trunk/src/emx/src/emxomf/weakld.h

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r540 r541  
    4343    /** Case in-sensitive symbol resolution. */
    4444    WLDC_CASE_INSENSITIVE = 4,
     45    /** The linker is link386. */
     46    WLDC_LINKER_LINK386 = 0x1000,
    4547};
    4648
     
    5153/** @group Weak LD - Public methods.
    5254 * @{ */
    53 PWLD    wldCreate(unsigned fFlags);
    54 int     wldAddObject(PWLD pWld, FILE *phFile, const char *pszName);
    55 int     wldAddDefFile(PWLD pWld, FILE *phFile, const char *pszName);
    56 int     wldAddLibrary(PWLD pWld, FILE *phFile, const char *pszName);
    57 int     wldPass1(PWLD pWld);
    58 int     wldGenerateWeakAliases(PWLD pwld, char *pszObjName, char *pszDefName);
    59 int     wldDestroy(PWLD pWld);
     55PWLD    WLDCreate(unsigned fFlags);
     56int     WLDAddObject(PWLD pWld, FILE *phFile, const char *pszName);
     57int     WLDAddDefFile(PWLD pWld, FILE *phFile, const char *pszName);
     58int     WLDAddLibrary(PWLD pWld, FILE *phFile, const char *pszName);
     59int     WLDPass1(PWLD pWld);
     60int     WLDGenerateWeakAliases(PWLD pwld, char *pszObjName, char *pszDefName);
     61int     WLDDestroy(PWLD pWld);
    6062/** @} */
    6163
Note: See TracChangeset for help on using the changeset viewer.