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
4 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
32 /*-----------------------------------------------------------------------------*/
34 /* typical sections for vax object files */
36 #define VAX_CODE_NAME "$CODE"
37 #define VAX_DATA_NAME "$DATA"
38 #define VAX_ADDRESS_DATA_NAME "$ADDRESS_DATA"
40 /* typical sections for evax object files */
42 #define EVAX_ABS_NAME "$ABS$"
43 #define EVAX_CODE_NAME "$CODE$"
44 #define EVAX_LINK_NAME "$LINK$"
45 #define EVAX_DATA_NAME "$DATA$"
46 #define EVAX_BSS_NAME "$BSS$"
47 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
48 #define EVAX_READONLY_NAME "$READONLY$"
49 #define EVAX_LITERAL_NAME "$LITERAL$"
50 #define EVAX_COMMON_NAME "$COMMON$"
51 #define EVAX_LOCAL_NAME "$LOCAL$"
53 struct sec_flags_struct
{
54 char *name
; /* name of section */
56 flagword flags_always
; /* flags we set always */
58 flagword flags_hassize
; /* flags we set if the section has a size > 0 */
61 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 VAX) compatible */
63 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
[] = {
93 (SEC_IN_MEMORY
|SEC_DATA
|SEC_HAS_CONTENTS
|SEC_ALLOC
|SEC_LOAD
) },
95 (EGPS_S_V_PIC
|EGPS_S_V_REL
|EGPS_S_V_SHR
|EGPS_S_V_EXE
),
97 (EGPS_S_V_PIC
|EGPS_S_V_REL
|EGPS_S_V_SHR
|EGPS_S_V_EXE
),
98 (SEC_IN_MEMORY
|SEC_CODE
|SEC_HAS_CONTENTS
|SEC_ALLOC
|SEC_LOAD
) },
100 (EGPS_S_V_PIC
|EGPS_S_V_REL
|EGPS_S_V_SHR
|EGPS_S_V_RD
|EGPS_S_V_NOMOD
),
101 (SEC_DATA
|SEC_READONLY
),
102 (EGPS_S_V_PIC
|EGPS_S_V_REL
|EGPS_S_V_SHR
|EGPS_S_V_RD
),
103 (SEC_IN_MEMORY
|SEC_DATA
|SEC_HAS_CONTENTS
|SEC_ALLOC
|SEC_READONLY
|SEC_LOAD
) },
105 (EGPS_S_V_REL
|EGPS_S_V_RD
),
106 (SEC_DATA
|SEC_READONLY
),
107 (EGPS_S_V_REL
|EGPS_S_V_RD
),
108 (SEC_IN_MEMORY
|SEC_DATA
|SEC_HAS_CONTENTS
|SEC_ALLOC
|SEC_READONLY
|SEC_LOAD
) },
110 (EGPS_S_V_REL
|EGPS_S_V_RD
|EGPS_S_V_WRT
|EGPS_S_V_NOMOD
),
112 (EGPS_S_V_REL
|EGPS_S_V_RD
|EGPS_S_V_WRT
),
113 (SEC_IN_MEMORY
|SEC_DATA
|SEC_HAS_CONTENTS
|SEC_ALLOC
|SEC_LOAD
) },
115 (EGPS_S_V_REL
|EGPS_S_V_RD
|EGPS_S_V_WRT
|EGPS_S_V_NOMOD
),
117 (EGPS_S_V_REL
|EGPS_S_V_RD
|EGPS_S_V_WRT
|EGPS_S_V_NOMOD
),
118 (SEC_IN_MEMORY
|SEC_HAS_CONTENTS
|SEC_ALLOC
|SEC_LOAD
) },
119 { EVAX_READONLYADDR_NAME
,
120 (EGPS_S_V_PIC
|EGPS_S_V_REL
|EGPS_S_V_RD
),
121 (SEC_DATA
|SEC_READONLY
),
122 (EGPS_S_V_PIC
|EGPS_S_V_REL
|EGPS_S_V_RD
),
123 (SEC_IN_MEMORY
|SEC_DATA
|SEC_HAS_CONTENTS
|SEC_ALLOC
|SEC_READONLY
|SEC_LOAD
) },
124 { EVAX_READONLY_NAME
,
125 (EGPS_S_V_PIC
|EGPS_S_V_REL
|EGPS_S_V_SHR
|EGPS_S_V_RD
|EGPS_S_V_NOMOD
),
126 (SEC_DATA
|SEC_READONLY
),
127 (EGPS_S_V_PIC
|EGPS_S_V_REL
|EGPS_S_V_SHR
|EGPS_S_V_RD
),
128 (SEC_IN_MEMORY
|SEC_DATA
|SEC_HAS_CONTENTS
|SEC_ALLOC
|SEC_READONLY
|SEC_LOAD
) },
130 (EGPS_S_V_REL
|EGPS_S_V_RD
|EGPS_S_V_WRT
),
132 (EGPS_S_V_REL
|EGPS_S_V_RD
|EGPS_S_V_WRT
),
133 (SEC_IN_MEMORY
|SEC_DATA
|SEC_HAS_CONTENTS
|SEC_ALLOC
|SEC_LOAD
) },
135 (EGPS_S_V_REL
|EGPS_S_V_RD
|EGPS_S_V_WRT
),
137 (EGPS_S_V_REL
|EGPS_S_V_RD
|EGPS_S_V_WRT
),
138 (SEC_IN_MEMORY
|SEC_DATA
|SEC_HAS_CONTENTS
|SEC_ALLOC
|SEC_LOAD
) }
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));
144 /* Retrieve bfd section flags by name and size */
147 vms_secflag_by_name (abfd
, section_flags
, name
, hassize
)
149 struct sec_flags_struct
*section_flags
;
155 while (section_flags
[i
].name
!= NULL
)
158 strcasecmp (name
, section_flags
[i
].name
):
159 strcmp (name
, section_flags
[i
].name
)) == 0)
162 return section_flags
[i
].flags_hassize
;
164 return section_flags
[i
].flags_always
;
169 return section_flags
[i
].flags_hassize
;
170 return section_flags
[i
].flags_always
;
173 /* Retrieve vms section flags by name and size */
176 vms_esecflag_by_name (section_flags
, name
, hassize
)
177 struct sec_flags_struct
*section_flags
;
183 while (section_flags
[i
].name
!= NULL
)
185 if (strcmp (name
, section_flags
[i
].name
) == 0)
188 return section_flags
[i
].vflags_hassize
;
190 return section_flags
[i
].vflags_always
;
195 return section_flags
[i
].vflags_hassize
;
196 return section_flags
[i
].vflags_always
;
199 /*-----------------------------------------------------------------------------*/
203 struct flagdescstruct
{ char *name
; flagword value
; };
205 /* Convert flag to printable string */
208 flag2str(flagdesc
, flags
)
209 struct flagdescstruct
*flagdesc
;
217 while (flagdesc
->name
!= NULL
)
219 if ((flags
& flagdesc
->value
) != 0)
225 strcat (res
, flagdesc
->name
);
233 /*-----------------------------------------------------------------------------*/
236 /* Process GSD/EGSD record
237 return 0 on success, -1 on error */
240 _bfd_vms_slurp_gsd (abfd
, objtype
)
245 static struct flagdescstruct gpsflagdesc
[] =
262 static struct flagdescstruct gsyflagdesc
[] =
275 int gsd_type
, gsd_size
;
277 unsigned char *vms_rec
;
278 flagword new_flags
, old_flags
;
281 vms_symbol_entry
*entry
;
282 unsigned long base_addr
;
283 unsigned long align_addr
;
284 static unsigned int psect_idx
= 0;
287 vms_debug (2, "GSD/EGSD (%d/%x)\n", objtype
, objtype
);
293 PRIV(vms_rec
) += 8; /* skip type, size, l_temp */
304 /* calculate base address for each section */
309 while (PRIV(rec_size
) > 0)
311 vms_rec
= PRIV(vms_rec
);
313 if (objtype
== OBJ_S_C_GSD
)
319 _bfd_vms_get_header_values (abfd
, vms_rec
, &gsd_type
, &gsd_size
);
320 gsd_type
+= EVAX_OFFSET
;
324 vms_debug (3, "gsd_type %d\n", gsd_type
);
332 * program section definition
335 asection
*old_section
= 0;
338 vms_debug (4, "GSD_S_C_PSC\n");
340 /* If this section isn't a bfd section. */
342 if (PRIV(is_vax
) && (psect_idx
< (abfd
->section_count
-1)))
344 /* check for temporary section from TIR record. */
346 if (psect_idx
< PRIV(section_count
))
347 old_section
= PRIV(sections
)[psect_idx
];
352 name
= _bfd_vms_save_counted_string (vms_rec
+ 8);
353 section
= bfd_make_section (abfd
, name
);
356 (*_bfd_error_handler
) (_("bfd_make_section (%s) failed"),
360 old_flags
= bfd_getl16 (vms_rec
+ 2);
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);
364 if (old_flags
& EGPS_S_V_REL
)
365 new_flags
|= SEC_RELOC
;
366 if (old_flags
& GPS_S_M_OVR
)
367 new_flags
|= SEC_IS_COMMON
;
368 if (!bfd_set_section_flags (abfd
, section
, new_flags
))
370 (*_bfd_error_handler
)
371 (_("bfd_set_section_flags (%s, %x) failed"),
375 section
->alignment_power
= vms_rec
[1];
376 align_addr
= (1 << section
->alignment_power
);
377 if ((base_addr
% align_addr
) != 0)
378 base_addr
+= (align_addr
- (base_addr
% align_addr
));
379 section
->vma
= (bfd_vma
)base_addr
;
380 base_addr
+= section
->_raw_size
;
382 /* global section is common symbol */
384 if (old_flags
& GPS_S_M_GBL
)
386 entry
= _bfd_vms_enter_symbol (abfd
, name
);
387 if (entry
== (vms_symbol_entry
*)NULL
)
389 bfd_set_error (bfd_error_no_memory
);
392 symbol
= entry
->symbol
;
395 symbol
->section
= section
;
396 symbol
->flags
= (BSF_GLOBAL
|BSF_SECTION_SYM
|BSF_OLD_COMMON
);
399 /* copy saved contents if old_section set */
401 if (old_section
!= 0)
403 section
->contents
= old_section
->contents
;
404 if (section
->_raw_size
< old_section
->_raw_size
)
406 (*_bfd_error_handler
)
407 (_("Size mismatch section %s=%lx, %s=%lx"),
409 (unsigned long) old_section
->_raw_size
,
411 (unsigned long) section
->_raw_size
);
414 else if (section
->_raw_size
> old_section
->_raw_size
)
416 section
->contents
= ((unsigned char *)
417 bfd_realloc (old_section
->contents
,
418 section
->_raw_size
));
419 if (section
->contents
== NULL
)
421 bfd_set_error (bfd_error_no_memory
);
428 section
->contents
= ((unsigned char *)
429 bfd_zmalloc (section
->_raw_size
));
430 if (section
->contents
== NULL
)
432 bfd_set_error (bfd_error_no_memory
);
436 section
->_cooked_size
= section
->_raw_size
;
438 vms_debug (4, "gsd psc %d (%s, flags %04x=%s) ",
439 section
->index
, name
, old_flags
, flag2str (gpsflagdesc
, old_flags
));
440 vms_debug (4, "%d bytes at 0x%08lx (mem %p)\n",
441 section
->_raw_size
, section
->vma
, section
->contents
);
444 gsd_size
= vms_rec
[8] + 9;
453 vms_debug(4, "gsd epm\n");
459 int name_offset
= 0, value_offset
= 0;
462 * symbol specification (definition or reference)
466 vms_debug (4, "GSD_S_C_SYM(W)\n");
468 old_flags
= bfd_getl16 (vms_rec
+ 2);
469 new_flags
= BSF_NO_FLAGS
;
471 if (old_flags
& GSY_S_M_WEAK
)
472 new_flags
|= BSF_WEAK
;
479 new_flags
|= BSF_FUNCTION
;
484 new_flags
|= BSF_FUNCTION
;
487 if (old_flags
& GSY_S_M_DEF
) /* symbol definition */
494 if (old_flags
& GSY_S_M_DEF
) /* symbol definition */
502 /* save symbol in vms_symbol_table */
504 entry
= _bfd_vms_enter_symbol (abfd
,
505 _bfd_vms_save_counted_string (vms_rec
+ name_offset
));
506 if (entry
== (vms_symbol_entry
*)NULL
)
508 bfd_set_error (bfd_error_no_memory
);
511 symbol
= entry
->symbol
;
513 if (old_flags
& GSY_S_M_DEF
) /* symbol definition */
517 symbol
->value
= bfd_getl32 (vms_rec
+value_offset
);
518 if ((gsd_type
== GSD_S_C_SYMW
)
519 || (gsd_type
== GSD_S_C_EPMW
))
520 psect
= bfd_getl16 (vms_rec
+ value_offset
- 2);
522 psect
= vms_rec
[value_offset
-1];
524 symbol
->section
= (asection
*)psect
;
526 vms_debug(4, "gsd sym def #%d (%s, %d [%p], %04x=%s)\n", abfd
->symcount
,
527 symbol
->name
, (int)symbol
->section
, symbol
->section
, old_flags
, flag2str(gsyflagdesc
, old_flags
));
530 else /* symbol reference */
532 symbol
->section
= bfd_make_section (abfd
, BFD_UND_SECTION_NAME
);
534 vms_debug (4, "gsd sym ref #%d (%s, %s [%p], %04x=%s)\n", abfd
->symcount
,
535 symbol
->name
, symbol
->section
->name
, symbol
->section
, old_flags
, flag2str (gsyflagdesc
, old_flags
));
539 gsd_size
= vms_rec
[name_offset
] + name_offset
+ 1;
540 symbol
->flags
= new_flags
;
548 vms_debug(4, "gsd pro\n");
553 vms_debug(4, "gsd idc\n");
558 vms_debug(4, "gsd env\n");
563 vms_debug(4, "gsd lsy\n");
568 vms_debug(4, "gsd lepm\n");
573 vms_debug(4, "gsd lpro\n");
578 vms_debug(4, "gsd spsc\n");
583 vms_debug(4, "gsd symv\n");
588 vms_debug(4, "gsd epmv\n");
593 vms_debug(4, "gsd prov\n");
597 case EGSD_S_C_PSC
+ EVAX_OFFSET
:
599 /* program section definition */
601 name
= _bfd_vms_save_counted_string (vms_rec
+12);
602 section
= bfd_make_section (abfd
, name
);
605 old_flags
= bfd_getl16 (vms_rec
+ 6);
606 section
->_raw_size
= bfd_getl32 (vms_rec
+ 8); /* allocation */
607 new_flags
= vms_secflag_by_name (abfd
, evax_section_flags
, name
,
608 section
->_raw_size
> 0);
609 if (old_flags
& EGPS_S_V_REL
)
610 new_flags
|= SEC_RELOC
;
611 if (!bfd_set_section_flags (abfd
, section
, new_flags
))
613 section
->alignment_power
= vms_rec
[4];
614 align_addr
= (1 << section
->alignment_power
);
615 if ((base_addr
% align_addr
) != 0)
616 base_addr
+= (align_addr
- (base_addr
% align_addr
));
617 section
->vma
= (bfd_vma
)base_addr
;
618 base_addr
+= section
->_raw_size
;
619 section
->contents
= ((unsigned char *)
620 bfd_zmalloc (section
->_raw_size
));
621 if (section
->contents
== NULL
)
623 section
->_cooked_size
= section
->_raw_size
;
625 vms_debug(4, "egsd psc %d (%s, flags %04x=%s) ",
626 section
->index
, name
, old_flags
, flag2str(gpsflagdesc
, old_flags
));
627 vms_debug(4, "%d bytes at 0x%08lx (mem %p)\n",
628 section
->_raw_size
, section
->vma
, section
->contents
);
633 case EGSD_S_C_SYM
+ EVAX_OFFSET
:
635 /* symbol specification (definition or reference) */
637 symbol
= bfd_make_empty_symbol (abfd
);
641 old_flags
= bfd_getl16 (vms_rec
+ 6);
642 new_flags
= BSF_NO_FLAGS
;
644 if (old_flags
& EGSY_S_V_WEAK
)
645 new_flags
|= BSF_WEAK
;
647 if (vms_rec
[6] & EGSY_S_V_DEF
) /* symbol definition */
650 _bfd_vms_save_counted_string (vms_rec
+32);
651 if (old_flags
& EGSY_S_V_NORM
)
653 new_flags
|= BSF_FUNCTION
;
655 symbol
->value
= bfd_getl64 (vms_rec
+8);
656 symbol
->section
= (asection
*) ((unsigned long) bfd_getl32 (vms_rec
+28));
658 vms_debug(4, "egsd sym def #%d (%s, %d, %04x=%s)\n", abfd
->symcount
,
659 symbol
->name
, (int)symbol
->section
, old_flags
, flag2str(gsyflagdesc
, old_flags
));
662 else /* symbol reference */
665 _bfd_vms_save_counted_string (vms_rec
+8);
667 vms_debug(4, "egsd sym ref #%d (%s, %04x=%s)\n", abfd
->symcount
,
668 symbol
->name
, old_flags
, flag2str(gsyflagdesc
, old_flags
));
670 symbol
->section
= bfd_make_section (abfd
, BFD_UND_SECTION_NAME
);
673 symbol
->flags
= new_flags
;
675 /* save symbol in vms_symbol_table */
677 entry
= (vms_symbol_entry
*) bfd_hash_lookup (PRIV(vms_symbol_table
), symbol
->name
, true, false);
678 if (entry
== (vms_symbol_entry
*)NULL
)
680 bfd_set_error (bfd_error_no_memory
);
683 if (entry
->symbol
!= (asymbol
*)NULL
)
684 { /* FIXME ?, DEC C generates this */
686 vms_debug(4, "EGSD_S_C_SYM: duplicate \"%s\"\n", symbol
->name
);
691 entry
->symbol
= symbol
;
692 PRIV(gsd_sym_count
)++;
698 case EGSD_S_C_IDC
+ EVAX_OFFSET
:
702 (*_bfd_error_handler
) (_("unknown gsd/egsd subtype %d"), gsd_type
);
703 bfd_set_error (bfd_error_bad_value
);
708 PRIV(rec_size
) -= gsd_size
;
709 PRIV(vms_rec
) += gsd_size
;
711 } /* while (recsize > 0) */
713 if (abfd
->symcount
> 0)
714 abfd
->flags
|= HAS_SYMS
;
719 /*-----------------------------------------------------------------------------*/
720 /* output routines */
722 /* Write section and symbol directory of bfd abfd */
725 _bfd_vms_write_gsd (abfd
, objtype
)
727 int objtype ATTRIBUTE_UNUSED
;
735 flagword new_flags
, old_flags
;
738 vms_debug (2, "vms_write_gsd (%p, %d)\n", abfd
, objtype
);
741 /* output sections */
743 section
= abfd
->sections
;
745 vms_debug (3, "%d sections found\n", abfd
->section_count
);
748 /* egsd is quadword aligned */
750 _bfd_vms_output_alignment (abfd
, 8);
752 _bfd_vms_output_begin (abfd
, EOBJ_S_C_EGSD
, -1);
753 _bfd_vms_output_long (abfd
, 0);
754 _bfd_vms_output_push (abfd
); /* prepare output for subrecords */
759 vms_debug (3, "Section #%d %s, %d bytes\n", section
->index
, section
->name
, (int)section
->_raw_size
);
762 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes */
763 if (_bfd_vms_output_check (abfd
, 64) < 0)
765 _bfd_vms_output_pop (abfd
);
766 _bfd_vms_output_end (abfd
);
767 _bfd_vms_output_begin (abfd
, EOBJ_S_C_EGSD
, -1);
768 _bfd_vms_output_long (abfd
, 0);
769 _bfd_vms_output_push (abfd
); /* prepare output for subrecords */
772 /* Create dummy sections to keep consecutive indices */
774 while (section
->index
- last_index
> 1)
777 vms_debug (3, "index %d, last %d\n", section
->index
, last_index
);
779 _bfd_vms_output_begin (abfd
, EGSD_S_C_PSC
, -1);
780 _bfd_vms_output_short (abfd
, 0);
781 _bfd_vms_output_short (abfd
, 0);
782 _bfd_vms_output_long (abfd
, 0);
783 sprintf (dummy_name
, ".DUMMY%02d", last_index
);
784 _bfd_vms_output_counted (abfd
, dummy_name
);
785 _bfd_vms_output_flush (abfd
);
789 /* Don't know if this is neccesary for the linker but for now it keeps
790 vms_slurp_gsd happy */
792 sname
= (char *)section
->name
;
796 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
797 sname
= PRIV(is_vax
)?VAX_CODE_NAME
:EVAX_CODE_NAME
;
798 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
799 sname
= PRIV(is_vax
)?VAX_DATA_NAME
:EVAX_DATA_NAME
;
800 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
801 sname
= EVAX_BSS_NAME
;
802 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
803 sname
= EVAX_LINK_NAME
;
804 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
805 sname
= EVAX_READONLY_NAME
;
806 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
807 sname
= EVAX_LITERAL_NAME
;
808 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
809 sname
= EVAX_COMMON_NAME
;
810 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
811 sname
= EVAX_LOCAL_NAME
;
814 sname
= _bfd_vms_length_hash_symbol (abfd
, sname
, EOBJ_S_C_SECSIZ
);
816 _bfd_vms_output_begin (abfd
, EGSD_S_C_PSC
, -1);
817 _bfd_vms_output_short (abfd
, section
->alignment_power
& 0xff);
818 if (bfd_is_com_section (section
))
820 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
);
824 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
825 section
->_raw_size
> 0);
827 _bfd_vms_output_short (abfd
, new_flags
);
828 _bfd_vms_output_long (abfd
, (unsigned long) section
->_raw_size
);
829 _bfd_vms_output_counted (abfd
, sname
);
830 _bfd_vms_output_flush (abfd
);
832 last_index
= section
->index
;
833 section
= section
->next
;
839 vms_debug (3, "%d symbols found\n", abfd
->symcount
);
842 bfd_set_start_address (abfd
, (bfd_vma
)-1);
844 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
848 symbol
= abfd
->outsymbols
[symnum
];
849 if (*(symbol
->name
) == '_')
851 if (strcmp (symbol
->name
, "__main") == 0)
852 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
854 old_flags
= symbol
->flags
;
856 if (old_flags
& BSF_FILE
)
859 if (((old_flags
& (BSF_GLOBAL
|BSF_WEAK
)) == 0) /* not xdef */
860 && (!bfd_is_und_section (symbol
->section
))) /* and not xref */
861 continue; /* dont output */
863 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes */
865 if (_bfd_vms_output_check (abfd
, 80) < 0)
867 _bfd_vms_output_pop (abfd
);
868 _bfd_vms_output_end (abfd
);
869 _bfd_vms_output_begin (abfd
, EOBJ_S_C_EGSD
, -1);
870 _bfd_vms_output_long (abfd
, 0);
871 _bfd_vms_output_push (abfd
); /* prepare output for subrecords */
874 _bfd_vms_output_begin (abfd
, EGSD_S_C_SYM
, -1);
876 _bfd_vms_output_short (abfd
, 0); /* data type, alignment */
880 if (old_flags
& BSF_WEAK
)
881 new_flags
|= EGSY_S_V_WEAK
;
882 if (bfd_is_com_section (symbol
->section
)) /* .comm */
883 new_flags
|= (EGSY_S_V_WEAK
|EGSY_S_V_COMM
);
885 if (old_flags
& BSF_FUNCTION
)
887 new_flags
|= EGSY_S_V_NORM
;
888 new_flags
|= EGSY_S_V_REL
;
890 if (old_flags
& (BSF_GLOBAL
|BSF_WEAK
))
892 new_flags
|= EGSY_S_V_DEF
;
893 if (!bfd_is_abs_section (symbol
->section
))
894 new_flags
|= EGSY_S_V_REL
;
896 _bfd_vms_output_short (abfd
, new_flags
);
898 if (old_flags
& (BSF_GLOBAL
| BSF_WEAK
)) /* symbol definition */
900 uquad code_address
= 0;
901 unsigned long ca_psindx
= 0;
902 unsigned long psindx
;
904 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
906 code_address
= ((asymbol
*) (symbol
->udata
.p
))->value
;
907 ca_psindx
= ((asymbol
*) (symbol
->udata
.p
))->section
->index
;
909 psindx
= symbol
->section
->index
;
911 _bfd_vms_output_quad (abfd
, symbol
->value
);
912 _bfd_vms_output_quad (abfd
, code_address
);
913 _bfd_vms_output_long (abfd
, ca_psindx
);
914 _bfd_vms_output_long (abfd
, psindx
);
916 hash
= _bfd_vms_length_hash_symbol (abfd
, symbol
->name
, EOBJ_S_C_SYMSIZ
);
917 _bfd_vms_output_counted (abfd
, hash
);
919 _bfd_vms_output_flush (abfd
);
923 _bfd_vms_output_alignment (abfd
, 8);
924 _bfd_vms_output_pop (abfd
);
925 _bfd_vms_output_end (abfd
);