Changeset 806
- Timestamp:
- Oct 6, 2003, 2:05:18 AM (22 years ago)
- Location:
- trunk/src/emx/src/emxomf
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/src/emxomf/emxomf.c
-
Property cvs2svn:cvs-rev
changed from
1.28
to1.29
r805 r806 57 57 int index; /* EXTDEF index */ 58 58 int flags; /* SF_FAR16 */ 59 int hll_type; /* HLL type index. */ 59 60 }; 60 61 … … 608 609 609 610 611 /* Set the hll_type of a symbols. */ 612 void set_hll_type (int index, int hll_type) 613 { 614 if (index > sym_count || index < 0) 615 error ("Internal error! Invalid index (%d) passed to set_hll_type().", index); 616 fprintf(stderr, "dbg: set_hll_type %x %s %d\n", sym_ptr[index].n_type, str_ptr + sym_ptr[index].n_un.n_strx, hll_type); 617 sym_more[index].hll_type = hll_type; 618 } 619 620 610 621 /* Add a symbol to 0 symbol list */ 611 622 … … 909 920 static void put_str (const char *src) 910 921 { 922 char sz[256]; 911 923 int len; 912 924 913 925 len = strlen (src); 914 926 if (len > 255) 915 { 927 { /* Hash the symbol to help making it unique. */ 928 const char * psz = src; 929 unsigned uhash = 0; 930 char szhash[16]; 916 931 warning ("Symbol length truncated to 255 characters for `%s'", src); 932 for (; *psz; psz++) 933 uhash = ((uhash << 3) ^ (*psz & 0x15)); /** @todo fix this rather bad hash algorithm. */ 934 len = sprintf(szhash, "!_%X", 0x7fffffff & uhash); 935 memcpy(sz, src, 255); 936 memcpy(sz + 255 - len, szhash, len + 1); 917 937 len = 255; 938 src = &sz[0]; 918 939 } 919 940 if (!fits (1+len)) … … 1071 1092 record. PSTARTED points to an object keeping state. */ 1072 1093 1073 static void add_extdef (int *pstarted, const char *name )1094 static void add_extdef (int *pstarted, const char *name, int type) 1074 1095 { 1075 1096 if (*pstarted && !fits (strlen (name)+3)) … … 1084 1105 } 1085 1106 put_sym (name); 1086 put_idx ( 0);/* type index */1107 put_idx (type); /* type index */ 1087 1108 } 1088 1109 … … 1115 1136 if (memcmp (name, "_16_", 4) == 0) 1116 1137 sym_more[i].flags |= SF_FAR16; 1117 add_extdef (&started, name );1138 add_extdef (&started, name, sym_more[i].hll_type); 1118 1139 } 1119 1140 else if (sym_ptr[i].n_type == N_WEAKU) … … 1122 1143 { 1123 1144 weak_zero_index = sym_index++; 1124 add_extdef (&started, "WEAK$ZERO" );1145 add_extdef (&started, "WEAK$ZERO", 0); 1125 1146 } 1126 1147 sym_more[i].index = sym_index++; 1127 add_extdef (&started, str_ptr + sym_ptr[i].n_un.n_strx );1148 add_extdef (&started, str_ptr + sym_ptr[i].n_un.n_strx, sym_more[i].hll_type); 1128 1149 } 1129 1150 #if 0 /* this isn't actually required if only the assembler could do what it's supposed to... */ … … 1134 1155 name = str_ptr + sym_ptr[i].n_un.n_strx; 1135 1156 sym_more[i].index = sym_index++; 1136 add_extdef (&started, name );1157 add_extdef (&started, name, sym_more[i].hll_type); 1137 1158 } 1138 1159 #endif … … 1390 1411 else 1391 1412 put_16 (address); 1392 put_idx ( 0);/* type index */1413 put_idx (sym_more[i].hll_type); /* type index */ 1393 1414 } 1394 1415 } … … 1431 1452 else 1432 1453 put_16 (address); 1433 put_idx ( 0);/* type index */1454 put_idx (sym_more[i].hll_type); /* type index */ 1434 1455 write_rec (); 1435 1456 break; … … 3299 3320 byte *t; 3300 3321 const struct nlist *entry_symbol; 3301 int i;3302 3322 3303 3323 /* Simplify things by reading the complete a.out module into … … 3339 3359 3340 3360 sym_more = xmalloc (sym_count * sizeof (struct symbol)); 3341 for (i = 0; i < sym_count; ++i) 3342 { 3343 sym_more[i].index = 0; 3344 sym_more[i].flags = 0; 3345 } 3361 memset(sym_more, 0, sym_count * sizeof (struct symbol)); 3346 3362 3347 3363 /* Print unknown symbol table entries if the -u option is given. */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/emxomf/emxomf.h
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r805 r806 32 32 extern const struct nlist *find_symbol (const char *name); 33 33 extern const struct nlist *find_symbol_ex (const char *name, int not_entry, int fext); 34 extern void set_hll_type (int index, int hll_type); 34 35 35 36 /* These variables are defined in emxomf.c. */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/emxomf/stabshll.c
-
Property cvs2svn:cvs-rev
changed from
1.26
to1.27
r805 r806 555 555 grow_by (&sst_boundary_grow, 1); 556 556 sst_boundary[sst_boundary_grow.count++] = sst.size; 557 buffer_byte (&sst, 0); /* Length of sub-record */ 558 buffer_byte (&sst, type); /* Type of sub-record */ 557 /* Length of sub-record - bird: not sure if HL03 likes this. */ 558 buffer_byte (&sst, 0x80); 559 buffer_byte (&sst, 0); 560 /* Type of sub-record */ 561 buffer_byte (&sst, type); 559 562 } 560 563 … … 565 568 static void sst_end (void) 566 569 { 567 if (sst.size - subrec_start - 1 > 255) 570 int len = sst.size - subrec_start - 2; 571 if (len > 1000) 568 572 error ("sst_end: Record too big"); 569 sst.buf[subrec_start] = sst.size - subrec_start - 1; 573 sst.buf[subrec_start] = (len >> 8) | 0x80; 574 sst.buf[subrec_start + 1] = 0xff & len; 570 575 } 571 576 … … 579 584 580 585 static void sst_static (const char *name, dword addr, int type_index, 581 int sym_seg, int ext )586 int sym_seg, int ext, const struct nlist *psym) 582 587 { 583 588 struct relocation_info r; 584 585 sst_start (SST_static); 589 size_t len = strlen (name); 590 591 if (!psym) 592 { 593 psym = find_symbol_ex (name, -1, ext); 594 if (!psym) 595 { 596 char *psz = alloca (len + 2); 597 *psz = '_'; 598 memcpy(psz + 1, name, len + 1); 599 psym = find_symbol_ex (psz, -1, ext); 600 } 601 } 602 if (psym) 603 set_hll_type (psym - sym_ptr, type_index); 604 605 if (len > 255) 606 sst_start (SST_CPPstatic); 607 else 608 sst_start (SST_static); 586 609 r.r_address = sst.size; 587 610 buffer_dword (&sst, addr); /* Segment offset */ 588 611 buffer_word (&sst, 0); /* Segment address */ 589 612 buffer_word (&sst, type_index); /* Type index */ 590 buffer_nstr (&sst, name); /* Symbol name */ 613 if (len > 255) 614 buffer_enc (&sst, name); /* Symbol name - encoded. */ 615 else 616 buffer_nstr (&sst, name); /* Symbol name */ 591 617 sst_end (); 592 618 r.r_extern = ext; … … 2268 2294 t1 = type_add (&t); 2269 2295 } 2296 tf->offset = offset >> 3; 2270 2297 } 2271 2298 tf->type = t1; 2272 tf->offset = offset >> 3;2273 2299 } 2274 2300 } … … 3228 3254 n = p - str; 3229 3255 3230 /* 3231 * The debuggers doesn't like looong names. Besides it doesn't know how to 3232 * demangle them either. This is the place to deal with this. 3233 * (The limit seems to be 106 bytes.) 3234 * 3235 * For now we'll just make sure the name ain't too long. 3236 */ 3237 if (n > 106) 3238 { 3239 char szName[106]; 3240 memcpy(szName, str, sizeof(szName) - 1); 3241 szName[sizeof(szName) - 1] = '!'; /* mark it as cut. */ 3242 name = strpool_addn(str_pool, str, sizeof(szName)); 3243 } 3244 else 3245 name = strpool_addn(str_pool, str, n); 3246 3256 /** @todo name demangling */ 3257 name = strpool_addn (str_pool, str, n); 3247 3258 proc_start_addr = symbol->n_value; 3248 3259 … … 3328 3339 make_type (t2, &ti); 3329 3340 3330 sst_start (cplusplus_flag ? SST_CPPproc : SST_proc);3341 sst_start (cplusplus_flag || n > 255 ? SST_CPPproc : SST_proc); 3331 3342 r.r_address = sst.size; 3332 3343 buffer_dword (&sst, symbol->n_value); /* Segment offset */ … … 3338 3349 buffer_word (&sst, 0); /* Class type (for member functions) */ 3339 3350 buffer_byte (&sst, 8); /* 32-bit near */ 3340 if (cplusplus_flag )3351 if (cplusplus_flag || n > 255) 3341 3352 buffer_enc (&sst, name); /* Proc name */ 3342 3353 else … … 3350 3361 r.r_pad = 0; 3351 3362 buffer_mem (&sst_reloc, &r, sizeof (r)); 3363 set_hll_type (symbol - sym_ptr, ti); 3352 3364 } 3353 3365 … … 3435 3447 { 3436 3448 if (sym2->n_type == N_EXT) 3437 sst_static (name, 0, ti, sym2 - sym_ptr, 1 );3449 sst_static (name, 0, ti, sym2 - sym_ptr, 1, sym2); 3438 3450 else 3439 sst_static (name, sym2->n_value, ti, sym2->n_type, 0 );3451 sst_static (name, sym2->n_value, ti, sym2->n_type, 0, sym2); 3440 3452 break; 3441 3453 } … … 3467 3479 } 3468 3480 if (sym2->n_type == N_EXT) 3469 sst_static (name, 0, ti, sym2 - sym_ptr, 1 );3481 sst_static (name, 0, ti, sym2 - sym_ptr, 1, sym2); 3470 3482 else 3471 sst_static (name, sym2->n_value, ti, sym2->n_type, 0 );3483 sst_static (name, sym2->n_value, ti, sym2->n_type, 0, sym2); 3472 3484 break; 3473 3485 } … … 3490 3502 printf (" type=%#x\n", ti); 3491 3503 #endif 3492 sst_static (name, symbol->n_value, ti, where, 0 );3504 sst_static (name, symbol->n_value, ti, where, 0, NULL); 3493 3505 break; 3494 3506 … … 3800 3812 3801 3813 /* Check whether converting a translated C++ program. */ 3802 3814 #if 1 /* kso #465 2003-06-04: pretend everything is C++, that symbols is no longer present. */ 3803 3815 cplusplus_flag = 1; 3804 3816 #else 3805 3817 cplusplus_flag = (find_symbol ("__gnu_compiled_cplusplus") != NULL); 3806 3818 #endif 3807 3819 3808 3820 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.