Changeset 2235


Ignore:
Timestamp:
Jul 8, 2005, 9:28:00 AM (20 years ago)
Author:
bird
Message:

fixed linker problem with regards to dllexport.

File:
1 edited

Legend:

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

    • Property cvs2svn:cvs-rev changed from 1.32 to 1.33
    r2234 r2235  
    269269        WLDSF_EXPORT    = 0x1000,
    270270
     271        /** Internal flags which indicates that the symbol was exported in
     272         * the definition file. This to select symbols which only appears in
     273         * __declspec(dllexport) and put them into the definition file for
     274         * proper weak handling. */
     275        WLDSF_EXPORT_DEF = 0x2000,
     276
    271277        /** Internal flag to say that we've already aliased this weak
    272278         * in the definition file.
     
    277283         * truncated by emxomf. */
    278284        WLDSF_TRUNCATED = 0x10000,
    279 
    280285    }                   fFlags;
    281286
     
    35443549    /** Our current linenumber index. */
    35453550    unsigned    iLine;
     3551    /** Set if we have processed any weak __declspec(dllexport) symbols. */
     3552    unsigned    fWeakDllExport;
    35463553} WLDGDCPARAM, *PWLDGDCPARAM;
    35473554
     
    35943601
    35953602            WLDDBG2(("wldGenerateDefCallback: '%s', '%s'", pSymExp->pszName, pSymInt ? pSymInt->pszName : "<the-same-name>"));
     3603
     3604            /* mark the exported symbol exported. */
     3605            pSymExp->fFlags |= WLDSF_EXPORT_DEF;
    35963606
    35973607            /* Skip it all if neither of the symbols are weak. */
     
    36613671
    36623672/**
     3673 * Checks the __declspec(dllexport) symbols for weak symbols.
     3674 * When a weak export is found, it will be added to the .def file.
     3675 *
     3676 * @returns 0 on success
     3677 * @returns !0 on failure after writing sufficient error message.
     3678 * @param   pWld    Linker instance.
     3679 * @param   pSym    Symbol.
     3680 * @param   pvUser  Pointer to a WLDGDCPARAM struct.
     3681 */
     3682static int      wldGenerateDefExportEnum(PWLD pWld, PWLDSYM pSym, void *pvUser)
     3683{
     3684    PWLDGDCPARAM     pParam = (PWLDGDCPARAM)pvUser;
     3685
     3686    if (!pParam->fWeakDllExport)
     3687    {
     3688        /* copy the rest of the file if any changes was made. */
     3689        char szTmp[512];
     3690        while (!feof(pParam->phOrgFile) && fgets(szTmp, sizeof(szTmp), pParam->phOrgFile))
     3691            if (fputs(szTmp, pParam->phNewFile) < 0)
     3692                return wldErr(pWld, "Write error.");
     3693
     3694        if (fputs("\n"
     3695                  "; weakld added weak __declspec(dllexport) exports\n"
     3696                  "EXPORTS\n",
     3697                  pParam->phNewFile) < 0)
     3698            return wldErr(pWld, "Write error.");
     3699        pParam->fWeakDllExport = 1;
     3700    }
     3701
     3702    /*
     3703     * Now generate the export entry.
     3704     */
     3705    if (!pSym->pAliasFor)
     3706    {
     3707        WLDINFO(pWld, ("Adding __declspec(dllexport) weak symbol '%s' to the definition aliasing '%s'",
     3708                       pSym->pszName, pSym->pszWeakName));
     3709        fprintf(pParam->phNewFile, "    \"%s\" = \"%s\"\n",
     3710                pSym->pszName, pSym->pszWeakName);
     3711    }
     3712    else
     3713    {
     3714        WLDINFO(pWld, ("Adding __declspec(dllexport) weak symbol '%s' to the definition aliasing '%s' (alias)",
     3715                       pSym->pszName,
     3716                       pSym->pAliasFor->pszWeakName ? pSym->pAliasFor->pszWeakName : pSym->pAliasFor->pszName));
     3717        fprintf(pParam->phNewFile, "    \"%s\" = \"%s\"\n",
     3718                pSym->pszName,
     3719                pSym->pAliasFor->pszWeakName ? pSym->pAliasFor->pszWeakName : pSym->pAliasFor->pszName);
     3720    }
     3721    if (ferror(pParam->phNewFile))
     3722        return wldErr(pWld, "Write error.");
     3723    return 0;
     3724}
     3725
     3726
     3727/**
    36633728 * Generates an unique temporary file.
    36643729 *
     
    37453810                        param.phNewFile = phFile;
    37463811                        param.iLine = 0;
     3812                        param.fWeakDllExport = 0;
    37473813
    37483814                        /* parse it */
     
    37503816                        rc = _md_parse(pMD, wldGenerateDefCallback, &param);
    37513817                        _md_close(pMD);
     3818
     3819                        /* now see if there are any aliases in __declspec(dllexport) statements. */
     3820                        if (!rc)
     3821                            rc = symEnum(pWld, &pWld->Global,
     3822                                         WLDSF_EXPORT | WLDSF_WEAK, WLDSF_EXPORT | WLDSF_WEAK | WLDSF_EXPORT_DEF | WLDSF_WEAKALIASDONE,
     3823                                         wldGenerateDefExportEnum, &param);
    37523824
    37533825                        /* copy the rest of the file if any changes was made. */
     
    37593831                                    rc = wldErr(pWld, "Write error.");
    37603832                        }
    3761                         else if (!rc)
     3833                        else if (!rc && !param.fWeakDllExport)
    37623834                        {
    3763                             /* no changes was made. */
     3835                            /* no changes were made. */
    37643836                            WLDINFO(pWld, ("No weak exports, removing file."));
    37653837                            fclose(phFile);
Note: See TracChangeset for help on using the changeset viewer.