1 /* vms-gsd.c -- BFD back-end for VAX (openVMS/VAX) and
2 EVAX (openVMS/Alpha) files.
3 Copyright 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
5 go and read the openVMS linker manual (esp. appendix B)
6 if you don't know what's going on here :-)
8 Written by Klaus K"ampf (kkaempf@rmi.de)
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
33 /*-----------------------------------------------------------------------------*/
35 /* typical sections for vax object files */
37 #define VAX_CODE_NAME "$CODE"
38 #define VAX_DATA_NAME "$DATA"
39 #define VAX_ADDRESS_DATA_NAME "$ADDRESS_DATA"
41 /* typical sections for evax object files */
43 #define EVAX_ABS_NAME "$ABS$"
44 #define EVAX_CODE_NAME "$CODE$"
45 #define EVAX_LINK_NAME "$LINK$"
46 #define EVAX_DATA_NAME "$DATA$"
47 #define EVAX_BSS_NAME "$BSS$"
48 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
49 #define EVAX_READONLY_NAME "$READONLY$"
50 #define EVAX_LITERAL_NAME "$LITERAL$"
51 #define EVAX_COMMON_NAME "$COMMON$"
52 #define EVAX_LOCAL_NAME "$LOCAL$"
54 struct sec_flags_struct {
55 char *name; /* name of section */
57 flagword flags_always; /* flags we set always */
59 flagword flags_hassize; /* flags we set if the section has a size > 0 */
62 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 VAX) compatible */
64 static struct sec_flags_struct vax_section_flags[] = {
66 (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_SHR|GPS_S_M_EXE|GPS_S_M_RD),
68 (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_SHR|GPS_S_M_EXE|GPS_S_M_RD),
69 (SEC_IN_MEMORY|SEC_CODE|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
71 (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_RD|GPS_S_M_WRT),
73 (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_RD|GPS_S_M_WRT),
74 (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
75 { VAX_ADDRESS_DATA_NAME,
76 (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_RD),
77 (SEC_DATA|SEC_READONLY),
78 (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_RD),
79 (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_READONLY|SEC_LOAD) },
81 (GPS_S_M_PIC|GPS_S_M_OVR|GPS_S_M_REL|GPS_S_M_GBL|GPS_S_M_RD|GPS_S_M_WRT),
83 (GPS_S_M_PIC|GPS_S_M_OVR|GPS_S_M_REL|GPS_S_M_GBL|GPS_S_M_RD|GPS_S_M_WRT),
84 (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) }
87 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible */
89 static struct sec_flags_struct evax_section_flags[] = {
94 (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
96 (EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_EXE),
98 (EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_EXE),
99 (SEC_IN_MEMORY|SEC_CODE|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
101 (EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_RD|EGPS_S_V_NOMOD),
102 (SEC_DATA|SEC_READONLY),
103 (EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_RD),
104 (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_READONLY|SEC_LOAD) },
106 (EGPS_S_V_REL|EGPS_S_V_RD),
107 (SEC_DATA|SEC_READONLY),
108 (EGPS_S_V_REL|EGPS_S_V_RD),
109 (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_READONLY|SEC_LOAD) },
111 (EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT|EGPS_S_V_NOMOD),
113 (EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT),
114 (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
116 (EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT|EGPS_S_V_NOMOD),
118 (EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT|EGPS_S_V_NOMOD),
119 (SEC_IN_MEMORY|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
120 { EVAX_READONLYADDR_NAME,
121 (EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_RD),
122 (SEC_DATA|SEC_READONLY),
123 (EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_RD),
124 (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_READONLY|SEC_LOAD) },
125 { EVAX_READONLY_NAME,
126 (EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_RD|EGPS_S_V_NOMOD),
127 (SEC_DATA|SEC_READONLY),
128 (EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_RD),
129 (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_READONLY|SEC_LOAD) },
131 (EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT),
133 (EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT),
134 (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
136 (EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT),
138 (EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT),
139 (SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) }
142 /* Retrieve bfd section flags by name and size */
145 vms_secflag_by_name (abfd, section_flags, name, size)
147 struct sec_flags_struct *section_flags;
153 while (section_flags[i].name != NULL)
156 strcasecmp (name, section_flags[i].name):
157 strcmp (name, section_flags[i].name)) == 0)
160 return section_flags[i].flags_hassize;
162 return section_flags[i].flags_always;
167 return section_flags[i].flags_hassize;
168 return section_flags[i].flags_always;
171 /* Retrieve vms section flags by name and size */
174 vms_esecflag_by_name (section_flags, name, size)
175 struct sec_flags_struct *section_flags;
181 while (section_flags[i].name != NULL)
183 if (strcmp (name, section_flags[i].name) == 0)
186 return section_flags[i].vflags_hassize;
188 return section_flags[i].vflags_always;
193 return section_flags[i].vflags_hassize;
194 return section_flags[i].vflags_always;
197 /*-----------------------------------------------------------------------------*/
201 struct flagdescstruct { char *name; flagword value; };
203 /* Convert flag to printable string */
206 flag2str(flagdesc, flags)
207 struct flagdescstruct *flagdesc;
215 while (flagdesc->name != NULL)
217 if ((flags & flagdesc->value) != 0)
223 strcat (res, flagdesc->name);
231 /*-----------------------------------------------------------------------------*/
234 /* Process GSD/EGSD record
235 return 0 on success, -1 on error */
238 _bfd_vms_slurp_gsd (abfd, objtype)
243 static struct flagdescstruct gpsflagdesc[] =
260 static struct flagdescstruct gsyflagdesc[] =
273 int gsd_type, gsd_size;
275 unsigned char *vms_rec;
276 flagword new_flags, old_flags;
279 vms_symbol_entry *entry;
280 unsigned long base_addr;
281 unsigned long align_addr;
282 static unsigned int psect_idx = 0;
285 vms_debug (2, "GSD/EGSD (%d/%x)\n", objtype, objtype);
291 PRIV(vms_rec) += 8; /* skip type, size, l_temp */
302 /* calculate base address for each section */
307 while (PRIV(rec_size) > 0)
309 vms_rec = PRIV(vms_rec);
311 if (objtype == OBJ_S_C_GSD)
317 _bfd_vms_get_header_values (abfd, vms_rec, &gsd_type, &gsd_size);
318 gsd_type += EVAX_OFFSET;
322 vms_debug (3, "gsd_type %d\n", gsd_type);
330 * program section definition
333 asection *old_section = 0;
336 vms_debug (4, "GSD_S_C_PSC\n");
338 /* If this section isn't a bfd section. */
340 if (PRIV(is_vax) && (psect_idx < (abfd->section_count-1)))
342 /* check for temporary section from TIR record. */
344 if (psect_idx < PRIV(section_count))
345 old_section = PRIV(sections)[psect_idx];
350 name = _bfd_vms_save_counted_string (vms_rec + 8);
351 section = bfd_make_section (abfd, name);
354 (*_bfd_error_handler) (_("bfd_make_section (%s) failed"),
358 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 if (old_flags & EGPS_S_V_REL)
362 new_flags |= SEC_RELOC;
363 if (old_flags & GPS_S_M_OVR)
364 new_flags |= SEC_IS_COMMON;
365 if (!bfd_set_section_flags (abfd, section, new_flags))
367 (*_bfd_error_handler)
368 (_("bfd_set_section_flags (%s, %x) failed"),
372 section->alignment_power = vms_rec[1];
373 align_addr = (1 << section->alignment_power);
374 if ((base_addr % align_addr) != 0)
375 base_addr += (align_addr - (base_addr % align_addr));
376 section->vma = (bfd_vma)base_addr;
377 base_addr += section->_raw_size;
379 /* global section is common symbol */
381 if (old_flags & GPS_S_M_GBL)
383 entry = _bfd_vms_enter_symbol (abfd, name);
384 if (entry == (vms_symbol_entry *)NULL)
386 bfd_set_error (bfd_error_no_memory);
389 symbol = entry->symbol;
392 symbol->section = section;
393 symbol->flags = (BSF_GLOBAL|BSF_SECTION_SYM|BSF_OLD_COMMON);
396 /* copy saved contents if old_section set */
398 if (old_section != 0)
400 section->contents = old_section->contents;
401 if (section->_raw_size < old_section->_raw_size)
403 (*_bfd_error_handler)
404 (_("Size mismatch section %s=%lx, %s=%lx"),
406 (unsigned long) old_section->_raw_size,
408 (unsigned long) section->_raw_size);
411 else if (section->_raw_size > old_section->_raw_size)
413 section->contents = ((unsigned char *)
414 bfd_realloc (old_section->contents, section->_raw_size));
415 if (section->contents == NULL)
417 bfd_set_error (bfd_error_no_memory);
424 section->contents = ((unsigned char *)
425 bfd_malloc (section->_raw_size));
426 if (section->contents == NULL)
428 bfd_set_error (bfd_error_no_memory);
431 memset (section->contents, 0, (size_t)section->_raw_size);
433 section->_cooked_size = section->_raw_size;
435 vms_debug (4, "gsd psc %d (%s, flags %04x=%s) ",
436 section->index, name, old_flags, flag2str (gpsflagdesc, old_flags));
437 vms_debug (4, "%d bytes at 0x%08lx (mem %p)\n",
438 section->_raw_size, section->vma, section->contents);
441 gsd_size = vms_rec[8] + 9;
450 vms_debug(4, "gsd epm\n");
456 int name_offset, value_offset;
459 * symbol specification (definition or reference)
463 vms_debug (4, "GSD_S_C_SYM(W)\n");
465 old_flags = bfd_getl16 (vms_rec + 2);
466 new_flags = BSF_NO_FLAGS;
468 if (old_flags & GSY_S_M_WEAK)
469 new_flags |= BSF_WEAK;
476 new_flags |= BSF_FUNCTION;
481 new_flags |= BSF_FUNCTION;
484 if (old_flags & GSY_S_M_DEF) /* symbol definition */
491 if (old_flags & GSY_S_M_DEF) /* symbol definition */
499 /* save symbol in vms_symbol_table */
501 entry = _bfd_vms_enter_symbol (abfd,
502 _bfd_vms_save_counted_string (vms_rec + name_offset));
503 if (entry == (vms_symbol_entry *)NULL)
505 bfd_set_error (bfd_error_no_memory);
508 symbol = entry->symbol;
510 if (old_flags & GSY_S_M_DEF) /* symbol definition */
514 symbol->value = bfd_getl32 (vms_rec+value_offset);
515 if ((gsd_type == GSD_S_C_SYMW)
516 || (gsd_type == GSD_S_C_EPMW))
517 psect = bfd_getl16 (vms_rec + value_offset - 2);
519 psect = vms_rec[value_offset-1];
521 symbol->section = (asection *)psect;
523 vms_debug(4, "gsd sym def #%d (%s, %d [%p], %04x=%s)\n", abfd->symcount,
524 symbol->name, (int)symbol->section, symbol->section, old_flags, flag2str(gsyflagdesc, old_flags));
527 else /* symbol reference */
529 symbol->section = bfd_make_section (abfd, BFD_UND_SECTION_NAME);
531 vms_debug (4, "gsd sym ref #%d (%s, %s [%p], %04x=%s)\n", abfd->symcount,
532 symbol->name, symbol->section->name, symbol->section, old_flags, flag2str (gsyflagdesc, old_flags));
536 gsd_size = vms_rec[name_offset] + name_offset + 1;
537 symbol->flags = new_flags;
545 vms_debug(4, "gsd pro\n");
550 vms_debug(4, "gsd idc\n");
555 vms_debug(4, "gsd env\n");
560 vms_debug(4, "gsd lsy\n");
565 vms_debug(4, "gsd lepm\n");
570 vms_debug(4, "gsd lpro\n");
575 vms_debug(4, "gsd spsc\n");
580 vms_debug(4, "gsd symv\n");
585 vms_debug(4, "gsd epmv\n");
590 vms_debug(4, "gsd prov\n");
594 case EGSD_S_C_PSC + EVAX_OFFSET:
596 /* program section definition */
598 name = _bfd_vms_save_counted_string (vms_rec+12);
599 section = bfd_make_section (abfd, name);
602 old_flags = bfd_getl16 (vms_rec + 6);
603 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);
605 if (old_flags & EGPS_S_V_REL)
606 new_flags |= SEC_RELOC;
607 if (!bfd_set_section_flags (abfd, section, new_flags))
609 section->alignment_power = vms_rec[4];
610 align_addr = (1 << section->alignment_power);
611 if ((base_addr % align_addr) != 0)
612 base_addr += (align_addr - (base_addr % align_addr));
613 section->vma = (bfd_vma)base_addr;
614 base_addr += section->_raw_size;
615 section->contents = ((unsigned char *)
616 bfd_malloc (section->_raw_size));
617 if (section->contents == NULL)
619 memset (section->contents, 0, (size_t) section->_raw_size);
620 section->_cooked_size = section->_raw_size;
622 vms_debug(4, "egsd psc %d (%s, flags %04x=%s) ",
623 section->index, name, old_flags, flag2str(gpsflagdesc, old_flags));
624 vms_debug(4, "%d bytes at 0x%08lx (mem %p)\n",
625 section->_raw_size, section->vma, section->contents);
630 case EGSD_S_C_SYM + EVAX_OFFSET:
632 /* symbol specification (definition or reference) */
634 symbol = _bfd_vms_make_empty_symbol (abfd);
638 old_flags = bfd_getl16 (vms_rec + 6);
639 new_flags = BSF_NO_FLAGS;
641 if (old_flags & EGSY_S_V_WEAK)
642 new_flags |= BSF_WEAK;
644 if (vms_rec[6] & EGSY_S_V_DEF) /* symbol definition */
647 _bfd_vms_save_counted_string (vms_rec+32);
648 if (old_flags & EGSY_S_V_NORM)
650 new_flags |= BSF_FUNCTION;
652 symbol->value = bfd_getl64 (vms_rec+8);
653 symbol->section = (asection *) ((unsigned long) bfd_getl32 (vms_rec+28));
655 vms_debug(4, "egsd sym def #%d (%s, %d, %04x=%s)\n", abfd->symcount,
656 symbol->name, (int)symbol->section, old_flags, flag2str(gsyflagdesc, old_flags));
659 else /* symbol reference */
662 _bfd_vms_save_counted_string (vms_rec+8);
664 vms_debug(4, "egsd sym ref #%d (%s, %04x=%s)\n", abfd->symcount,
665 symbol->name, old_flags, flag2str(gsyflagdesc, old_flags));
667 symbol->section = bfd_make_section (abfd, BFD_UND_SECTION_NAME);
670 symbol->flags = new_flags;
672 /* save symbol in vms_symbol_table */
674 entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV(vms_symbol_table), symbol->name, true, false);
675 if (entry == (vms_symbol_entry *)NULL)
677 bfd_set_error (bfd_error_no_memory);
680 if (entry->symbol != (asymbol *)NULL)
681 { /* FIXME ?, DEC C generates this */
683 vms_debug(4, "EGSD_S_C_SYM: duplicate \"%s\"\n", symbol->name);
688 entry->symbol = symbol;
689 PRIV(gsd_sym_count)++;
695 case EGSD_S_C_IDC + EVAX_OFFSET:
699 (*_bfd_error_handler) (_("unknown gsd/egsd subtype %d"), gsd_type);
700 bfd_set_error (bfd_error_bad_value);
705 PRIV(rec_size) -= gsd_size;
706 PRIV(vms_rec) += gsd_size;
708 } /* while (recsize > 0) */
710 if (abfd->symcount > 0)
711 abfd->flags |= HAS_SYMS;
716 /*-----------------------------------------------------------------------------*/
717 /* output routines */
719 /* Write section and symbol directory of bfd abfd */
722 _bfd_vms_write_gsd (abfd, objtype)
724 int objtype ATTRIBUTE_UNUSED;
732 flagword new_flags, old_flags;
735 vms_debug (2, "vms_write_gsd (%p, %d)\n", abfd, objtype);
738 /* output sections */
740 section = abfd->sections;
742 vms_debug (3, "%d sections found\n", abfd->section_count);
745 /* egsd is quadword aligned */
747 _bfd_vms_output_alignment (abfd, 8);
749 _bfd_vms_output_begin (abfd, EOBJ_S_C_EGSD, -1);
750 _bfd_vms_output_long (abfd, 0);
751 _bfd_vms_output_push (abfd); /* prepare output for subrecords */
756 vms_debug (3, "Section #%d %s, %d bytes\n", section->index, section->name, (int)section->_raw_size);
759 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes */
760 if (_bfd_vms_output_check (abfd, 64) < 0)
762 _bfd_vms_output_pop (abfd);
763 _bfd_vms_output_end (abfd);
764 _bfd_vms_output_begin (abfd, EOBJ_S_C_EGSD, -1);
765 _bfd_vms_output_long (abfd, 0);
766 _bfd_vms_output_push (abfd); /* prepare output for subrecords */
769 /* Create dummy sections to keep consecutive indices */
771 while (section->index - last_index > 1)
774 vms_debug (3, "index %d, last %d\n", section->index, last_index);
776 _bfd_vms_output_begin (abfd, EGSD_S_C_PSC, -1);
777 _bfd_vms_output_short (abfd, 0);
778 _bfd_vms_output_short (abfd, 0);
779 _bfd_vms_output_long (abfd, 0);
780 sprintf (dummy_name, ".DUMMY%02d", last_index);
781 _bfd_vms_output_counted (abfd, dummy_name);
782 _bfd_vms_output_flush (abfd);
786 /* Don't know if this is neccesary for the linker but for now it keeps
787 vms_slurp_gsd happy */
789 sname = (char *)section->name;
793 if ((*sname == 't') && (strcmp (sname, "text") == 0))
794 sname = PRIV(is_vax)?VAX_CODE_NAME:EVAX_CODE_NAME;
795 else if ((*sname == 'd') && (strcmp (sname, "data") == 0))
796 sname = PRIV(is_vax)?VAX_DATA_NAME:EVAX_DATA_NAME;
797 else if ((*sname == 'b') && (strcmp (sname, "bss") == 0))
798 sname = EVAX_BSS_NAME;
799 else if ((*sname == 'l') && (strcmp (sname, "link") == 0))
800 sname = EVAX_LINK_NAME;
801 else if ((*sname == 'r') && (strcmp (sname, "rdata") == 0))
802 sname = EVAX_READONLY_NAME;
803 else if ((*sname == 'l') && (strcmp (sname, "literal") == 0))
804 sname = EVAX_LITERAL_NAME;
805 else if ((*sname == 'c') && (strcmp (sname, "comm") == 0))
806 sname = EVAX_COMMON_NAME;
807 else if ((*sname == 'l') && (strcmp (sname, "lcomm") == 0))
808 sname = EVAX_LOCAL_NAME;
811 sname = _bfd_vms_length_hash_symbol (abfd, sname, EOBJ_S_C_SECSIZ);
813 _bfd_vms_output_begin (abfd, EGSD_S_C_PSC, -1);
814 _bfd_vms_output_short (abfd, section->alignment_power & 0xff);
815 if (bfd_is_com_section (section))
817 new_flags = (EGPS_S_V_OVR|EGPS_S_V_REL|EGPS_S_V_GBL|EGPS_S_V_RD|EGPS_S_V_WRT|EGPS_S_V_NOMOD|EGPS_S_V_COM);
821 new_flags = vms_esecflag_by_name (evax_section_flags, sname, section->_raw_size);
823 _bfd_vms_output_short (abfd, new_flags);
824 _bfd_vms_output_long (abfd, section->_raw_size);
825 _bfd_vms_output_counted (abfd, sname);
826 _bfd_vms_output_flush (abfd);
828 last_index = section->index;
829 section = section->next;
835 vms_debug (3, "%d symbols found\n", abfd->symcount);
838 bfd_set_start_address (abfd, (bfd_vma)-1);
840 for (symnum = 0; symnum < abfd->symcount; symnum++)
843 symbol = abfd->outsymbols[symnum];
844 if (*(symbol->name) == '_')
846 if (strcmp (symbol->name, "__main") == 0)
847 bfd_set_start_address (abfd, (bfd_vma)symbol->value);
849 old_flags = symbol->flags;
851 if (old_flags & BSF_FILE)
854 if (((old_flags & (BSF_GLOBAL|BSF_WEAK)) == 0) /* not xdef */
855 && (!bfd_is_und_section (symbol->section))) /* and not xref */
856 continue; /* dont output */
858 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes */
860 if (_bfd_vms_output_check (abfd, 80) < 0)
862 _bfd_vms_output_pop (abfd);
863 _bfd_vms_output_end (abfd);
864 _bfd_vms_output_begin (abfd, EOBJ_S_C_EGSD, -1);
865 _bfd_vms_output_long (abfd, 0);
866 _bfd_vms_output_push (abfd); /* prepare output for subrecords */
869 _bfd_vms_output_begin (abfd, EGSD_S_C_SYM, -1);
871 _bfd_vms_output_short (abfd, 0); /* data type, alignment */
875 if (old_flags & BSF_WEAK)
876 new_flags |= EGSY_S_V_WEAK;
877 if (bfd_is_com_section (symbol->section)) /* .comm */
878 new_flags |= (EGSY_S_V_WEAK|EGSY_S_V_COMM);
880 if (old_flags & BSF_FUNCTION)
882 new_flags |= EGSY_S_V_NORM;
883 new_flags |= EGSY_S_V_REL;
885 if (old_flags & (BSF_GLOBAL|BSF_WEAK))
887 new_flags |= EGSY_S_V_DEF;
888 if (!bfd_is_abs_section (symbol->section))
889 new_flags |= EGSY_S_V_REL;
891 _bfd_vms_output_short (abfd, new_flags);
893 if (old_flags & (BSF_GLOBAL|BSF_WEAK)) /* symbol definition */
895 if (old_flags & BSF_FUNCTION)
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))
903 _bfd_vms_output_long (abfd, symbol->section->index);
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 */
913 _bfd_vms_output_counted (abfd, _bfd_vms_length_hash_symbol (abfd, symbol->name, EOBJ_S_C_SYMSIZ));
915 _bfd_vms_output_flush (abfd);
919 _bfd_vms_output_alignment (abfd, 8);
920 _bfd_vms_output_pop (abfd);
921 _bfd_vms_output_end (abfd);