Changeset 609 for branches/GNU/src/binutils/bfd/vms-gsd.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/vms-gsd.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* vms-gsd.c -- BFD back-end for VAX (openVMS/VAX) and 2 2 EVAX (openVMS/Alpha) files. 3 Copyright 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. 3 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 4 Free Software Foundation, Inc. 4 5 5 6 go and read the openVMS linker manual (esp. appendix B) … … 21 22 along with this program; if not, write to the Free Software 22 23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 23 24 #include <ctype.h>25 24 26 25 #include "bfd.h" … … 140 139 }; 141 140 141 static flagword vms_secflag_by_name PARAMS ((bfd *, struct sec_flags_struct *, char *, int)); 142 static flagword vms_esecflag_by_name PARAMS ((struct sec_flags_struct *, char *, int)); 143 142 144 /* Retrieve bfd section flags by name and size */ 143 145 144 146 static flagword 145 vms_secflag_by_name (abfd, section_flags, name, size)147 vms_secflag_by_name (abfd, section_flags, name, hassize) 146 148 bfd *abfd; 147 149 struct sec_flags_struct *section_flags; 148 150 char *name; 149 int size;151 int hassize; 150 152 { 151 153 int i = 0; … … 157 159 strcmp (name, section_flags[i].name)) == 0) 158 160 { 159 if ( size > 0)161 if (hassize) 160 162 return section_flags[i].flags_hassize; 161 163 else … … 164 166 i++; 165 167 } 166 if ( size > 0)168 if (hassize) 167 169 return section_flags[i].flags_hassize; 168 170 return section_flags[i].flags_always; … … 172 174 173 175 static flagword 174 vms_esecflag_by_name (section_flags, name, size)176 vms_esecflag_by_name (section_flags, name, hassize) 175 177 struct sec_flags_struct *section_flags; 176 178 char *name; 177 int size;179 int hassize; 178 180 { 179 181 int i = 0; … … 183 185 if (strcmp (name, section_flags[i].name) == 0) 184 186 { 185 if ( size > 0)187 if (hassize) 186 188 return section_flags[i].vflags_hassize; 187 189 else … … 190 192 i++; 191 193 } 192 if ( size > 0)194 if (hassize) 193 195 return section_flags[i].vflags_hassize; 194 196 return section_flags[i].vflags_always; … … 288 290 switch (objtype) 289 291 { 290 291 292 293 294 295 296 297 298 299 292 case EOBJ_S_C_EGSD: 293 PRIV(vms_rec) += 8; /* skip type, size, l_temp */ 294 PRIV(rec_size) -= 8; 295 break; 296 case OBJ_S_C_GSD: 297 PRIV(vms_rec) += 1; 298 PRIV(rec_size) -= 1; 299 break; 300 default: 301 return -1; 300 302 } 301 303 … … 357 359 } 358 360 old_flags = bfd_getl16 (vms_rec + 2); 359 section->_raw_size = bfd_getl32(vms_rec + 4); /* allocation */ 360 new_flags = vms_secflag_by_name (abfd, vax_section_flags, name, section->_raw_size); 361 section->_raw_size = bfd_getl32 (vms_rec + 4); /* allocation */ 362 new_flags = vms_secflag_by_name (abfd, vax_section_flags, name, 363 section->_raw_size > 0); 361 364 if (old_flags & EGPS_S_V_REL) 362 365 new_flags |= SEC_RELOC; … … 412 415 { 413 416 section->contents = ((unsigned char *) 414 bfd_realloc (old_section->contents, section->_raw_size)); 417 bfd_realloc (old_section->contents, 418 section->_raw_size)); 415 419 if (section->contents == NULL) 416 420 { 417 421 bfd_set_error (bfd_error_no_memory); 418 422 return -1; 419 423 } 420 424 } 421 425 } … … 423 427 { 424 428 section->contents = ((unsigned char *) 425 bfd_malloc (section->_raw_size));429 bfd_zmalloc (section->_raw_size)); 426 430 if (section->contents == NULL) 427 431 { … … 429 433 return -1; 430 434 } 431 memset (section->contents, 0, (size_t)section->_raw_size);432 435 } 433 436 section->_cooked_size = section->_raw_size; … … 454 457 case GSD_S_C_SYMW: 455 458 { 456 int name_offset , value_offset;459 int name_offset = 0, value_offset = 0; 457 460 458 461 /* … … 471 474 switch (gsd_type) 472 475 { 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 476 case GSD_S_C_EPM: 477 name_offset = 11; 478 value_offset = 5; 479 new_flags |= BSF_FUNCTION; 480 break; 481 case GSD_S_C_EPMW: 482 name_offset = 12; 483 value_offset = 6; 484 new_flags |= BSF_FUNCTION; 485 break; 486 case GSD_S_C_SYM: 487 if (old_flags & GSY_S_M_DEF) /* symbol definition */ 488 name_offset = 9; 489 else 490 name_offset = 4; 491 value_offset = 5; 492 break; 493 case GSD_S_C_SYMW: 494 if (old_flags & GSY_S_M_DEF) /* symbol definition */ 495 name_offset = 10; 496 else 497 name_offset = 5; 498 value_offset = 6; 499 break; 497 500 } 498 501 … … 602 605 old_flags = bfd_getl16 (vms_rec + 6); 603 606 section->_raw_size = bfd_getl32 (vms_rec + 8); /* allocation */ 604 new_flags = vms_secflag_by_name (abfd, evax_section_flags, name, (int) section->_raw_size); 607 new_flags = vms_secflag_by_name (abfd, evax_section_flags, name, 608 section->_raw_size > 0); 605 609 if (old_flags & EGPS_S_V_REL) 606 610 new_flags |= SEC_RELOC; … … 614 618 base_addr += section->_raw_size; 615 619 section->contents = ((unsigned char *) 616 bfd_ malloc (section->_raw_size));620 bfd_zmalloc (section->_raw_size)); 617 621 if (section->contents == NULL) 618 622 return -1; 619 memset (section->contents, 0, (size_t) section->_raw_size);620 623 section->_cooked_size = section->_raw_size; 621 624 #if VMS_DEBUG … … 632 635 /* symbol specification (definition or reference) */ 633 636 634 symbol = _bfd_vms_make_empty_symbol (abfd);637 symbol = bfd_make_empty_symbol (abfd); 635 638 if (symbol == 0) 636 639 return -1; … … 659 662 else /* symbol reference */ 660 663 { 661 664 symbol->name = 662 665 _bfd_vms_save_counted_string (vms_rec+8); 663 666 #if VMS_DEBUG … … 665 668 symbol->name, old_flags, flag2str(gsyflagdesc, old_flags)); 666 669 #endif 667 670 symbol->section = bfd_make_section (abfd, BFD_UND_SECTION_NAME); 668 671 } 669 672 … … 672 675 /* save symbol in vms_symbol_table */ 673 676 674 entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV(vms_symbol_table), symbol->name, true, false); 677 entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV(vms_symbol_table), 678 symbol->name, 679 TRUE, FALSE); 675 680 if (entry == (vms_symbol_entry *)NULL) 676 681 { … … 819 824 else 820 825 { 821 new_flags = vms_esecflag_by_name (evax_section_flags, sname, section->_raw_size); 826 new_flags = vms_esecflag_by_name (evax_section_flags, sname, 827 section->_raw_size > 0); 822 828 } 823 829 _bfd_vms_output_short (abfd, new_flags); 824 _bfd_vms_output_long (abfd, section->_raw_size);830 _bfd_vms_output_long (abfd, (unsigned long) section->_raw_size); 825 831 _bfd_vms_output_counted (abfd, sname); 826 832 _bfd_vms_output_flush (abfd); … … 840 846 for (symnum = 0; symnum < abfd->symcount; symnum++) 841 847 { 848 char *hash; 842 849 843 850 symbol = abfd->outsymbols[symnum]; … … 891 898 _bfd_vms_output_short (abfd, new_flags); 892 899 893 if (old_flags & (BSF_GLOBAL|BSF_WEAK)) /* symbol definition */ 894 { 895 if (old_flags & BSF_FUNCTION) 900 if (old_flags & (BSF_GLOBAL | BSF_WEAK)) /* symbol definition */ 901 { 902 uquad code_address = 0; 903 unsigned long ca_psindx = 0; 904 unsigned long psindx; 905 906 if ((old_flags & BSF_FUNCTION) && symbol->udata.p != NULL) 896 907 { 897 _bfd_vms_output_quad (abfd, symbol->value); 898 _bfd_vms_output_quad (abfd, 899 ((asymbol *) (symbol->udata.p))->value); 900 _bfd_vms_output_long (abfd, 901 (((asymbol *) (symbol->udata.p)) 902 ->section->index)); 903 _bfd_vms_output_long (abfd, symbol->section->index); 908 code_address = ((asymbol *) (symbol->udata.p))->value; 909 ca_psindx = ((asymbol *) (symbol->udata.p))->section->index; 904 910 } 905 else906 { 907 _bfd_vms_output_quad (abfd, symbol->value); /* L_VALUE */908 _bfd_vms_output_quad (abfd, 0); /* L_CODE_ADDRESS */909 _bfd_vms_output_long (abfd, 0); /* L_CA_PSINDX */910 _bfd_vms_output_long (abfd, symbol->section->index);/* L_PSINDX */911 912 } 913 _bfd_vms_output_counted (abfd, _bfd_vms_length_hash_symbol (abfd, symbol->name, EOBJ_S_C_SYMSIZ));911 psindx = symbol->section->index; 912 913 _bfd_vms_output_quad (abfd, symbol->value); 914 _bfd_vms_output_quad (abfd, code_address); 915 _bfd_vms_output_long (abfd, ca_psindx); 916 _bfd_vms_output_long (abfd, psindx); 917 } 918 hash = _bfd_vms_length_hash_symbol (abfd, symbol->name, EOBJ_S_C_SYMSIZ); 919 _bfd_vms_output_counted (abfd, hash); 914 920 915 921 _bfd_vms_output_flush (abfd); -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.