Changeset 2001
- Timestamp:
- Jun 6, 2005, 4:13:06 AM (20 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/ChangeLog.LIBC
-
Property cvs2svn:cvs-rev
changed from
1.50
to1.51
r2000 r2001 8 8 o Default TCPIP mode is __USB_LIBC_TCPIP. When either TCPV40HDRS or TCPV41HDRS 9 9 are defined we are in strict mode and __USB_LIBC_TCPIP will not be defined. 10 11 10 - libomflib, emxomfar: 12 11 o Allow multiple modules by the same basename. This is not in tradition with 13 12 other librarians, but it solves incompatible behaviour between emxomfar and ar. 14 15 13 - ld: 16 14 o Avoid using alloca since we might easily run out of stack for big objects 17 15 with debuginfo. 16 - emxomf: 17 o Added support for new EMX a.out stab N_EXP (0x6c). This encodes export 18 definitions. (gcc can do __declspec(dllexport) now.) 19 TODO: ld needs updating, probably this is the right time to drop the 20 old ld and fixup the binutils port! 18 21 19 22 2005-05-08: knut st. osmundsen <bird-gccos2-spam@anduin.net> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/a_out.h
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r2000 r2001 141 141 #define N_WEAKB 0x11 /* Weak bss symbol. */ 142 142 /* emx */ 143 #define N_IMP1 0x68 /* Import definitionsymbol */143 #define N_IMP1 0x68 /* Import reference symbol */ 144 144 #define N_IMP2 0x6a /* Import definition symbol */ 145 #define N_EXP 0x6c /* Export definition symbol */ 145 146 146 147 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/omflib.h
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r2000 r2001 78 78 79 79 #if !defined (IMPDEF_CLASS) 80 #define IMPDEF_CLASS 0xa080 #define IMPDEF_CLASS CLASS_OMFEXT 81 81 #define LIBMOD_CLASS 0xa3 82 #define IMPDEF_SUBTYPE 0x0182 #define IMPDEF_SUBTYPE OMFEXT_IMPDEF 83 83 #endif 84 84 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/emxomf/emxomf.c
-
Property cvs2svn:cvs-rev
changed from
1.41
to1.42
r2000 r2001 575 575 { 576 576 int sym_ofs = i; 577 s = name;578 if (strip_underscore ( str_ptr + i))577 s = (const byte *)name; 578 if (strip_underscore ((const char *)(str_ptr + i))) 579 579 ++i; 580 580 if (memcmp (name, str_ptr+i, len+1) == 0) … … 594 594 } 595 595 } 596 i += strlen ( str_ptr+i) + 1;596 i += strlen ((const char *)(str_ptr + i)) + 1; 597 597 } 598 598 return NULL; /* Symbol not found */ … … 917 917 918 918 919 /* Put the null-terminatedstring pszName into the current OMF record.919 /* Put the string pszName into the current OMF record. 920 920 In the OMF record, the string is preceded by a length byte. The 921 921 string length must not exceed 255; if it is too long, display a … … 924 924 message and abort. */ 925 925 926 static void put_str(const char *pszName) 927 { 928 int cch = strlen(pszName); 926 static void put_nstr(const char *pszName, size_t cch) 927 { 929 928 if (cch > 255) 930 929 { … … 937 936 const char *psz; 938 937 unsigned uHash; 939 for (psz = pszName, uHash = 5381 ; *psz; psz++)/* hash alg: original djb2. */938 for (psz = pszName, uHash = 5381, cch2 = cch; cch > 0; psz++, cch--) /* hash alg: original djb2. */ 940 939 uHash += (uHash << 5) + *psz; 941 940 cch2 = sprintf(szHash, "!_%X", 0x7fffffff & uHash); … … 958 957 out_idx += cch; 959 958 } 959 } 960 961 /* Put the null-terminated string pszName into the current OMF record. 962 See put_nstr() for full details on string handling. */ 963 964 static void put_str(const char *pszName) 965 { 966 int cch = strlen(pszName); 967 put_nstr(pszName, cch); 960 968 } 961 969 … … 1059 1067 and quit. */ 1060 1068 1061 static void put_mem (const char*src, int size)1069 static void put_mem (const void *src, int size) 1062 1070 { 1063 1071 if (!fits (size)) … … 1147 1155 else if (sym_ptr[i].n_type == N_EXT && sym_ptr[i].n_value == 0) 1148 1156 { 1149 name = str_ptr + sym_ptr[i].n_un.n_strx;1157 name = (const char *)(str_ptr + sym_ptr[i].n_un.n_strx); 1150 1158 sym_more[i].index = sym_index++; 1151 1159 if (memcmp (name, "_16_", 4) == 0) … … 1161 1169 } 1162 1170 sym_more[i].index = sym_index++; 1163 add_extdef (&started, str_ptr + sym_ptr[i].n_un.n_strx, sym_more[i].hll_type);1171 add_extdef (&started, (const char *)(str_ptr + sym_ptr[i].n_un.n_strx), sym_more[i].hll_type); 1164 1172 } 1165 1173 #if 1 /* this isn't actually required if only the assembler could do what it's supposed to... */ … … 1168 1176 external records for this, perhaps... 1169 1177 At least I can't see why this will be wrong. */ 1170 name = str_ptr + sym_ptr[i].n_un.n_strx;1178 name = (const char *)(str_ptr + sym_ptr[i].n_un.n_strx); 1171 1179 sym_more[i].index = sym_index++; 1172 1180 add_extdef (&started, name, sym_more[i].hll_type); … … 1227 1235 if ((sym_ptr[i].n_type >= N_WEAKA) && (sym_ptr[i].n_type <= N_WEAKB)) 1228 1236 { 1229 const char *name = str_ptr + sym_ptr[i].n_un.n_strx;1237 const char *name = (const char *)(str_ptr + sym_ptr[i].n_un.n_strx); 1230 1238 1231 1239 int public = N_EXT; … … 1401 1409 { 1402 1410 init_rec (ALIAS); 1403 put_sym ( str_ptr + sym_ptr[i].n_un.n_strx);1404 put_sym ( str_ptr + sym_ptr[i+1].n_un.n_strx);1411 put_sym ((const char *)(str_ptr + sym_ptr[i].n_un.n_strx)); 1412 put_sym ((const char *)(str_ptr + sym_ptr[i+1].n_un.n_strx)); 1405 1413 write_rec (); 1406 1414 1407 1415 if (out_lib != NULL) 1408 1416 { 1409 pub_name = str_ptr + sym_ptr[i].n_un.n_strx;1417 pub_name = (const char *)(str_ptr + sym_ptr[i].n_un.n_strx); 1410 1418 if (strip_underscore (pub_name)) 1411 1419 ++pub_name; … … 1454 1462 if ((address >= 0x10000 || force_big) == big) 1455 1463 { 1456 name = str_ptr + sym_ptr[i].n_un.n_strx;1464 name = (const char *)(str_ptr + sym_ptr[i].n_un.n_strx); 1457 1465 if ( (sym_ptr[i].n_type & N_EXT) 1458 1466 || (type == N_TEXT && strncmp (name, "___POST$", 8) == 0) … … 1518 1526 if ((sym_ptr[i].n_type & ~N_EXT) == N_TEXT) 1519 1527 { 1520 const char * name = str_ptr + sym_ptr[i].n_un.n_strx;1528 const char * name = (const char *)(str_ptr + sym_ptr[i].n_un.n_strx); 1521 1529 dword address = sym_ptr[i].n_value; 1522 1530 if ( (sym_ptr[i].n_type & N_EXT) … … 1610 1618 else if (sym_ptr[i].n_type == N_EXT && sym_ptr[i].n_value != 0) 1611 1619 { 1612 name = str_ptr + sym_ptr[i].n_un.n_strx;1620 name = (const char *)(str_ptr + sym_ptr[i].n_un.n_strx); 1613 1621 sym_more[i].index = sym_index++; 1614 1622 if (memcmp (name, "_16_", 4) == 0) … … 1628 1636 put_idx (0); /* Type index */ 1629 1637 put_8 (0x62); /* Data type */ 1638 if (size < 4) 1639 size = 4; /* VAC308 ilink freaks out if size = 1 or something */ 1630 1640 if (size < 0x80) 1631 1641 put_8 (size); … … 2224 2234 this set is already known. */ 2225 2235 2226 name = str_ptr + sym_ptr[i].n_un.n_strx;2236 name = (const char *)(str_ptr + sym_ptr[i].n_un.n_strx); 2227 2237 for (set_ptr = sets; set_ptr != NULL; set_ptr = set_ptr->next) 2228 2238 if (strcmp (set_ptr->name, name) == 0) … … 2475 2485 get the string from the cache. */ 2476 2486 2477 sym_name = str_ptr + sym_ptr[rel->r_symbolnum].n_un.n_strx;2487 sym_name = (const char *)(str_ptr + sym_ptr[rel->r_symbolnum].n_un.n_strx); 2478 2488 for (p = modstr_cache; p != NULL; p = p->next) 2479 2489 if (strcmp (p->symbol, sym_name) == 0) … … 2528 2538 case N_TEXT|N_EXT: 2529 2539 case N_DATA|N_EXT: 2530 if (strcmp ( m_str + m_sym[i].n_un.n_strx, sym_name) == 0)2540 if (strcmp ((const char *)(m_str + m_sym[i].n_un.n_strx), sym_name) == 0) 2531 2541 { 2532 2542 m_sym += i; found = TRUE; break; … … 2661 2671 { 2662 2672 case N_IMP1|N_EXT: 2663 name1 = str_ptr + sym_ptr[i].n_un.n_strx;2673 name1 = (const char *)(str_ptr + sym_ptr[i].n_un.n_strx); 2664 2674 break; 2665 2675 case N_IMP2|N_EXT: 2666 name2 = str_ptr + sym_ptr[i].n_un.n_strx;2676 name2 = (const char *)(str_ptr + sym_ptr[i].n_un.n_strx); 2667 2677 break; 2668 2678 default: … … 2732 2742 { 2733 2743 case N_IMP1|N_EXT: 2734 name1 = str_ptr + sym_ptr[i].n_un.n_strx;2744 name1 = (const char *)(str_ptr + sym_ptr[i].n_un.n_strx); 2735 2745 break; 2736 2746 case N_IMP2|N_EXT: 2737 name2 = str_ptr + sym_ptr[i].n_un.n_strx;2747 name2 = (const char *)(str_ptr + sym_ptr[i].n_un.n_strx); 2738 2748 break; 2739 2749 } … … 2829 2839 case N_TEXT|N_EXT: 2830 2840 if (pub_name != NULL) return FALSE; 2831 pub_name = str_ptr + sym_ptr[i].n_un.n_strx;2841 pub_name = (const char *)(str_ptr + sym_ptr[i].n_un.n_strx); 2832 2842 break; 2833 2843 … … 2837 2847 2838 2848 case N_SETT|N_EXT: 2839 if (strcmp ( str_ptr + sym_ptr[i].n_un.n_strx, "__os2dll") != 0)2849 if (strcmp ((const char *)(str_ptr + sym_ptr[i].n_un.n_strx), "__os2dll") != 0) 2840 2850 return FALSE; 2841 2851 table_off = sym_ptr[i].n_value; … … 2889 2899 make_import (pub_name, ord != 0 ? NULL : proc_name, ord, dll_name); 2890 2900 return TRUE; 2901 } 2902 2903 /** 2904 * Emits a OMF export record if the symbols is defined in this module. 2905 */ 2906 static void make_export(const char *pszSymbol, size_t cchSymbol, 2907 const char *pszExpName, size_t cchExpName, unsigned iOrdinal) 2908 { 2909 const struct nlist *pSym; 2910 char *pszSym = alloca(cchSymbol + 1); 2911 memcpy(pszSym, pszSymbol, cchSymbol); 2912 pszSym[cchSymbol] = '\0'; 2913 2914 pSym = find_symbol(pszSym); 2915 if (pSym) 2916 { 2917 /* 2918 * Write the export definition record. 2919 */ 2920 uint8_t fFlags = 0; 2921 if (iOrdinal) 2922 fFlags |= 1 << 7; /* have ordinal */ 2923 if (cchExpName && !iOrdinal) 2924 fFlags |= 1 << 6; /* resident name */ 2925 2926 init_rec(COMENT); 2927 put_8(0x00); 2928 put_8(CLASS_OMFEXT); 2929 put_8(OMFEXT_EXPDEF); 2930 put_8(fFlags); 2931 put_nstr(pszExpName, cchExpName); 2932 put_nstr(pszSymbol, cchSymbol); 2933 if (iOrdinal) 2934 put_16(iOrdinal); 2935 write_rec(); 2936 } 2937 } 2938 2939 2940 /* Convert export entries. 2941 2942 The exports are encoded as N_EXT (0x6c) stab entries. The value is -42, 2943 and the symbol name is on the form: "<exportname>,<ordinal>=<symbol>,code|data" 2944 The exportname can be empty if ordinal is not 0. Ordinal 0 means not exported by 2945 any special ordinal number. 2946 2947 Export entries for symbols which are not defined in the object are ignored. */ 2948 static void write_export (void) 2949 { 2950 int i; 2951 2952 /* Search the symbol table for N_IMP1 and N_IMP2 symbols. These are 2953 unique to import modules. */ 2954 2955 for (i = 0; i < sym_count; ++i) 2956 { 2957 const char *pszName; 2958 size_t cchName; 2959 const char *pszOrdinal; 2960 const char *pszSymbol; 2961 size_t cchSymbol; 2962 const char *pszType; 2963 int iOrdinal; 2964 char *pszOrdinalEnd; 2965 if (sym_ptr[i].n_type != N_EXP) 2966 continue; 2967 pszName = (const char *)(str_ptr + sym_ptr[i].n_un.n_strx); 2968 2969 /* 2970 * Parse it. 2971 */ 2972 /* find equal sign first, we'll use this for validating the ordinal. */ 2973 pszSymbol = strchr(pszName, '='); 2974 if (!pszSymbol) 2975 error("Invalid export record: missing `='. \nstabs: %s", pszName); 2976 2977 /* ordinal */ 2978 pszOrdinal = strchr(pszName, ','); 2979 if (!pszOrdinal || pszOrdinal >= pszSymbol) 2980 error("Invalid export record: missing ordinal.\nstabs: %s", pszName); 2981 cchName = pszOrdinal - pszName; 2982 pszOrdinal++; 2983 iOrdinal = strtol(pszOrdinal, &pszOrdinalEnd, 0); 2984 if (iOrdinal < 0 || iOrdinal >= 0x10000) 2985 error("Invalid export record: ordinal value is out of range (0-65k): %d\nstabs:%s", 2986 iOrdinal, pszName); 2987 if (pszOrdinalEnd != pszSymbol) 2988 error("Invalid export record: ordinal field doesn't end at `=.\nstabs:%s", pszName); 2989 2990 /* type and symbol */ 2991 pszSymbol++; 2992 pszType = strchr(pszSymbol, ','); 2993 if (!pszType) 2994 error("Invalid export record: Symbol type is missing\nstabs:%s", pszName); 2995 cchSymbol = pszType - pszSymbol; 2996 pszType++; 2997 if (strcmp(pszType, "code") && strcmp(pszType, "data") && strcmp(pszType, "bss") && strcmp(pszType, "common")) 2998 error("Invalid export record: Invalid symbol type: %s\nstabs:%s", pszType, pszName); 2999 if (!cchSymbol) 3000 error("Invalid export record: No (internal) symbol name.\nstabs:%s", pszName); 3001 3002 /* 3003 * Hand it on to the worker which looks up the symbol 3004 * and emits the OMF export record if found. 3005 */ 3006 make_export(pszSymbol, cchSymbol, pszName, cchName, iOrdinal); 3007 } 2891 3008 } 2892 3009 … … 2951 3068 if (sym_ptr[i].n_type == N_SO) 2952 3069 { 2953 p1 = str_ptr + sym_ptr[i].n_un.n_strx;3070 p1 = (const char *)(str_ptr + sym_ptr[i].n_un.n_strx); 2954 3071 len = strlen (p1); 2955 3072 if (len > 0 && p1[len-1] == '/' ) … … 3234 3351 { 3235 3352 case N_SOL: 3236 file_index = file_find ( str_ptr + sym_ptr[i].n_un.n_strx);3353 file_index = file_find ((const char *)(str_ptr + sym_ptr[i].n_un.n_strx)); 3237 3354 break; 3238 3355 case N_SLINE: … … 3490 3607 case N_IMP1|N_EXT: 3491 3608 case N_IMP2|N_EXT: 3609 case N_EXP: case N_EXP|N_EXT: 3492 3610 case N_LSYM: 3493 3611 case N_SOL: … … 3707 3825 weak_process (); 3708 3826 3827 /* Convert imports and exports. These show up very early in VAC 3828 generated OMF files. */ 3829 write_import_i2 (); 3830 write_export (); 3831 3709 3832 /* Define external, communal and public symbols (EXTDEF, WKEXT, 3710 3833 COMDEF, PUBDEF, and ALIAS records). This must be done after … … 3717 3840 write_set_pub (); 3718 3841 write_alias (); 3719 write_import_i2 ();3720 3842 3721 3843 /* Write link pass separator. */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/emxomf/weakld.c
-
Property cvs2svn:cvs-rev
changed from
1.31
to1.32
r2000 r2001 349 349 /** @} */ 350 350 /** no idea what this implies */ 351 WLDSEF_NODATA = 0x04 351 WLDSEF_NODATA = 0x04, 352 /** From an EXPORT section of a .DEF-file. */ 353 WLDSEF_DEF_FILE = 0x80 352 354 } fExport; 353 355 /** Export word count. */ … … 2075 2077 if (pSym->fFlags & WLDSF_EXPORT) 2076 2078 { 2077 /* Just warn and ignore */ 2078 modWarn(pMod, "Export '%s' is already defined.", pSym->pszName); 2079 if ( (pSym->fExport & WLDSEF_DEF_FILE) 2080 && (fExport & WLDSEF_DEF_FILE)) 2081 modWarn(pMod, "Export '%s' is already defined.", pSym->pszName); 2082 if ( !(pSym->fExport & WLDSEF_DEF_FILE) 2083 && (fExport & WLDSEF_DEF_FILE)) 2084 pSym->fExport = fExport; 2079 2085 } 2080 2086 else … … 2518 2524 ul = 0; /* ordinal */ 2519 2525 if (*u1.pch & 0x80) 2520 ul = OMF_ BYTE();2526 ul = OMF_WORD(); 2521 2527 pSym = symAddExport(pWld, pMod, fLibSearch, 2522 2528 (*u1.puch & 0x40 ? WLDSEF_RESIDENT : WLDSEF_DEFAULT) | (*u1.puch & 0x20 ? WLDSEF_NODATA : 0), 2523 2529 ((unsigned)*u1.puch) & 0x1f, 2524 u2.pch + 1, *u 1.puch,2525 u3.pch + 1, *u 2.puch,2530 u2.pch + 1, *u2.puch, 2531 u3.pch + 1, *u3.puch, 2526 2532 ul); 2527 2533 if (!pSym) goto failure; … … 2941 2947 cWords = pStmt->export.pwords; 2942 2948 pSym = symAddExport(pParam->pWld, pParam->pMod, 0, 2943 fFlags , cWords,2949 fFlags | WLDSEF_DEF_FILE, cWords, 2944 2950 pStmt->export.entryname, -1, 2945 2951 pStmt->export.internalname, -1, -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.