Changeset 541
- Timestamp:
- Aug 6, 2003, 9:47:24 PM (22 years ago)
- 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
to1.21
r540 r541 1337 1337 || (sym_ptr[i].n_type >= N_WEAKU && sym_ptr[i].n_type <= N_WEAKB) ) 1338 1338 { 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 ) ) 1340 1350 { 1341 1351 pub_name = name; … … 1346 1356 error (lib_errmsg); 1347 1357 } 1348 1349 /* for weaksymbols we may have to decorate the name */1350 if ( !weak_list_filename1351 && 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));1353 1358 1354 1359 if (started && !fits (strlen (name) + 6)) … … 3678 3683 calculated_page_size <<= 1; 3679 3684 } 3680 if (1)3681 printf("calculated page size %d\n", calculated_page_size);3682 3685 } 3683 3686 … … 3890 3893 opt_o = NULL; opt_O = NULL; 3891 3894 opterr = FALSE; 3895 3896 tmp = getenv("EMXOMFLD_TYPE"); 3897 if (tmp && !stricmp(tmp, "LINK386")) 3898 hll_version = 3; 3892 3899 3893 3900 /* Parse the command line options. */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/emxomf/emxomfld.c
-
Property cvs2svn:cvs-rev
changed from
1.21
to1.22
r540 r541 640 640 if (opt_t) 641 641 fFlags |= WLDC_VERBOSE; 642 if (!stricmp(linker_type, "LINK386")) 643 fFlags |= WLDC_LINKER_LINK386; 644 642 645 for (pOpt = options; pOpt; pOpt = pOpt->next) 643 646 if ( !strnicmp(pOpt->name, "/NOE", 4) … … 668 671 if (opt_t) 669 672 fprintf(stderr, "*** Invoking weak prelinker with flags %x.\n", fFlags); 670 pwld = wldCreate (fFlags);673 pwld = WLDCreate (fFlags); 671 674 if (pwld) 672 675 { … … 679 682 { 680 683 phfile = fopen (def_fname, "r"); 681 rc = wldAddDefFile (pwld, phfile, def_fname);684 rc = WLDAddDefFile (pwld, phfile, def_fname); 682 685 } 683 686 … … 687 690 static const char * objexts[] = { ".obj", ".o", NULL }; 688 691 phfile = find_objlib (szname, pcur->name, objexts, TRUE); 689 rc = wldAddObject (pwld, phfile, szname);692 rc = WLDAddObject (pwld, phfile, szname); 690 693 } 691 694 … … 695 698 static const char * libexts[] = { ".lib", ".a", NULL }; 696 699 phfile = find_objlib (szname, pcur->name, libexts, TRUE); 697 rc = wldAddLibrary (pwld, phfile, szname);700 rc = WLDAddLibrary (pwld, phfile, szname); 698 701 free(pcur->name); 699 702 pcur->name = xstrdup(szname); … … 703 706 if (!rc) 704 707 { 705 rc = wldPass1 (pwld);708 rc = WLDPass1 (pwld); 706 709 /* ignore unresolved externals for now. */ 707 710 if (rc == 42) … … 714 717 /* generate weak aliases. */ 715 718 if (!rc) 716 rc = wldGenerateWeakAliases (pwld, weakobj_fname, weakdef_fname);719 rc = WLDGenerateWeakAliases (pwld, weakobj_fname, weakdef_fname); 717 720 if (!rc && weakobj_fname[0]) 718 721 add_name_list (&add_obj_fnames, weakobj_fname); 719 722 if (!rc && weakdef_fname[0]) 720 strcpy (def_fname, weakdef_fname);723 def_fname = weakdef_fname; 721 724 722 725 /* cleanup the linker */ 723 wldDestroy (pwld);726 WLDDestroy (pwld); 724 727 725 728 /* last words */ … … 1089 1092 } 1090 1093 1091 /* Build the environment for LINK386. */1094 /* Build the environment for the linker. */ 1092 1095 1093 1096 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 else1101 {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 }1117 1097 1118 1098 /* EMXOMFLD_TYPE contains VAC365, VAC308 or LINK386 if set. If non of these … … 1139 1119 1140 1120 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 } 1141 1144 1142 1145 /* Start building the linker command line. We can use a response … … 1201 1204 if (map_flag) 1202 1205 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 }1217 1206 } 1218 1207 put_arg ("/nol", FALSE, FALSE); … … 1220 1209 put_arg ("/noi", FALSE, FALSE); 1221 1210 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 } 1222 1229 1223 1230 /* Add the /INFORMATION option if the -i or -t option was given. This is -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/emxomf/weakld.c
-
Property cvs2svn:cvs-rev
changed from
1.16
to1.17
r540 r541 1369 1369 int cch = *pachPascalString; 1370 1370 const char *psz = pachPascalString + 1; 1371 const char *pszWeak; 1371 1372 int (*pfn)(const char *, const char *, size_t) = (pWld->fFlags & WLDC_CASE_INSENSITIVE) ? strnicmp : strncmp; 1372 1373 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 */ 1373 1385 if (pSym) 1374 1386 return !pfn(pSym->pszName, psz, cch) && !pSym->pszName[cch]; 1375 1387 else 1376 1388 { 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); 1379 1391 for (pSym = pWld->Global.ap[uHash]; pSym; pSym = pSym->pHashNext) 1380 1392 { … … 1385 1397 } 1386 1398 } 1387 #else1388 /* 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 #endif1402 1399 } 1403 1400 return 0; … … 1455 1452 * Actually if the symbol exists we'll perform any required symbol 'merger' and 1456 1453 * 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 twice1481 * 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 yields1483 * warnings anyway it seems).1484 1454 * 1485 1455 * @returns Pointer to symbold. … … 1496 1466 * @param pflAction What we actually did. 1497 1467 * 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 * 1498 1498 */ 1499 1499 static PWLDSYM symAdd(PWLD pWld, PWLDMOD pMod, unsigned fFlags, const char *pachName, int cchName, PWLDSYMACTION peAction) … … 1611 1611 * 3. adding a !WEAK UNDEF where a WEAK UNDEF exists. 1612 1612 * 4. adding a UNDEF where a WKEXT exists. 1613 * 5. adding a IMPORT where a WEAK exists. 1613 1614 */ 1614 1615 else … … 1625 1626 (fFlags & WLDSF_TYPEMASK) == WLDSF_UNDEF 1626 1627 && (pSym->fFlags & WLDSF_TYPEMASK) == WLDSF_WKEXT 1628 ) || ( /* 5 */ 1629 (fFlags & WLDSF_TYPEMASK) == WLDSF_IMPORT 1630 && (pSym->fFlags & WLDSF_WEAK) == WLDSF_WEAK 1627 1631 )) 1628 1632 { … … 2442 2446 * @param fFlags Linker flags as defined by enum wld_create_flags. 2443 2447 */ 2444 PWLD wldCreate(unsigned fFlags)2448 PWLD WLDCreate(unsigned fFlags) 2445 2449 { 2446 2450 PWLD pWld = xmalloc(sizeof(*pWld)); … … 2466 2470 * @param pWld Linker instance to destroy. 2467 2471 */ 2468 int wldDestroy(PWLD pWld)2472 int WLDDestroy(PWLD pWld) 2469 2473 { 2470 2474 PWLDMOD pObj; … … 2524 2528 * or wld_generate_weaklib()! 2525 2529 */ 2526 int wldAddObject(PWLD pWld, FILE *phFile, const char *pszName)2530 int WLDAddObject(PWLD pWld, FILE *phFile, const char *pszName) 2527 2531 { 2528 2532 OMFREC OmfRec = {0,0}; … … 2614 2618 * On failure, we'll update the structures rc member. 2615 2619 */ 2616 static int wldDefCallback(struct _md *pMD, const _md_stmt *pStmt, _md_token eToken, void *pvArg)2620 static int wldDefCallback(struct _md *pMD, const _md_stmt *pStmt, _md_token eToken, void *pvArg) 2617 2621 { 2618 2622 unsigned fFlags; … … 2706 2710 * or wld_generate_weaklib()! 2707 2711 */ 2708 int wldAddDefFile(PWLD pWld, FILE *phFile, const char *pszName)2712 int WLDAddDefFile(PWLD pWld, FILE *phFile, const char *pszName) 2709 2713 { 2710 2714 struct _md * pMD; … … 2767 2771 * @author Don't call wld_add_library after wld_generate_weaklib()! 2768 2772 */ 2769 int wldAddLibrary(PWLD pWld, FILE *phFile, const char *pszName)2773 int WLDAddLibrary(PWLD pWld, FILE *phFile, const char *pszName) 2770 2774 { 2771 2775 PWLDLIB pLib; … … 2823 2827 * @param pWld Linker Instance. 2824 2828 */ 2825 int wldPass1(PWLD pWld)2829 int WLDPass1(PWLD pWld) 2826 2830 { 2827 2831 int fMore; … … 2894 2898 2895 2899 2900 /** Parameter structure for wldGenerateObjEnum(). */ 2896 2901 typedef struct wldGenerateObjEnum_param 2897 2902 { … … 2902 2907 } WLDGOEPARAM, *PWLDGOEPARAM; 2903 2908 2904 #define GENERATE_LIBRARY2905 2909 2906 2910 /** … … 2914 2918 * @param pvUser Pointer to a FILE stream. 2915 2919 */ 2916 static int wldGenerateObjEnum(PWLD pWld, PWLDSYM pSym, void *pvUser)2920 static int wldGenerateObjEnum(PWLD pWld, PWLDSYM pSym, void *pvUser) 2917 2921 { 2918 2922 if (pSym->pszWeakName) … … 2947 2951 } 2948 2952 2949 #ifdef GENERATE_LIBRARY2950 2953 /* end the current object? */ 2951 if ( pParam->cAliases >32)2954 if ((pWld->fFlags & WLDC_LINKER_LINK386) && pParam->cAliases > 1)//32) 2952 2955 { 2953 2956 off_t off; … … 2965 2968 2966 2969 /* make new object ? */ 2967 if ( !pParam->cAliases)2970 if ((pWld->fFlags & WLDC_LINKER_LINK386) && !pParam->cAliases) 2968 2971 { 2969 2972 omf.hdr.chType = THEADR; … … 2978 2981 } 2979 2982 } 2980 #endif2983 2981 2984 2982 2985 /* Alias record */ … … 3033 3036 * copied to the new file. 3034 3037 */ 3035 static int wldGenerateDefCallback(struct _md *pMD, const _md_stmt *pStmt, _md_token eToken, void *pvArg)3038 static int wldGenerateDefCallback(struct _md *pMD, const _md_stmt *pStmt, _md_token eToken, void *pvArg) 3036 3039 { 3037 3040 PWLDGDCPARAM pParam = (PWLDGDCPARAM)pvArg; … … 3171 3174 * This is an empty string if changes was required! 3172 3175 */ 3173 int wldGenerateWeakAliases(PWLD pWld, char *pszObjName, char *pszDefName)3176 int WLDGenerateWeakAliases(PWLD pWld, char *pszObjName, char *pszDefName) 3174 3177 { 3175 3178 FILE * phFile; … … 3252 3255 if (!rc && pszObjName) 3253 3256 { 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"); 3259 3258 if (!rc) 3260 3259 { … … 3262 3261 3263 3262 /* open it */ 3264 phFile = fopen(pszObjName, "w r");3263 phFile = fopen(pszObjName, "wb"); 3265 3264 if (phFile) 3266 3265 { … … 3279 3278 off_t offAlias; 3280 3279 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 } 3300 3301 fwrite(&omf, omf.hdr.cb + sizeof(OMFREC), 1, phFile); 3301 3302 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/emxomf/weakld.h
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r540 r541 43 43 /** Case in-sensitive symbol resolution. */ 44 44 WLDC_CASE_INSENSITIVE = 4, 45 /** The linker is link386. */ 46 WLDC_LINKER_LINK386 = 0x1000, 45 47 }; 46 48 … … 51 53 /** @group Weak LD - Public methods. 52 54 * @{ */ 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);55 PWLD WLDCreate(unsigned fFlags); 56 int WLDAddObject(PWLD pWld, FILE *phFile, const char *pszName); 57 int WLDAddDefFile(PWLD pWld, FILE *phFile, const char *pszName); 58 int WLDAddLibrary(PWLD pWld, FILE *phFile, const char *pszName); 59 int WLDPass1(PWLD pWld); 60 int WLDGenerateWeakAliases(PWLD pwld, char *pszObjName, char *pszDefName); 61 int WLDDestroy(PWLD pWld); 60 62 /** @} */ 61 63 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.