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 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 static flagword vms_secflag_by_name
PARAMS ((bfd
*, struct sec_flags_struct
*, char *, int));
143 static flagword vms_esecflag_by_name
PARAMS ((struct sec_flags_struct
*, char *, int));
145 /* Retrieve bfd section flags by name and size */
148 vms_secflag_by_name (abfd
, section_flags
, name
, hassize
)
150 struct sec_flags_struct
*section_flags
;
156 while (section_flags
[i
].name
!= NULL
)
159 strcasecmp (name
, section_flags
[i
].name
):
160 strcmp (name
, section_flags
[i
].name
)) == 0)
163 return section_flags
[i
].flags_hassize
;
165 return section_flags
[i
].flags_always
;
170 return section_flags
[i
].flags_hassize
;
171 return section_flags
[i
].flags_always
;
174 /* Retrieve vms section flags by name and size */
177 vms_esecflag_by_name (section_flags
, name
, hassize
)
178 struct sec_flags_struct
*section_flags
;
184 while (section_flags
[i
].name
!= NULL
)
186 if (strcmp (name
, section_flags
[i
].name
) == 0)
189 return section_flags
[i
].vflags_hassize
;
191 return section_flags
[i
].vflags_always
;
196 return section_flags
[i
].vflags_hassize
;
197 return section_flags
[i
].vflags_always
;
200 /*-----------------------------------------------------------------------------*/
204 struct flagdescstruct
{ char *name
; flagword value
; };
206 /* Convert flag to printable string */
209 flag2str(flagdesc
, flags
)
210 struct flagdescstruct
*flagdesc
;
218 while (flagdesc
->name
!= NULL
)
220 if ((flags
& flagdesc
->value
) != 0)
226 strcat (res
, flagdesc
->name
);
234 /*-----------------------------------------------------------------------------*/
237 /* Process GSD/EGSD record
238 return 0 on success, -1 on error */
241 _bfd_vms_slurp_gsd (abfd
, objtype
)
246 static struct flagdescstruct gpsflagdesc
[] =
263 static struct flagdescstruct gsyflagdesc
[] =
276 int gsd_type
, gsd_size
;
278 unsigned char *vms_rec
;
279 flagword new_flags
, old_flags
;
282 vms_symbol_entry
*entry
;
283 unsigned long base_addr
;
284 unsigned long align_addr
;
285 static unsigned int psect_idx
= 0;
288 vms_debug (2, "GSD/EGSD (%d/%x)\n", objtype
, objtype
);
294 PRIV(vms_rec
) += 8; /* skip type, size, l_temp */
305 /* calculate base address for each section */
310 while (PRIV(rec_size
) > 0)
312 vms_rec
= PRIV(vms_rec
);
314 if (objtype
== OBJ_S_C_GSD
)
320 _bfd_vms_get_header_values (abfd
, vms_rec
, &gsd_type
, &gsd_size
);
321 gsd_type
+= EVAX_OFFSET
;
325 vms_debug (3, "gsd_type %d\n", gsd_type
);
333 * program section definition
336 asection
*old_section
= 0;
339 vms_debug (4, "GSD_S_C_PSC\n");
341 /* If this section isn't a bfd section. */
343 if (PRIV(is_vax
) && (psect_idx
< (abfd
->section_count
-1)))
345 /* check for temporary section from TIR record. */
347 if (psect_idx
< PRIV(section_count
))
348 old_section
= PRIV(sections
)[psect_idx
];
353 name
= _bfd_vms_save_counted_string (vms_rec
+ 8);
354 section
= bfd_make_section (abfd
, name
);
357 (*_bfd_error_handler
) (_("bfd_make_section (%s) failed"),
361 old_flags
= bfd_getl16 (vms_rec
+ 2);
362 section
->_raw_size
= bfd_getl32 (vms_rec
+ 4); /* allocation */
363 new_flags
= vms_secflag_by_name (abfd
, vax_section_flags
, name
,
364 section
->_raw_size
> 0);
365 if (old_flags
& EGPS_S_V_REL
)
366 new_flags
|= SEC_RELOC
;
367 if (old_flags
& GPS_S_M_OVR
)
368 new_flags
|= SEC_IS_COMMON
;
369 if (!bfd_set_section_flags (abfd
, section
, new_flags
))
371 (*_bfd_error_handler
)
372 (_("bfd_set_section_flags (%s, %x) failed"),
376 section
->alignment_power
= vms_rec
[1];
377 align_addr
= (1 << section
->alignment_power
);
378 if ((base_addr
% align_addr
) != 0)
379 base_addr
+= (align_addr
- (base_addr
% align_addr
));
380 section
->vma
= (bfd_vma
)base_addr
;
381 base_addr
+= section
->_raw_size
;
383 /* global section is common symbol */
385 if (old_flags
& GPS_S_M_GBL
)
387 entry
= _bfd_vms_enter_symbol (abfd
, name
);
388 if (entry
== (vms_symbol_entry
*)NULL
)
390 bfd_set_error (bfd_error_no_memory
);
393 symbol
= entry
->symbol
;
396 symbol
->section
= section
;
397 symbol
->flags
= (BSF_GLOBAL
|BSF_SECTION_SYM
|BSF_OLD_COMMON
);
400 /* copy saved contents if old_section set */
402 if (old_section
!= 0)
404 section
->contents
= old_section
->contents
;
405 if (section
->_raw_size
< old_section
->_raw_size
)
407 (*_bfd_error_handler
)
408 (_("Size mismatch section %s=%lx, %s=%lx"),
410 (unsigned long) old_section
->_raw_size
,
412 (unsigned long) section
->_raw_size
);
415 else if (section
->_raw_size
> old_section
->_raw_size
)
417 section
->contents
= ((unsigned char *)
418 bfd_realloc (old_section
->contents
,
419 section
->_raw_size
));
420 if (section
->contents
== NULL
)
422 bfd_set_error (bfd_error_no_memory
);
429 section
->contents
= ((unsigned char *)
430 bfd_malloc (section
->_raw_size
));
431 if (section
->contents
== NULL
)
433 bfd_set_error (bfd_error_no_memory
);
436 memset (section
->contents
, 0, (size_t) section
->_raw_size
);
438 section
->_cooked_size
= section
->_raw_size
;
440 vms_debug (4, "gsd psc %d (%s, flags %04x=%s) ",
441 section
->index
, name
, old_flags
, flag2str (gpsflagdesc
, old_flags
));
442 vms_debug (4, "%d bytes at 0x%08lx (mem %p)\n",
443 section
->_raw_size
, section
->vma
, section
->contents
);
446 gsd_size
= vms_rec
[8] + 9;
455 vms_debug(4, "gsd epm\n");
461 int name_offset
= 0, value_offset
= 0;
464 * symbol specification (definition or reference)
468 vms_debug (4, "GSD_S_C_SYM(W)\n");
470 old_flags
= bfd_getl16 (vms_rec
+ 2);
471 new_flags
= BSF_NO_FLAGS
;
473 if (old_flags
& GSY_S_M_WEAK
)
474 new_flags
|= BSF_WEAK
;
481 new_flags
|= BSF_FUNCTION
;
486 new_flags
|= BSF_FUNCTION
;
489 if (old_flags
& GSY_S_M_DEF
) /* symbol definition */
496 if (old_flags
& GSY_S_M_DEF
) /* symbol definition */
504 /* save symbol in vms_symbol_table */
506 entry
= _bfd_vms_enter_symbol (abfd
,
507 _bfd_vms_save_counted_string (vms_rec
+ name_offset
));
508 if (entry
== (vms_symbol_entry
*)NULL
)
510 bfd_set_error (bfd_error_no_memory
);
513 symbol
= entry
->symbol
;
515 if (old_flags
& GSY_S_M_DEF
) /* symbol definition */
519 symbol
->value
= bfd_getl32 (vms_rec
+value_offset
);
520 if ((gsd_type
== GSD_S_C_SYMW
)
521 || (gsd_type
== GSD_S_C_EPMW
))
522 psect
= bfd_getl16 (vms_rec
+ value_offset
- 2);
524 psect
= vms_rec
[value_offset
-1];
526 symbol
->section
= (asection
*)psect
;
528 vms_debug(4, "gsd sym def #%d (%s, %d [%p], %04x=%s)\n", abfd
->symcount
,
529 symbol
->name
, (int)symbol
->section
, symbol
->section
, old_flags
, flag2str(gsyflagdesc
, old_flags
));
532 else /* symbol reference */
534 symbol
->section
= bfd_make_section (abfd
, BFD_UND_SECTION_NAME
);
536 vms_debug (4, "gsd sym ref #%d (%s, %s [%p], %04x=%s)\n", abfd
->symcount
,
537 symbol
->name
, symbol
->section
->name
, symbol
->section
, old_flags
, flag2str (gsyflagdesc
, old_flags
));
541 gsd_size
= vms_rec
[name_offset
] + name_offset
+ 1;
542 symbol
->flags
= new_flags
;
550 vms_debug(4, "gsd pro\n");
555 vms_debug(4, "gsd idc\n");
560 vms_debug(4, "gsd env\n");
565 vms_debug(4, "gsd lsy\n");
570 vms_debug(4, "gsd lepm\n");
575 vms_debug(4, "gsd lpro\n");
580 vms_debug(4, "gsd spsc\n");
585 vms_debug(4, "gsd symv\n");
590 vms_debug(4, "gsd epmv\n");
595 vms_debug(4, "gsd prov\n");
599 case EGSD_S_C_PSC
+ EVAX_OFFSET
:
601 /* program section definition */
603 name
= _bfd_vms_save_counted_string (vms_rec
+12);
604 section
= bfd_make_section (abfd
, name
);
607 old_flags
= bfd_getl16 (vms_rec
+ 6);
608 section
->_raw_size
= bfd_getl32 (vms_rec
+ 8); /* allocation */
609 new_flags
= vms_secflag_by_name (abfd
, evax_section_flags
, name
,
610 section
->_raw_size
> 0);
611 if (old_flags
& EGPS_S_V_REL
)
612 new_flags
|= SEC_RELOC
;
613 if (!bfd_set_section_flags (abfd
, section
, new_flags
))
615 section
->alignment_power
= vms_rec
[4];
616 align_addr
= (1 << section
->alignment_power
);
617 if ((base_addr
% align_addr
) != 0)
618 base_addr
+= (align_addr
- (base_addr
% align_addr
));
619 section
->vma
= (bfd_vma
)base_addr
;
620 base_addr
+= section
->_raw_size
;
621 section
->contents
= ((unsigned char *)
622 bfd_malloc (section
->_raw_size
));
623 if (section
->contents
== NULL
)
625 memset (section
->contents
, 0, (size_t) section
->_raw_size
);
626 section
->_cooked_size
= section
->_raw_size
;
628 vms_debug(4, "egsd psc %d (%s, flags %04x=%s) ",
629 section
->index
, name
, old_flags
, flag2str(gpsflagdesc
, old_flags
));
630 vms_debug(4, "%d bytes at 0x%08lx (mem %p)\n",
631 section
->_raw_size
, section
->vma
, section
->contents
);
636 case EGSD_S_C_SYM
+ EVAX_OFFSET
:
638 /* symbol specification (definition or reference) */
640 symbol
= _bfd_vms_make_empty_symbol (abfd
);
644 old_flags
= bfd_getl16 (vms_rec
+ 6);
645 new_flags
= BSF_NO_FLAGS
;
647 if (old_flags
& EGSY_S_V_WEAK
)
648 new_flags
|= BSF_WEAK
;
650 if (vms_rec
[6] & EGSY_S_V_DEF
) /* symbol definition */
653 _bfd_vms_save_counted_string (vms_rec
+32);
654 if (old_flags
& EGSY_S_V_NORM
)
656 new_flags
|= BSF_FUNCTION
;
658 symbol
->value
= bfd_getl64 (vms_rec
+8);
659 symbol
->section
= (asection
*) ((unsigned long) bfd_getl32 (vms_rec
+28));
661 vms_debug(4, "egsd sym def #%d (%s, %d, %04x=%s)\n", abfd
->symcount
,
662 symbol
->name
, (int)symbol
->section
, old_flags
, flag2str(gsyflagdesc
, old_flags
));
665 else /* symbol reference */
668 _bfd_vms_save_counted_string (vms_rec
+8);
670 vms_debug(4, "egsd sym ref #%d (%s, %04x=%s)\n", abfd
->symcount
,
671 symbol
->name
, old_flags
, flag2str(gsyflagdesc
, old_flags
));
673 symbol
->section
= bfd_make_section (abfd
, BFD_UND_SECTION_NAME
);
676 symbol
->flags
= new_flags
;
678 /* save symbol in vms_symbol_table */
680 entry
= (vms_symbol_entry
*) bfd_hash_lookup (PRIV(vms_symbol_table
), symbol
->name
, true, false);
681 if (entry
== (vms_symbol_entry
*)NULL
)
683 bfd_set_error (bfd_error_no_memory
);
686 if (entry
->symbol
!= (asymbol
*)NULL
)
687 { /* FIXME ?, DEC C generates this */
689 vms_debug(4, "EGSD_S_C_SYM: duplicate \"%s\"\n", symbol
->name
);
694 entry
->symbol
= symbol
;
695 PRIV(gsd_sym_count
)++;
701 case EGSD_S_C_IDC
+ EVAX_OFFSET
:
705 (*_bfd_error_handler
) (_("unknown gsd/egsd subtype %d"), gsd_type
);
706 bfd_set_error (bfd_error_bad_value
);
711 PRIV(rec_size
) -= gsd_size
;
712 PRIV(vms_rec
) += gsd_size
;
714 } /* while (recsize > 0) */
716 if (abfd
->symcount
> 0)
717 abfd
->flags
|= HAS_SYMS
;
722 /*-----------------------------------------------------------------------------*/
723 /* output routines */
725 /* Write section and symbol directory of bfd abfd */
728 _bfd_vms_write_gsd (abfd
, objtype
)
730 int objtype ATTRIBUTE_UNUSED
;
738 flagword new_flags
, old_flags
;
741 vms_debug (2, "vms_write_gsd (%p, %d)\n", abfd
, objtype
);
744 /* output sections */
746 section
= abfd
->sections
;
748 vms_debug (3, "%d sections found\n", abfd
->section_count
);
751 /* egsd is quadword aligned */
753 _bfd_vms_output_alignment (abfd
, 8);
755 _bfd_vms_output_begin (abfd
, EOBJ_S_C_EGSD
, -1);
756 _bfd_vms_output_long (abfd
, 0);
757 _bfd_vms_output_push (abfd
); /* prepare output for subrecords */
762 vms_debug (3, "Section #%d %s, %d bytes\n", section
->index
, section
->name
, (int)section
->_raw_size
);
765 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes */
766 if (_bfd_vms_output_check (abfd
, 64) < 0)
768 _bfd_vms_output_pop (abfd
);
769 _bfd_vms_output_end (abfd
);
770 _bfd_vms_output_begin (abfd
, EOBJ_S_C_EGSD
, -1);
771 _bfd_vms_output_long (abfd
, 0);
772 _bfd_vms_output_push (abfd
); /* prepare output for subrecords */
775 /* Create dummy sections to keep consecutive indices */
777 while (section
->index
- last_index
> 1)
780 vms_debug (3, "index %d, last %d\n", section
->index
, last_index
);
782 _bfd_vms_output_begin (abfd
, EGSD_S_C_PSC
, -1);
783 _bfd_vms_output_short (abfd
, 0);
784 _bfd_vms_output_short (abfd
, 0);
785 _bfd_vms_output_long (abfd
, 0);
786 sprintf (dummy_name
, ".DUMMY%02d", last_index
);
787 _bfd_vms_output_counted (abfd
, dummy_name
);
788 _bfd_vms_output_flush (abfd
);
792 /* Don't know if this is neccesary for the linker but for now it keeps
793 vms_slurp_gsd happy */
795 sname
= (char *)section
->name
;
799 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
800 sname
= PRIV(is_vax
)?VAX_CODE_NAME
:EVAX_CODE_NAME
;
801 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
802 sname
= PRIV(is_vax
)?VAX_DATA_NAME
:EVAX_DATA_NAME
;
803 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
804 sname
= EVAX_BSS_NAME
;
805 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
806 sname
= EVAX_LINK_NAME
;
807 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
808 sname
= EVAX_READONLY_NAME
;
809 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
810 sname
= EVAX_LITERAL_NAME
;
811 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
812 sname
= EVAX_COMMON_NAME
;
813 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
814 sname
= EVAX_LOCAL_NAME
;
817 sname
= _bfd_vms_length_hash_symbol (abfd
, sname
, EOBJ_S_C_SECSIZ
);
819 _bfd_vms_output_begin (abfd
, EGSD_S_C_PSC
, -1);
820 _bfd_vms_output_short (abfd
, section
->alignment_power
& 0xff);
821 if (bfd_is_com_section (section
))
823 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
);
827 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
828 section
->_raw_size
> 0);
830 _bfd_vms_output_short (abfd
, new_flags
);
831 _bfd_vms_output_long (abfd
, (unsigned long) section
->_raw_size
);
832 _bfd_vms_output_counted (abfd
, sname
);
833 _bfd_vms_output_flush (abfd
);
835 last_index
= section
->index
;
836 section
= section
->next
;
842 vms_debug (3, "%d symbols found\n", abfd
->symcount
);
845 bfd_set_start_address (abfd
, (bfd_vma
)-1);
847 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
851 symbol
= abfd
->outsymbols
[symnum
];
852 if (*(symbol
->name
) == '_')
854 if (strcmp (symbol
->name
, "__main") == 0)
855 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
857 old_flags
= symbol
->flags
;
859 if (old_flags
& BSF_FILE
)
862 if (((old_flags
& (BSF_GLOBAL
|BSF_WEAK
)) == 0) /* not xdef */
863 && (!bfd_is_und_section (symbol
->section
))) /* and not xref */
864 continue; /* dont output */
866 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes */
868 if (_bfd_vms_output_check (abfd
, 80) < 0)
870 _bfd_vms_output_pop (abfd
);
871 _bfd_vms_output_end (abfd
);
872 _bfd_vms_output_begin (abfd
, EOBJ_S_C_EGSD
, -1);
873 _bfd_vms_output_long (abfd
, 0);
874 _bfd_vms_output_push (abfd
); /* prepare output for subrecords */
877 _bfd_vms_output_begin (abfd
, EGSD_S_C_SYM
, -1);
879 _bfd_vms_output_short (abfd
, 0); /* data type, alignment */
883 if (old_flags
& BSF_WEAK
)
884 new_flags
|= EGSY_S_V_WEAK
;
885 if (bfd_is_com_section (symbol
->section
)) /* .comm */
886 new_flags
|= (EGSY_S_V_WEAK
|EGSY_S_V_COMM
);
888 if (old_flags
& BSF_FUNCTION
)
890 new_flags
|= EGSY_S_V_NORM
;
891 new_flags
|= EGSY_S_V_REL
;
893 if (old_flags
& (BSF_GLOBAL
|BSF_WEAK
))
895 new_flags
|= EGSY_S_V_DEF
;
896 if (!bfd_is_abs_section (symbol
->section
))
897 new_flags
|= EGSY_S_V_REL
;
899 _bfd_vms_output_short (abfd
, new_flags
);
901 if (old_flags
& (BSF_GLOBAL
| BSF_WEAK
)) /* symbol definition */
903 uquad code_address
= 0;
904 unsigned long ca_psindx
= 0;
905 unsigned long psindx
;
907 if (old_flags
& BSF_FUNCTION
)
909 code_address
= ((asymbol
*) (symbol
->udata
.p
))->value
;
910 ca_psindx
= ((asymbol
*) (symbol
->udata
.p
))->section
->index
;
912 psindx
= symbol
->section
->index
;
914 _bfd_vms_output_quad (abfd
, symbol
->value
);
915 _bfd_vms_output_quad (abfd
, code_address
);
916 _bfd_vms_output_long (abfd
, ca_psindx
);
917 _bfd_vms_output_long (abfd
, psindx
);
919 hash
= _bfd_vms_length_hash_symbol (abfd
, symbol
->name
, EOBJ_S_C_SYMSIZ
);
920 _bfd_vms_output_counted (abfd
, hash
);
922 _bfd_vms_output_flush (abfd
);
926 _bfd_vms_output_alignment (abfd
, 8);
927 _bfd_vms_output_pop (abfd
);
928 _bfd_vms_output_end (abfd
);