1 /* vms-gsd.c -- BFD back-end for VAX (openVMS/VAX) and
2 EVAX (openVMS/Alpha) files.
3 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4 2007 Free Software Foundation, Inc.
6 go and read the openVMS linker manual (esp. appendix B)
7 if you don't know what's going on here :-)
9 Written by Klaus K"ampf (kkaempf@rmi.de)
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
32 /* Typical sections for vax object files. */
34 #define VAX_CODE_NAME "$CODE"
35 #define VAX_DATA_NAME "$DATA"
36 #define VAX_ADDRESS_DATA_NAME "$ADDRESS_DATA"
38 /* Typical sections for evax object files. */
40 #define EVAX_ABS_NAME "$ABS$"
41 #define EVAX_CODE_NAME "$CODE$"
42 #define EVAX_LINK_NAME "$LINK$"
43 #define EVAX_DATA_NAME "$DATA$"
44 #define EVAX_BSS_NAME "$BSS$"
45 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
46 #define EVAX_READONLY_NAME "$READONLY$"
47 #define EVAX_LITERAL_NAME "$LITERAL$"
48 #define EVAX_COMMON_NAME "$COMMON$"
49 #define EVAX_LOCAL_NAME "$LOCAL$"
51 struct sec_flags_struct
53 char *name; /* Name of section. */
55 flagword flags_always; /* Flags we set always. */
57 flagword flags_hassize; /* Flags we set if the section has a size > 0. */
60 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 VAX) compatible. */
62 static struct sec_flags_struct vax_section_flags[] =
65 (GPS_S_M_PIC | GPS_S_M_REL | GPS_S_M_SHR | GPS_S_M_EXE | GPS_S_M_RD),
67 (GPS_S_M_PIC | GPS_S_M_REL | GPS_S_M_SHR | GPS_S_M_EXE | GPS_S_M_RD),
68 (SEC_IN_MEMORY | SEC_CODE | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD) },
70 (GPS_S_M_PIC | GPS_S_M_REL | GPS_S_M_RD | GPS_S_M_WRT),
72 (GPS_S_M_PIC | GPS_S_M_REL | GPS_S_M_RD | GPS_S_M_WRT),
73 (SEC_IN_MEMORY | SEC_DATA | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD) },
74 { VAX_ADDRESS_DATA_NAME,
75 (GPS_S_M_PIC | GPS_S_M_REL | GPS_S_M_RD),
76 (SEC_DATA | SEC_READONLY),
77 (GPS_S_M_PIC | GPS_S_M_REL | GPS_S_M_RD),
78 (SEC_IN_MEMORY | SEC_DATA | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_READONLY | SEC_LOAD) },
80 (GPS_S_M_PIC | GPS_S_M_OVR | GPS_S_M_REL | GPS_S_M_GBL | GPS_S_M_RD | GPS_S_M_WRT),
82 (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 (SEC_IN_MEMORY | SEC_DATA | SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD) }
86 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
88 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 (bfd *abfd,
146 struct sec_flags_struct *section_flags,
152 while (section_flags[i].name != NULL)
155 strcasecmp (name, section_flags[i].name):
156 strcmp (name, section_flags[i].name)) == 0)
159 return section_flags[i].flags_hassize;
161 return section_flags[i].flags_always;
166 return section_flags[i].flags_hassize;
167 return section_flags[i].flags_always;
170 /* Retrieve vms section flags by name and size. */
173 vms_esecflag_by_name (struct sec_flags_struct *section_flags,
179 while (section_flags[i].name != NULL)
181 if (strcmp (name, section_flags[i].name) == 0)
184 return section_flags[i].vflags_hassize;
186 return section_flags[i].vflags_always;
191 return section_flags[i].vflags_hassize;
192 return section_flags[i].vflags_always;
197 struct flagdescstruct { char *name; flagword value; };
199 /* Convert flag to printable string. */
202 flag2str (struct flagdescstruct * flagdesc, flagword flags)
208 while (flagdesc->name != NULL)
210 if ((flags & flagdesc->value) != 0)
216 strcat (res, flagdesc->name);
224 /* Input routines. */
226 /* Process GSD/EGSD record
227 return 0 on success, -1 on error. */
230 _bfd_vms_slurp_gsd (bfd * abfd, int objtype)
233 static struct flagdescstruct gpsflagdesc[] =
250 static struct flagdescstruct gsyflagdesc[] =
263 int gsd_type, gsd_size;
265 unsigned char *vms_rec;
266 flagword new_flags, old_flags;
269 vms_symbol_entry *entry;
270 unsigned long base_addr;
271 unsigned long align_addr;
272 static unsigned int psect_idx = 0;
275 vms_debug (2, "GSD/EGSD (%d/%x)\n", objtype, objtype);
281 PRIV (vms_rec) += 8; /* Skip type, size, l_temp. */
282 PRIV (rec_size) -= 8;
286 PRIV (rec_size) -= 1;
292 /* Calculate base address for each section. */
297 while (PRIV (rec_size) > 0)
299 vms_rec = PRIV (vms_rec);
301 if (objtype == OBJ_S_C_GSD)
305 _bfd_vms_get_header_values (abfd, vms_rec, &gsd_type, &gsd_size);
306 gsd_type += EVAX_OFFSET;
310 vms_debug (3, "gsd_type %d\n", gsd_type);
317 /* Program section definition. */
318 asection *old_section = 0;
321 vms_debug (4, "GSD_S_C_PSC\n");
323 /* If this section isn't a bfd section. */
324 if (PRIV (is_vax) && (psect_idx < (abfd->section_count-1)))
326 /* Check for temporary section from TIR record. */
327 if (psect_idx < PRIV (section_count))
328 old_section = PRIV (sections)[psect_idx];
333 name = _bfd_vms_save_counted_string (vms_rec + 8);
334 section = bfd_make_section (abfd, name);
337 (*_bfd_error_handler) (_("bfd_make_section (%s) failed"),
341 old_flags = bfd_getl16 (vms_rec + 2);
342 section->size = bfd_getl32 (vms_rec + 4); /* allocation */
343 new_flags = vms_secflag_by_name (abfd, vax_section_flags, name,
345 if (old_flags & EGPS_S_V_REL)
346 new_flags |= SEC_RELOC;
347 if (old_flags & GPS_S_M_OVR)
348 new_flags |= SEC_IS_COMMON;
349 if (!bfd_set_section_flags (abfd, section, new_flags))
351 (*_bfd_error_handler)
352 (_("bfd_set_section_flags (%s, %x) failed"),
356 section->alignment_power = vms_rec[1];
357 align_addr = (1 << section->alignment_power);
358 if ((base_addr % align_addr) != 0)
359 base_addr += (align_addr - (base_addr % align_addr));
360 section->vma = (bfd_vma)base_addr;
361 base_addr += section->size;
363 /* Global section is common symbol. */
365 if (old_flags & GPS_S_M_GBL)
367 entry = _bfd_vms_enter_symbol (abfd, name);
370 bfd_set_error (bfd_error_no_memory);
373 symbol = entry->symbol;
376 symbol->section = section;
377 symbol->flags = (BSF_GLOBAL | BSF_SECTION_SYM | BSF_OLD_COMMON);
380 /* Copy saved contents if old_section set. */
381 if (old_section != 0)
383 section->contents = old_section->contents;
384 if (section->size < old_section->size)
386 (*_bfd_error_handler)
387 (_("Size mismatch section %s=%lx, %s=%lx"),
389 (unsigned long) old_section->size,
391 (unsigned long) section->size);
394 else if (section->size > old_section->size)
396 section->contents = bfd_realloc (old_section->contents,
398 if (section->contents == NULL)
400 bfd_set_error (bfd_error_no_memory);
407 section->contents = bfd_zmalloc (section->size);
408 if (section->contents == NULL)
410 bfd_set_error (bfd_error_no_memory);
415 vms_debug (4, "gsd psc %d (%s, flags %04x=%s) ",
416 section->index, name, old_flags, flag2str (gpsflagdesc, old_flags));
417 vms_debug (4, "%d bytes at 0x%08lx (mem %p)\n",
418 section->size, section->vma, section->contents);
421 gsd_size = vms_rec[8] + 9;
430 vms_debug (4, "gsd epm\n");
436 int name_offset = 0, value_offset = 0;
438 /* Symbol specification (definition or reference). */
440 vms_debug (4, "GSD_S_C_SYM(W)\n");
442 old_flags = bfd_getl16 (vms_rec + 2);
443 new_flags = BSF_NO_FLAGS;
445 if (old_flags & GSY_S_M_WEAK)
446 new_flags |= BSF_WEAK;
453 new_flags |= BSF_FUNCTION;
458 new_flags |= BSF_FUNCTION;
461 if (old_flags & GSY_S_M_DEF) /* Symbol definition. */
468 if (old_flags & GSY_S_M_DEF) /* Symbol definition. */
476 /* Save symbol in vms_symbol_table. */
477 entry = _bfd_vms_enter_symbol
478 (abfd, _bfd_vms_save_counted_string (vms_rec + name_offset));
481 bfd_set_error (bfd_error_no_memory);
484 symbol = entry->symbol;
486 if (old_flags & GSY_S_M_DEF)
488 /* Symbol definition. */
491 symbol->value = bfd_getl32 (vms_rec + value_offset);
492 if ((gsd_type == GSD_S_C_SYMW)
493 || (gsd_type == GSD_S_C_EPMW))
494 psect = bfd_getl16 (vms_rec + value_offset - 2);
496 psect = vms_rec[value_offset-1];
498 symbol->section = (asection *) (size_t) psect;
500 vms_debug (4, "gsd sym def #%d (%s, %d [%p], %04x=%s)\n", abfd->symcount,
501 symbol->name, (int)symbol->section, symbol->section, old_flags, flag2str (gsyflagdesc, old_flags));
506 /* Symbol reference. */
507 symbol->section = bfd_make_section (abfd, BFD_UND_SECTION_NAME);
509 vms_debug (4, "gsd sym ref #%d (%s, %s [%p], %04x=%s)\n",
510 abfd->symcount, symbol->name, symbol->section->name,
511 symbol->section, old_flags, flag2str (gsyflagdesc, old_flags));
515 gsd_size = vms_rec[name_offset] + name_offset + 1;
516 symbol->flags = new_flags;
524 vms_debug (4, "gsd pro\n");
529 vms_debug (4, "gsd idc\n");
534 vms_debug (4, "gsd env\n");
539 vms_debug (4, "gsd lsy\n");
544 vms_debug (4, "gsd lepm\n");
549 vms_debug (4, "gsd lpro\n");
554 vms_debug (4, "gsd spsc\n");
559 vms_debug (4, "gsd symv\n");
564 vms_debug (4, "gsd epmv\n");
569 vms_debug (4, "gsd prov\n");
573 case EGSD_S_C_PSC + EVAX_OFFSET:
575 /* Program section definition. */
576 name = _bfd_vms_save_counted_string (vms_rec + 12);
577 section = bfd_make_section (abfd, name);
580 old_flags = bfd_getl16 (vms_rec + 6);
581 section->size = bfd_getl32 (vms_rec + 8); /* Allocation. */
582 new_flags = vms_secflag_by_name (abfd, evax_section_flags, name,
584 if (old_flags & EGPS_S_V_REL)
585 new_flags |= SEC_RELOC;
586 if (!bfd_set_section_flags (abfd, section, new_flags))
588 section->alignment_power = vms_rec[4];
589 align_addr = (1 << section->alignment_power);
590 if ((base_addr % align_addr) != 0)
591 base_addr += (align_addr - (base_addr % align_addr));
592 section->vma = (bfd_vma)base_addr;
593 base_addr += section->size;
594 section->contents = bfd_zmalloc (section->size);
595 if (section->contents == NULL)
598 vms_debug (4, "egsd psc %d (%s, flags %04x=%s) ",
599 section->index, name, old_flags, flag2str (gpsflagdesc, old_flags));
600 vms_debug (4, "%d bytes at 0x%08lx (mem %p)\n",
601 section->size, section->vma, section->contents);
606 case EGSD_S_C_SYM + EVAX_OFFSET:
608 /* Symbol specification (definition or reference). */
609 symbol = bfd_make_empty_symbol (abfd);
613 old_flags = bfd_getl16 (vms_rec + 6);
614 new_flags = BSF_NO_FLAGS;
616 if (old_flags & EGSY_S_V_WEAK)
617 new_flags |= BSF_WEAK;
619 if (vms_rec[6] & EGSY_S_V_DEF)
621 /* Symbol definition. */
622 symbol->name = _bfd_vms_save_counted_string (vms_rec + 32);
623 if (old_flags & EGSY_S_V_NORM)
625 new_flags |= BSF_FUNCTION;
627 symbol->value = bfd_getl64 (vms_rec + 8);
628 symbol->section = (asection *) ((unsigned long) bfd_getl32 (vms_rec + 28));
630 vms_debug (4, "egsd sym def #%d (%s, %d, %04x=%s)\n", abfd->symcount,
631 symbol->name, (int) symbol->section, old_flags,
632 flag2str (gsyflagdesc, old_flags));
637 /* Symbol reference. */
638 symbol->name = _bfd_vms_save_counted_string (vms_rec + 8);
640 vms_debug (4, "egsd sym ref #%d (%s, %04x=%s)\n", abfd->symcount,
641 symbol->name, old_flags, flag2str (gsyflagdesc, old_flags));
643 symbol->section = bfd_make_section (abfd, BFD_UND_SECTION_NAME);
646 symbol->flags = new_flags;
648 /* Save symbol in vms_symbol_table. */
649 entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV (vms_symbol_table),
654 bfd_set_error (bfd_error_no_memory);
658 if (entry->symbol != NULL)
660 /* FIXME ?, DEC C generates this. */
662 vms_debug (4, "EGSD_S_C_SYM: duplicate \"%s\"\n", symbol->name);
667 entry->symbol = symbol;
668 PRIV (gsd_sym_count)++;
674 case EGSD_S_C_IDC + EVAX_OFFSET:
678 (*_bfd_error_handler) (_("unknown gsd/egsd subtype %d"), gsd_type);
679 bfd_set_error (bfd_error_bad_value);
683 PRIV (rec_size) -= gsd_size;
684 PRIV (vms_rec) += gsd_size;
687 if (abfd->symcount > 0)
688 abfd->flags |= HAS_SYMS;
693 /* Output routines. */
695 /* Write section and symbol directory of bfd abfd. */
698 _bfd_vms_write_gsd (bfd *abfd, int objtype ATTRIBUTE_UNUSED)
706 flagword new_flags, old_flags;
709 vms_debug (2, "vms_write_gsd (%p, %d)\n", abfd, objtype);
712 /* Output sections. */
713 section = abfd->sections;
715 vms_debug (3, "%d sections found\n", abfd->section_count);
718 /* Egsd is quadword aligned. */
719 _bfd_vms_output_alignment (abfd, 8);
721 _bfd_vms_output_begin (abfd, EOBJ_S_C_EGSD, -1);
722 _bfd_vms_output_long (abfd, 0);
723 /* Prepare output for subrecords. */
724 _bfd_vms_output_push (abfd);
729 vms_debug (3, "Section #%d %s, %d bytes\n", section->index, section->name, (int)section->size);
732 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
733 if (_bfd_vms_output_check (abfd, 64) < 0)
735 _bfd_vms_output_pop (abfd);
736 _bfd_vms_output_end (abfd);
737 _bfd_vms_output_begin (abfd, EOBJ_S_C_EGSD, -1);
738 _bfd_vms_output_long (abfd, 0);
739 /* Prepare output for subrecords. */
740 _bfd_vms_output_push (abfd);
743 /* Create dummy sections to keep consecutive indices. */
744 while (section->index - last_index > 1)
747 vms_debug (3, "index %d, last %d\n", section->index, last_index);
749 _bfd_vms_output_begin (abfd, EGSD_S_C_PSC, -1);
750 _bfd_vms_output_short (abfd, 0);
751 _bfd_vms_output_short (abfd, 0);
752 _bfd_vms_output_long (abfd, 0);
753 sprintf (dummy_name, ".DUMMY%02d", last_index);
754 _bfd_vms_output_counted (abfd, dummy_name);
755 _bfd_vms_output_flush (abfd);
759 /* Don't know if this is necessary for the linker but for now it keeps
760 vms_slurp_gsd happy */
761 sname = (char *)section->name;
765 if ((*sname == 't') && (strcmp (sname, "text") == 0))
766 sname = PRIV (is_vax)?VAX_CODE_NAME:EVAX_CODE_NAME;
767 else if ((*sname == 'd') && (strcmp (sname, "data") == 0))
768 sname = PRIV (is_vax)?VAX_DATA_NAME:EVAX_DATA_NAME;
769 else if ((*sname == 'b') && (strcmp (sname, "bss") == 0))
770 sname = EVAX_BSS_NAME;
771 else if ((*sname == 'l') && (strcmp (sname, "link") == 0))
772 sname = EVAX_LINK_NAME;
773 else if ((*sname == 'r') && (strcmp (sname, "rdata") == 0))
774 sname = EVAX_READONLY_NAME;
775 else if ((*sname == 'l') && (strcmp (sname, "literal") == 0))
776 sname = EVAX_LITERAL_NAME;
777 else if ((*sname == 'c') && (strcmp (sname, "comm") == 0))
778 sname = EVAX_COMMON_NAME;
779 else if ((*sname == 'l') && (strcmp (sname, "lcomm") == 0))
780 sname = EVAX_LOCAL_NAME;
783 sname = _bfd_vms_length_hash_symbol (abfd, sname, EOBJ_S_C_SECSIZ);
785 _bfd_vms_output_begin (abfd, EGSD_S_C_PSC, -1);
786 _bfd_vms_output_short (abfd, section->alignment_power & 0xff);
787 if (bfd_is_com_section (section))
788 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);
790 new_flags = vms_esecflag_by_name (evax_section_flags, sname,
793 _bfd_vms_output_short (abfd, new_flags);
794 _bfd_vms_output_long (abfd, (unsigned long) section->size);
795 _bfd_vms_output_counted (abfd, sname);
796 _bfd_vms_output_flush (abfd);
798 last_index = section->index;
799 section = section->next;
802 /* Output symbols. */
804 vms_debug (3, "%d symbols found\n", abfd->symcount);
807 bfd_set_start_address (abfd, (bfd_vma) -1);
809 for (symnum = 0; symnum < abfd->symcount; symnum++)
813 symbol = abfd->outsymbols[symnum];
814 if (*(symbol->name) == '_')
816 if (strcmp (symbol->name, "__main") == 0)
817 bfd_set_start_address (abfd, (bfd_vma)symbol->value);
819 old_flags = symbol->flags;
821 if (old_flags & BSF_FILE)
824 if (((old_flags & (BSF_GLOBAL | BSF_WEAK)) == 0) /* Not xdef... */
825 && (!bfd_is_und_section (symbol->section))) /* ...and not xref. */
826 continue; /* Dont output. */
828 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. */
829 if (_bfd_vms_output_check (abfd, 80) < 0)
831 _bfd_vms_output_pop (abfd);
832 _bfd_vms_output_end (abfd);
833 _bfd_vms_output_begin (abfd, EOBJ_S_C_EGSD, -1);
834 _bfd_vms_output_long (abfd, 0);
835 /* Prepare output for subrecords. */
836 _bfd_vms_output_push (abfd);
839 _bfd_vms_output_begin (abfd, EGSD_S_C_SYM, -1);
841 /* Data type, alignment. */
842 _bfd_vms_output_short (abfd, 0);
846 if (old_flags & BSF_WEAK)
847 new_flags |= EGSY_S_V_WEAK;
848 if (bfd_is_com_section (symbol->section))
849 new_flags |= (EGSY_S_V_WEAK | EGSY_S_V_COMM);
851 if (old_flags & BSF_FUNCTION)
853 new_flags |= EGSY_S_V_NORM;
854 new_flags |= EGSY_S_V_REL;
856 if (old_flags & (BSF_GLOBAL | BSF_WEAK))
858 new_flags |= EGSY_S_V_DEF;
859 if (!bfd_is_abs_section (symbol->section))
860 new_flags |= EGSY_S_V_REL;
862 _bfd_vms_output_short (abfd, new_flags);
864 if (old_flags & (BSF_GLOBAL | BSF_WEAK))
866 /* Symbol definition. */
867 uquad code_address = 0;
868 unsigned long ca_psindx = 0;
869 unsigned long psindx;
871 if ((old_flags & BSF_FUNCTION) && symbol->udata.p != NULL)
873 code_address = ((asymbol *) (symbol->udata.p))->value;
874 ca_psindx = ((asymbol *) (symbol->udata.p))->section->index;
876 psindx = symbol->section->index;
878 _bfd_vms_output_quad (abfd, symbol->value);
879 _bfd_vms_output_quad (abfd, code_address);
880 _bfd_vms_output_long (abfd, ca_psindx);
881 _bfd_vms_output_long (abfd, psindx);
883 hash = _bfd_vms_length_hash_symbol (abfd, symbol->name, EOBJ_S_C_SYMSIZ);
884 _bfd_vms_output_counted (abfd, hash);
886 _bfd_vms_output_flush (abfd);
890 _bfd_vms_output_alignment (abfd, 8);
891 _bfd_vms_output_pop (abfd);
892 _bfd_vms_output_end (abfd);