Changeset 479
- Timestamp:
- Jul 30, 2003, 2:13:59 AM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/src/emxomf/emxomf.c
-
Property cvs2svn:cvs-rev
changed from
1.16
to1.17
r478 r479 33 33 #include <sys/types.h> 34 34 #include <sys/stat.h> 35 #include <sys/time.h> 35 36 #include <ar.h> 36 37 … … 260 261 /* Remove underscores from all symbol names */ 261 262 static int opt_rmunder = FALSE; 263 264 /* Add timestamp to symbol to make it more unique. */ 265 static int opt_weakts = FALSE; 262 266 263 267 /* This is the page size for OMF libraries. It is set by the -p … … 343 347 static char mod_name[256]; 344 348 349 /* This variable holds a normalized module name used with weak syms. See get_mod_name(). */ 350 static char weak_mod_name[256]; 351 345 352 /* This growing array holds the file name table for generating line 346 353 number information. */ … … 573 580 if (t == N_TEXT || t == N_DATA || t == N_BSS 574 581 /* kso #465 2003-06-04: Find weak symbols too. */ 575 || t == N_WEAKT || t == N_WEAKD || t == N_WEAKB 576 || t == N_WEAKA /* hmm.. */ 582 || (t >= N_WEAKA && t <= N_WEAKB) 577 583 || (t == 0 && sym_ptr[j].n_value != 0)) 578 584 return sym_ptr+j; … … 622 628 return; 623 629 624 /* Find and open the weak symbol list file 630 /* Find and open the weak symbol list file 625 631 #483: If not present we'll use the new method. */ 626 632 weak_list_filename = getenv ("GCC_WEAKSYMS"); … … 1147 1153 int i; 1148 1154 1155 if (!weak_list_filename) 1156 return; 1157 1149 1158 #define SETTYPE(t) ((struct nlist *)sym_ptr)[i].n_type = t 1150 1159 … … 1192 1201 * Generates new names for weak symbols. 1193 1202 * 1194 * These names will be catch bye emxomfld and an alias from the generated to 1203 * These names will be catch bye emxomfld and an alias from the generated to 1195 1204 * the real name will be generated and put in a library before linking. 1196 1205 * … … 1203 1212 * @remark I'm sorry this function is written in my coding style - not! 1204 1213 */ 1205 static char *weak_process_name(struct nlist *pSym, char *pszOrgName, char *pachName, int cchName)); 1206 { 1207 for (i = 0; i < sym_count; ++i) 1208 { 1209 1210 switch (sym_ptr->n_type) 1214 static const char *weak_process_name(const struct nlist *pSym, const char *pszOrgName, char *pachName, int cchName) 1215 { 1216 switch (sym_ptr->n_type) 1217 { 1218 /* 1219 * Hmmm... Check that we handle this correctly else where 1220 */ 1221 case N_WEAKU: /* 0x0d Weak undefined symbol. */ 1222 default: 1223 break; 1224 1225 /* 1226 * These symbols are defined in this module, so we need to 1227 * make a unique and recognizable name for them. 1228 */ 1229 case N_WEAKA: /* 0x0e Weak absolute symbol. */ 1230 case N_WEAKT: /* 0x0f Weak text symbol. */ 1231 case N_WEAKD: /* 0x10 Weak data symbol. */ 1232 case N_WEAKB: /* 0x11 Weak bss symbol. */ 1211 1233 { 1212 /* 1213 * Hmmm... Check that we handle this correctly else where 1214 */ 1215 case N_WEAKU: /* 0x0d Weak undefined symbol. */ 1216 break; 1217 1218 /* 1219 * I'm uncertain what this means, needs to google 1220 * for and explanation of how this is used. 1221 */ 1222 case N_WEAKA: /* 0x0e Weak absolute symbol. */ 1223 break; 1224 1225 /* 1226 * These symbols are defined in this module, so we need to 1227 * make a unique and recognizable name for them. 1228 */ 1229 case N_WEAKT: /* 0x0f Weak text symbol. */ 1230 case N_WEAKD: /* 0x10 Weak data symbol. */ 1231 case N_WEAKB: /* 0x11 Weak bss symbol. */ 1234 if (!opt_weakts) 1235 snprintf(pachName, cchName, "%s$w$%s", 1236 pszOrgName, weak_mod_name); 1237 else 1232 1238 { 1233 int cch = strlen(pszOrgName);1234 memcpy(pachName, pszOrgName, cch);1235 1236 break;1239 struct timeval tv = {0, 0}; 1240 gettimeofday(&tv, NULL); 1241 snprintf(pachName, cchName, "%s$w$%s%lx%lx", 1242 pszOrgName, weak_mod_name, tv.tv_sec, tv.tv_usec); 1237 1243 } 1244 return pachName; 1238 1245 } 1239 } 1246 1247 } 1248 /* default is to keep the original name */ 1249 return pszOrgName; 1240 1250 } 1241 1251 … … 1296 1306 const char *name, *pub_name; 1297 1307 dword address; 1298 char szName[2 60];1308 char szName[256]; 1299 1309 1300 1310 started = FALSE; 1301 1311 for (i = 0; i < sym_count; ++i) 1302 if ((sym_ptr[i].n_type & ~N_EXT) == type) 1312 if ( (sym_ptr[i].n_type & ~N_EXT) == type 1313 || (type >= N_WEAKU && type <= N_WEAKB && sym_ptr[i].n_type == type) 1314 ) 1303 1315 { 1304 1316 address = sym_ptr[i].n_value - start; … … 1308 1320 if ( (sym_ptr[i].n_type & N_EXT) 1309 1321 || (type == N_TEXT && strncmp (name, "___POST$", 8) == 0) 1310 || (sym_ptr[i].n_type >= N_WEAKU && sym_ptr[i].n_type <= N_WEAKB) 1311 ) 1322 || (sym_ptr[i].n_type >= N_WEAKU && sym_ptr[i].n_type <= N_WEAKB) ) 1312 1323 { 1313 1324 if ((sym_ptr[i].n_type & N_EXT) && out_lib != NULL) … … 1320 1331 error (lib_errmsg); 1321 1332 } 1322 1333 1323 1334 /* for weaksymbols we may have to decorate the name */ 1324 1335 if ( !weak_list_filename 1325 && sym_ptr[i].n_type >= N_WEAKU 1326 && sym_ptr[i].n_type <= N_WEAKB 1327 ) 1328 name = weak_process_name(sym_ptr[i], name, szName, sizeof(szName)); 1336 && sym_ptr[i].n_type >= N_WEAKU && sym_ptr[i].n_type <= N_WEAKB ) 1337 name = weak_process_name(&sym_ptr[i], name, szName, sizeof(szName)); 1329 1338 1330 1339 if (started && !fits (strlen (name) + 6)) … … 1401 1410 write_pubdef1 (N_TEXT, text_index, FALSE, 0); 1402 1411 write_pubdef1 (N_TEXT, text_index, TRUE, 0); 1403 if (!w rite_pubdef_main)1412 if (!weak_list_filename) 1404 1413 { 1405 1414 write_pubdef1 (N_WEAKT, text_index, FALSE, 0); … … 1410 1419 write_pubdef1 (N_DATA, udat_index, FALSE, text_size); 1411 1420 write_pubdef1 (N_DATA, udat_index, TRUE, text_size); 1412 if (!w rite_pubdef_main)1421 if (!weak_list_filename) 1413 1422 { 1414 1423 write_pubdef1 (N_WEAKD, text_index, FALSE, 0); … … 1417 1426 write_pubdef1 (N_BSS, bss_index, FALSE, text_size + data_size); 1418 1427 write_pubdef1 (N_BSS, bss_index, TRUE, text_size + data_size); 1419 if (!w rite_pubdef_main)1428 if (!weak_list_filename) 1420 1429 { 1421 1430 write_pubdef1 (N_WEAKB, bss_index, FALSE, text_size + data_size); … … 2711 2720 int i, len, ok; 2712 2721 const char *p1, *p2; 2722 char *p3; 2713 2723 2714 2724 ok = FALSE; … … 2734 2744 _strncpy (mod_name, p1, sizeof (mod_name)); 2735 2745 } 2746 2747 /* Find the base name and lenght (excluding extension) 2748 This is used for weak symbol handling. */ 2749 for (p1 = "\\/:", p2 = mod_name; *p1; p1++) 2750 if ((p3 = strrchr(p2, *p1)) != NULL) 2751 p2 = p3 + 1; 2752 for (p3 = weak_mod_name; *p2; p2++) 2753 if (isalnum(*p2) || *p2 == '$' || *p2 == '_' || *p2 == '@') 2754 *p3++ = *p2; 2755 *p3 = '\0'; 2736 2756 } 2737 2757 … … 2919 2939 2920 2940 2921 /* 2922 * If no lines or no files, we don't want to issue any LINNUM records. 2941 /* 2942 * If no lines or no files, we don't want to issue any LINNUM records. 2923 2943 */ 2924 2944 if (valid_lines <= 0 || file_grow.count <= 0) … … 3302 3322 write_debug_style (); 3303 3323 3304 /* Method 2 Weak symbol processing (generate names). */3305 3306 weak_process_names();3307 3308 3324 /* Define all the OMF names (LNAMES record). Of course, we must not 3309 3325 define new OMF names after this point. */ … … 3461 3477 puts (" -I <idmdll> Name the identifier manipulation DLL"); 3462 3478 puts (" -O <directory> Extract files to <directory>"); 3479 puts (" -t Add timestamping to the weak symbol mangling"); 3463 3480 puts (" -w Suppress reading/writing of the weaksyms.omf file"); 3464 3481 puts (" -z Remove underscores from all symbol names"); … … 3958 3975 opt_rmunder = TRUE; 3959 3976 break; 3977 case 't': 3978 opt_weakts = TRUE; 3979 break; 3960 3980 default: 3961 3981 usage (); -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.