xref: /openbsd-src/gnu/usr.bin/binutils/bfd/vms-hdr.c (revision cf2f2c5620d6d9a4fd01930983c4b9a1f76d7aa3)
1f7cc78ecSespie /* vms-hdr.c -- BFD back-end for VMS/VAX (openVMS/VAX) and
2f7cc78ecSespie    EVAX (openVMS/Alpha) files.
3d2201f2fSdrahn    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
4d2201f2fSdrahn    Free Software Foundation, Inc.
5f7cc78ecSespie 
6f7cc78ecSespie    HDR record handling functions
7f7cc78ecSespie    EMH record handling functions
8f7cc78ecSespie    and
9f7cc78ecSespie    EOM record handling functions
10f7cc78ecSespie    EEOM record handling functions
11f7cc78ecSespie 
12f7cc78ecSespie    Written by Klaus K"ampf (kkaempf@rmi.de)
13f7cc78ecSespie 
14f7cc78ecSespie This program is free software; you can redistribute it and/or modify
15f7cc78ecSespie it under the terms of the GNU General Public License as published by
16f7cc78ecSespie the Free Software Foundation; either version 2 of the License, or
17f7cc78ecSespie (at your option) any later version.
18f7cc78ecSespie 
19f7cc78ecSespie This program is distributed in the hope that it will be useful,
20f7cc78ecSespie but WITHOUT ANY WARRANTY; without even the implied warranty of
21f7cc78ecSespie MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22f7cc78ecSespie GNU General Public License for more details.
23f7cc78ecSespie 
24f7cc78ecSespie You should have received a copy of the GNU General Public License
25f7cc78ecSespie along with this program; if not, write to the Free Software
26f7cc78ecSespie Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
27f7cc78ecSespie 
28f7cc78ecSespie #include "bfd.h"
29d2201f2fSdrahn #include "bfdver.h"
30f7cc78ecSespie #include "sysdep.h"
31f7cc78ecSespie #include "bfdlink.h"
32d2201f2fSdrahn #include "safe-ctype.h"
33f7cc78ecSespie #include "libbfd.h"
34f7cc78ecSespie 
35f7cc78ecSespie #include "vms.h"
36f7cc78ecSespie 
375f210c2aSfgsch #ifdef HAVE_ALLOCA_H
385f210c2aSfgsch #include <alloca.h>
395f210c2aSfgsch #endif
40d2201f2fSdrahn 
41d2201f2fSdrahn static unsigned char *get_vms_time_string PARAMS ((void));
42d2201f2fSdrahn 
43d2201f2fSdrahn 
44f7cc78ecSespie /*---------------------------------------------------------------------------*/
45f7cc78ecSespie 
46f7cc78ecSespie /* Read & process emh record
47f7cc78ecSespie    return 0 on success, -1 on error  */
48f7cc78ecSespie 
49f7cc78ecSespie int
_bfd_vms_slurp_hdr(abfd,objtype)50f7cc78ecSespie _bfd_vms_slurp_hdr (abfd, objtype)
51f7cc78ecSespie      bfd *abfd;
52f7cc78ecSespie      int objtype;
53f7cc78ecSespie {
54f7cc78ecSespie   unsigned char *ptr;
55f7cc78ecSespie   unsigned char *vms_rec;
56f7cc78ecSespie   int subtype;
57f7cc78ecSespie 
58f7cc78ecSespie   vms_rec = PRIV(vms_rec);
59f7cc78ecSespie 
60f7cc78ecSespie #if VMS_DEBUG
61f7cc78ecSespie   vms_debug(2, "HDR/EMH\n");
62f7cc78ecSespie #endif
63f7cc78ecSespie 
64f7cc78ecSespie   switch (objtype)
65f7cc78ecSespie     {
66f7cc78ecSespie       case OBJ_S_C_HDR:
67f7cc78ecSespie 	subtype = vms_rec[1];
68f7cc78ecSespie 	break;
69f7cc78ecSespie       case EOBJ_S_C_EMH:
70f7cc78ecSespie 	subtype = bfd_getl16 (vms_rec + 4) + EVAX_OFFSET;
71f7cc78ecSespie 	break;
72f7cc78ecSespie       default:
73f7cc78ecSespie 	subtype = -1;
74f7cc78ecSespie     }
75f7cc78ecSespie 
76f7cc78ecSespie #if VMS_DEBUG
77f7cc78ecSespie   vms_debug(3, "subtype %d\n", subtype);
78f7cc78ecSespie #endif
79f7cc78ecSespie 
80f7cc78ecSespie   switch (subtype)
81f7cc78ecSespie     {
82f7cc78ecSespie 
83f7cc78ecSespie       case MHD_S_C_MHD:
84f7cc78ecSespie 	/*
85f7cc78ecSespie 	 * module header
86f7cc78ecSespie 	 */
87f7cc78ecSespie 	PRIV(hdr_data).hdr_b_strlvl = vms_rec[2];
88f7cc78ecSespie 	PRIV(hdr_data).hdr_l_recsiz = bfd_getl16 (vms_rec + 3);
89f7cc78ecSespie 	PRIV(hdr_data).hdr_t_name = _bfd_vms_save_counted_string (vms_rec + 5);
90f7cc78ecSespie 	ptr = vms_rec + 5 + vms_rec[5] + 1;
91f7cc78ecSespie 	PRIV(hdr_data).hdr_t_version = _bfd_vms_save_counted_string (ptr);
92f7cc78ecSespie 	ptr += *ptr + 1;
93f7cc78ecSespie 	PRIV(hdr_data).hdr_t_date = _bfd_vms_save_sized_string (ptr, 17);
94f7cc78ecSespie 
95f7cc78ecSespie       break;
96f7cc78ecSespie 
97f7cc78ecSespie       case MHD_S_C_LNM:
98f7cc78ecSespie 	/*
99f7cc78ecSespie 	 *
100f7cc78ecSespie 	 */
101f7cc78ecSespie 	PRIV(hdr_data).hdr_c_lnm = _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-2));
102f7cc78ecSespie       break;
103f7cc78ecSespie 
104f7cc78ecSespie       case MHD_S_C_SRC:
105f7cc78ecSespie 	/*
106f7cc78ecSespie 	 *
107f7cc78ecSespie 	 */
108f7cc78ecSespie 	PRIV(hdr_data).hdr_c_src = _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-2));
109f7cc78ecSespie       break;
110f7cc78ecSespie 
111f7cc78ecSespie       case MHD_S_C_TTL:
112f7cc78ecSespie 	/*
113f7cc78ecSespie 	 *
114f7cc78ecSespie 	 */
115f7cc78ecSespie 	PRIV(hdr_data).hdr_c_ttl = _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-2));
116f7cc78ecSespie       break;
117f7cc78ecSespie 
118f7cc78ecSespie       case MHD_S_C_CPR:
119f7cc78ecSespie 	/*
120f7cc78ecSespie 	 *
121f7cc78ecSespie 	 */
122f7cc78ecSespie       break;
123f7cc78ecSespie 
124f7cc78ecSespie       case MHD_S_C_MTC:
125f7cc78ecSespie 	/*
126f7cc78ecSespie 	 *
127f7cc78ecSespie 	 */
128f7cc78ecSespie       break;
129f7cc78ecSespie 
130f7cc78ecSespie       case MHD_S_C_GTX:
131f7cc78ecSespie 	/*
132f7cc78ecSespie 	 *
133f7cc78ecSespie 	 */
134f7cc78ecSespie       break;
135f7cc78ecSespie 
136f7cc78ecSespie       case EMH_S_C_MHD + EVAX_OFFSET:
137f7cc78ecSespie 	/*
138f7cc78ecSespie 	 * module header
139f7cc78ecSespie 	 */
140f7cc78ecSespie 	PRIV(hdr_data).hdr_b_strlvl = vms_rec[6];
141f7cc78ecSespie 	PRIV(hdr_data).hdr_l_arch1 = bfd_getl32 (vms_rec + 8);
142f7cc78ecSespie 	PRIV(hdr_data).hdr_l_arch2 = bfd_getl32 (vms_rec + 12);
143f7cc78ecSespie 	PRIV(hdr_data).hdr_l_recsiz = bfd_getl32 (vms_rec + 16);
144f7cc78ecSespie 	PRIV(hdr_data).hdr_t_name =
145f7cc78ecSespie 	  _bfd_vms_save_counted_string (vms_rec + 20);
146f7cc78ecSespie 	ptr = vms_rec + 20 + vms_rec[20] + 1;
147f7cc78ecSespie 	PRIV(hdr_data).hdr_t_version =
148f7cc78ecSespie 	  _bfd_vms_save_counted_string (ptr);
149f7cc78ecSespie 	ptr += *ptr + 1;
150f7cc78ecSespie 	PRIV(hdr_data).hdr_t_date =
151f7cc78ecSespie 	  _bfd_vms_save_sized_string (ptr, 17);
152f7cc78ecSespie 
153f7cc78ecSespie       break;
154f7cc78ecSespie 
155f7cc78ecSespie       case EMH_S_C_LNM + EVAX_OFFSET:
156f7cc78ecSespie 	/*
157f7cc78ecSespie 	 *
158f7cc78ecSespie 	 */
159f7cc78ecSespie 	PRIV(hdr_data).hdr_c_lnm =
160f7cc78ecSespie 	  _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-6));
161f7cc78ecSespie       break;
162f7cc78ecSespie 
163f7cc78ecSespie       case EMH_S_C_SRC + EVAX_OFFSET:
164f7cc78ecSespie 	/*
165f7cc78ecSespie 	 *
166f7cc78ecSespie 	 */
167f7cc78ecSespie 	PRIV(hdr_data).hdr_c_src =
168f7cc78ecSespie 	  _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-6));
169f7cc78ecSespie       break;
170f7cc78ecSespie 
171f7cc78ecSespie       case EMH_S_C_TTL + EVAX_OFFSET:
172f7cc78ecSespie 	/*
173f7cc78ecSespie 	 *
174f7cc78ecSespie 	 */
175f7cc78ecSespie 	PRIV(hdr_data).hdr_c_ttl =
176f7cc78ecSespie 	  _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-6));
177f7cc78ecSespie       break;
178f7cc78ecSespie 
179f7cc78ecSespie       case EMH_S_C_CPR + EVAX_OFFSET:
180f7cc78ecSespie 	/*
181f7cc78ecSespie 	 *
182f7cc78ecSespie 	 */
183f7cc78ecSespie       break;
184f7cc78ecSespie 
185f7cc78ecSespie       case EMH_S_C_MTC + EVAX_OFFSET:
186f7cc78ecSespie 	/*
187f7cc78ecSespie 	 *
188f7cc78ecSespie 	 */
189f7cc78ecSespie       break;
190f7cc78ecSespie 
191f7cc78ecSespie       case EMH_S_C_GTX + EVAX_OFFSET:
192f7cc78ecSespie 	/*
193f7cc78ecSespie 	 *
194f7cc78ecSespie 	 */
195f7cc78ecSespie       break;
196f7cc78ecSespie 
197f7cc78ecSespie       default:
198f7cc78ecSespie 	bfd_set_error (bfd_error_wrong_format);
199f7cc78ecSespie       return -1;
200f7cc78ecSespie 
201f7cc78ecSespie     } /* switch */
202f7cc78ecSespie 
203f7cc78ecSespie   return 0;
204f7cc78ecSespie }
205f7cc78ecSespie 
206f7cc78ecSespie /*-----------------------------------------------------------------------------*/
207f7cc78ecSespie /* Output routines.  */
208f7cc78ecSespie 
209*cf2f2c56Smiod /* Manufacture a VMS like time on a unix based system.
210f7cc78ecSespie    stolen from obj-vms.c  */
211f7cc78ecSespie 
212f7cc78ecSespie static unsigned char *
get_vms_time_string()213f7cc78ecSespie get_vms_time_string ()
214f7cc78ecSespie {
215f7cc78ecSespie   static unsigned char tbuf[18];
216f7cc78ecSespie #ifndef VMS
217f7cc78ecSespie #include <time.h>
218f7cc78ecSespie 
219f7cc78ecSespie   char *pnt;
220f7cc78ecSespie   time_t timeb;
221f7cc78ecSespie   time (&timeb);
222f7cc78ecSespie   pnt = ctime (&timeb);
223f7cc78ecSespie   pnt[3] = 0;
224f7cc78ecSespie   pnt[7] = 0;
225f7cc78ecSespie   pnt[10] = 0;
226f7cc78ecSespie   pnt[16] = 0;
227f7cc78ecSespie   pnt[24] = 0;
228f7cc78ecSespie   sprintf (tbuf, "%2s-%3s-%s %s", pnt + 8, pnt + 4, pnt + 20, pnt + 11);
229f7cc78ecSespie #else
230f7cc78ecSespie #include <starlet.h>
231f7cc78ecSespie   struct
232f7cc78ecSespie   {
233f7cc78ecSespie     int Size;
234f7cc78ecSespie     unsigned char *Ptr;
235f7cc78ecSespie   } Descriptor;
236f7cc78ecSespie   Descriptor.Size = 17;
237f7cc78ecSespie   Descriptor.Ptr = tbuf;
238f7cc78ecSespie   SYS$ASCTIM (0, &Descriptor, 0, 0);
239f7cc78ecSespie #endif /* not VMS */
240f7cc78ecSespie 
241f7cc78ecSespie #if VMS_DEBUG
242f7cc78ecSespie   vms_debug (6, "vmstimestring:'%s'\n", tbuf);
243f7cc78ecSespie #endif
244f7cc78ecSespie 
245f7cc78ecSespie   return tbuf;
246f7cc78ecSespie }
247f7cc78ecSespie 
248f7cc78ecSespie /* write object header for bfd abfd  */
249f7cc78ecSespie 
250f7cc78ecSespie int
_bfd_vms_write_hdr(abfd,objtype)251f7cc78ecSespie _bfd_vms_write_hdr (abfd, objtype)
252f7cc78ecSespie      bfd *abfd;
253f7cc78ecSespie      int objtype;
254f7cc78ecSespie {
255f7cc78ecSespie   asymbol *symbol;
256f7cc78ecSespie   unsigned int symnum;
257f7cc78ecSespie   int had_case = 0;
258f7cc78ecSespie   int had_file = 0;
259f7cc78ecSespie 
260f7cc78ecSespie #if VMS_DEBUG
261f7cc78ecSespie   vms_debug (2, "vms_write_hdr (%p)\n", abfd);
262f7cc78ecSespie #endif
263f7cc78ecSespie 
264f7cc78ecSespie   _bfd_vms_output_alignment (abfd, 2);
265f7cc78ecSespie 
266f7cc78ecSespie   /* MHD */
267f7cc78ecSespie 
268f7cc78ecSespie   if (objtype == OBJ_S_C_HDR)
269f7cc78ecSespie     {
270f7cc78ecSespie     }
271f7cc78ecSespie   else
272f7cc78ecSespie     {
273f7cc78ecSespie       _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_MHD);
274f7cc78ecSespie       _bfd_vms_output_short (abfd, EOBJ_S_C_STRLVL);
275f7cc78ecSespie       _bfd_vms_output_long (abfd, 0);
276f7cc78ecSespie       _bfd_vms_output_long (abfd, 0);
277f7cc78ecSespie       _bfd_vms_output_long (abfd, MAX_OUTREC_SIZE);
278f7cc78ecSespie     }
279f7cc78ecSespie 
280f7cc78ecSespie   if (bfd_get_filename (abfd) != 0)
281f7cc78ecSespie     {
282f7cc78ecSespie       /* strip path and suffix information */
283f7cc78ecSespie 
284f7cc78ecSespie       char *fname, *fout, *fptr;
285f7cc78ecSespie 
286f7cc78ecSespie       fptr = bfd_get_filename (abfd);
287f7cc78ecSespie       fname = (char *) alloca (strlen (fptr) + 1);
288f7cc78ecSespie       strcpy (fname, fptr);
289f7cc78ecSespie       fout = strrchr (fname, ']');
290f7cc78ecSespie       if (fout == 0)
291f7cc78ecSespie 	fout = strchr (fname, ':');
292f7cc78ecSespie       if (fout != 0)
293f7cc78ecSespie 	fout++;
294f7cc78ecSespie       else
295f7cc78ecSespie 	fout = fname;
296f7cc78ecSespie 
297f7cc78ecSespie       /* strip .obj suffix  */
298f7cc78ecSespie 
299f7cc78ecSespie       fptr = strrchr (fname, '.');
300f7cc78ecSespie       if ((fptr != 0)
301f7cc78ecSespie 	  && (strcasecmp (fptr, ".OBJ") == 0))
302f7cc78ecSespie 	*fptr = 0;
303f7cc78ecSespie 
304f7cc78ecSespie       fptr = fout;
305f7cc78ecSespie       while (*fptr != 0)
306f7cc78ecSespie 	{
307d2201f2fSdrahn 	  *fptr = TOUPPER (*fptr);
308f7cc78ecSespie 	  fptr++;
309f7cc78ecSespie 	  if ((*fptr == ';')
310f7cc78ecSespie 	     || ((fptr - fout) > 31))
311f7cc78ecSespie 	    *fptr = 0;
312f7cc78ecSespie 	}
313f7cc78ecSespie       _bfd_vms_output_counted (abfd, fout);
314f7cc78ecSespie     }
315f7cc78ecSespie   else
316f7cc78ecSespie     _bfd_vms_output_counted (abfd, "NONAME");
317f7cc78ecSespie 
318d2201f2fSdrahn   _bfd_vms_output_counted (abfd, BFD_VERSION_STRING);
319f7cc78ecSespie   _bfd_vms_output_dump (abfd, get_vms_time_string (), 17);
320f7cc78ecSespie   _bfd_vms_output_fill (abfd, 0, 17);
321f7cc78ecSespie   _bfd_vms_output_flush (abfd);
322f7cc78ecSespie 
323f7cc78ecSespie   /* LMN */
324f7cc78ecSespie 
325f7cc78ecSespie   _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_LNM);
326f7cc78ecSespie   _bfd_vms_output_dump (abfd, (unsigned char *)"GAS proGIS", 10);
327f7cc78ecSespie   _bfd_vms_output_flush (abfd);
328f7cc78ecSespie 
329f7cc78ecSespie   /* SRC */
330f7cc78ecSespie 
331f7cc78ecSespie   _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_SRC);
332f7cc78ecSespie 
333f7cc78ecSespie   for (symnum = 0; symnum < abfd->symcount; symnum++)
334f7cc78ecSespie     {
335f7cc78ecSespie       symbol = abfd->outsymbols[symnum];
336f7cc78ecSespie 
337f7cc78ecSespie       if (symbol->flags & BSF_FILE)
338f7cc78ecSespie 	{
339f7cc78ecSespie 	  if (strncmp ((char *)symbol->name, "<CASE:", 6) == 0)
340f7cc78ecSespie 	    {
341f7cc78ecSespie 	      PRIV(flag_hash_long_names) = symbol->name[6] - '0';
342f7cc78ecSespie 	      PRIV(flag_show_after_trunc) = symbol->name[7] - '0';
343f7cc78ecSespie 
344f7cc78ecSespie 	      if (had_file)
345f7cc78ecSespie 		break;
346f7cc78ecSespie 	      had_case = 1;
347f7cc78ecSespie 	      continue;
348f7cc78ecSespie 	    }
349f7cc78ecSespie 
350d2201f2fSdrahn 	  _bfd_vms_output_dump (abfd, (unsigned char *) symbol->name,
351d2201f2fSdrahn 				(int) strlen (symbol->name));
352f7cc78ecSespie 	  if (had_case)
353f7cc78ecSespie 	    break;
354f7cc78ecSespie 	  had_file = 1;
355f7cc78ecSespie 	}
356f7cc78ecSespie     }
357f7cc78ecSespie 
358f7cc78ecSespie   if (symnum == abfd->symcount)
359f7cc78ecSespie     _bfd_vms_output_dump (abfd, (unsigned char *)"noname", 6);
360f7cc78ecSespie 
361f7cc78ecSespie   _bfd_vms_output_flush (abfd);
362f7cc78ecSespie 
363f7cc78ecSespie   /* TTL */
364f7cc78ecSespie 
365f7cc78ecSespie   _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_TTL);
366f7cc78ecSespie   _bfd_vms_output_dump (abfd, (unsigned char *)"TTL", 3);
367f7cc78ecSespie   _bfd_vms_output_flush (abfd);
368f7cc78ecSespie 
369f7cc78ecSespie   /* CPR */
370f7cc78ecSespie 
371f7cc78ecSespie   _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_CPR);
372f7cc78ecSespie   _bfd_vms_output_dump (abfd,
373f7cc78ecSespie 			 (unsigned char *)"GNU BFD ported by Klaus K�mpf 1994-1996",
374f7cc78ecSespie 			 39);
375f7cc78ecSespie   _bfd_vms_output_flush (abfd);
376f7cc78ecSespie 
377f7cc78ecSespie   return 0;
378f7cc78ecSespie }
379f7cc78ecSespie 
380f7cc78ecSespie /*-----------------------------------------------------------------------------*/
381f7cc78ecSespie 
382f7cc78ecSespie /* Process EOM/EEOM record
383f7cc78ecSespie    return 0 on success, -1 on error  */
384f7cc78ecSespie 
385f7cc78ecSespie int
_bfd_vms_slurp_eom(abfd,objtype)386f7cc78ecSespie _bfd_vms_slurp_eom (abfd, objtype)
387f7cc78ecSespie      bfd *abfd;
388f7cc78ecSespie      int objtype;
389f7cc78ecSespie {
390f7cc78ecSespie   unsigned char *vms_rec;
391f7cc78ecSespie 
392f7cc78ecSespie #if VMS_DEBUG
393f7cc78ecSespie   vms_debug(2, "EOM/EEOM\n");
394f7cc78ecSespie #endif
395f7cc78ecSespie 
396f7cc78ecSespie   vms_rec = PRIV(vms_rec);
397f7cc78ecSespie 
398f7cc78ecSespie   if ((objtype == OBJ_S_C_EOM)
399f7cc78ecSespie      || (objtype == OBJ_S_C_EOMW))
400f7cc78ecSespie     {
401f7cc78ecSespie     }
402f7cc78ecSespie   else
403f7cc78ecSespie     {
404f7cc78ecSespie       PRIV(eom_data).eom_l_total_lps = bfd_getl32 (vms_rec + 4);
405f7cc78ecSespie       PRIV(eom_data).eom_b_comcod = *(vms_rec + 8);
406f7cc78ecSespie       if (PRIV(eom_data).eom_b_comcod > 1)
407f7cc78ecSespie 	{
408f7cc78ecSespie 	  (*_bfd_error_handler) (_("Object module NOT error-free !\n"));
409f7cc78ecSespie 	  bfd_set_error (bfd_error_bad_value);
410f7cc78ecSespie 	  return -1;
411f7cc78ecSespie 	}
412d2201f2fSdrahn       PRIV(eom_data).eom_has_transfer = FALSE;
413f7cc78ecSespie       if (PRIV(rec_size) > 10)
414f7cc78ecSespie 	{
415d2201f2fSdrahn 	   PRIV(eom_data).eom_has_transfer = TRUE;
416f7cc78ecSespie 	   PRIV(eom_data).eom_b_tfrflg = *(vms_rec + 9);
417f7cc78ecSespie 	   PRIV(eom_data).eom_l_psindx = bfd_getl32 (vms_rec + 12);
418f7cc78ecSespie 	   PRIV(eom_data).eom_l_tfradr = bfd_getl32 (vms_rec + 16);
419f7cc78ecSespie 
420f7cc78ecSespie 	   abfd->start_address = PRIV(eom_data).eom_l_tfradr;
421f7cc78ecSespie 	}
422f7cc78ecSespie     }
423f7cc78ecSespie   return 0;
424f7cc78ecSespie }
425f7cc78ecSespie 
426f7cc78ecSespie /* Write eom record for bfd abfd  */
427f7cc78ecSespie 
428f7cc78ecSespie int
_bfd_vms_write_eom(abfd,objtype)429f7cc78ecSespie _bfd_vms_write_eom (abfd, objtype)
430f7cc78ecSespie      bfd *abfd;
431f7cc78ecSespie      int objtype;
432f7cc78ecSespie {
433f7cc78ecSespie #if VMS_DEBUG
434f7cc78ecSespie   vms_debug (2, "vms_write_eom (%p, %d)\n", abfd, objtype);
435f7cc78ecSespie #endif
436f7cc78ecSespie 
437f7cc78ecSespie   _bfd_vms_output_begin (abfd, objtype, -1);
438f7cc78ecSespie   _bfd_vms_output_long (abfd, (unsigned long) (PRIV(vms_linkage_index) >> 1));
439f7cc78ecSespie   _bfd_vms_output_byte (abfd, 0);	/* completion code */
440f7cc78ecSespie   _bfd_vms_output_byte (abfd, 0);	/* fill byte */
441f7cc78ecSespie 
442f7cc78ecSespie   if (bfd_get_start_address (abfd) != (bfd_vma)-1)
443f7cc78ecSespie     {
444f7cc78ecSespie       asection *section;
445f7cc78ecSespie 
446f7cc78ecSespie       section = bfd_get_section_by_name (abfd, ".link");
447f7cc78ecSespie       if (section == 0)
448f7cc78ecSespie 	{
449f7cc78ecSespie 	  bfd_set_error (bfd_error_nonrepresentable_section);
450f7cc78ecSespie 	  return -1;
451f7cc78ecSespie 	}
452f7cc78ecSespie       _bfd_vms_output_short (abfd, 0);
453f7cc78ecSespie       _bfd_vms_output_long (abfd, (unsigned long) (section->index));
454f7cc78ecSespie       _bfd_vms_output_long (abfd,
455f7cc78ecSespie 			     (unsigned long) bfd_get_start_address (abfd));
456f7cc78ecSespie       _bfd_vms_output_long (abfd, 0);
457f7cc78ecSespie     }
458f7cc78ecSespie 
459f7cc78ecSespie   _bfd_vms_output_end (abfd);
460f7cc78ecSespie   return 0;
461f7cc78ecSespie }
462