1 /* evax-emh.c -- BFD back-end for ALPHA EVAX (openVMS/AXP) files.
2 Copyright 1996 Free Software Foundation, Inc.
4 EMH record handling functions
6 EEOM record handling functions
8 Written by Klaus Kämpf (kkaempf@progis.de)
9 of proGIS Softwareentwicklung, Aachen, Germany
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. */
34 /*---------------------------------------------------------------------------*/
37 /* Read & process emh record
38 return 0 on success, -1 on error */
41 _bfd_evax_slurp_emh (abfd
)
45 unsigned char *evax_rec
;
47 evax_rec
= PRIV(evax_rec
);
50 evax_debug(2, "EMH\n");
53 switch (bfd_getl16 (evax_rec
+ 4))
60 PRIV(emh_data
).emh_b_strlvl
= evax_rec
[6];
61 PRIV(emh_data
).emh_l_arch1
= bfd_getl32 (evax_rec
+ 8);
62 PRIV(emh_data
).emh_l_arch2
= bfd_getl32 (evax_rec
+ 12);
63 PRIV(emh_data
).emh_l_recsiz
= bfd_getl32 (evax_rec
+ 16);
64 PRIV(emh_data
).emh_t_name
=
65 _bfd_evax_save_counted_string ((char *)evax_rec
+ 20);
66 ptr
= evax_rec
+ 20 + evax_rec
[20] + 1;
67 PRIV(emh_data
).emh_t_version
=
68 _bfd_evax_save_counted_string ((char *)ptr
);
70 PRIV(emh_data
).emh_t_date
=
71 _bfd_evax_save_sized_string ((char *)ptr
, 17);
79 PRIV(emh_data
).emh_c_lnm
=
80 _bfd_evax_save_sized_string ((char *)evax_rec
, PRIV(rec_length
-6));
87 PRIV(emh_data
).emh_c_src
=
88 _bfd_evax_save_sized_string ((char *)evax_rec
, PRIV(rec_length
-6));
95 PRIV(emh_data
).emh_c_ttl
=
96 _bfd_evax_save_sized_string ((char *)evax_rec
, PRIV(rec_length
-6));
118 bfd_set_error (bfd_error_wrong_format
);
127 /* write object header for bfd abfd */
130 _bfd_evax_write_emh (abfd
)
136 evax_debug (2, "evax_write_emh(%p)\n", abfd
);
139 _bfd_evax_output_alignment (abfd
, 2);
143 _bfd_evax_output_begin (abfd
, EOBJ_S_C_EMH
, EMH_S_C_MHD
);
144 _bfd_evax_output_short (abfd
, EOBJ_S_C_STRLVL
);
145 _bfd_evax_output_long (abfd
, 0);
146 _bfd_evax_output_long (abfd
, 0);
147 _bfd_evax_output_long (abfd
, MAX_OUTREC_SIZE
);
148 if (bfd_get_filename (abfd
) != NULL
)
150 name
= strdup (bfd_get_filename (abfd
));
151 _bfd_evax_output_counted (abfd
, _bfd_evax_basename (name
));
154 _bfd_evax_output_counted (abfd
, "NONAME");
155 _bfd_evax_output_counted (abfd
, BFD_VERSION
);
156 _bfd_evax_output_dump (abfd
, (unsigned char *)_bfd_get_vms_time_string (),
158 _bfd_evax_output_fill (abfd
, 0, 17);
159 _bfd_evax_output_flush (abfd
);
163 _bfd_evax_output_begin (abfd
, EOBJ_S_C_EMH
, EMH_S_C_LNM
);
164 _bfd_evax_output_dump (abfd
, (unsigned char *)"GAS proGIS", 10);
165 _bfd_evax_output_flush (abfd
);
169 _bfd_evax_output_begin (abfd
, EOBJ_S_C_EMH
, EMH_S_C_SRC
);
170 if (PRIV(filename
) != 0)
171 _bfd_evax_output_dump (abfd
, (unsigned char *)PRIV(filename
), strlen (PRIV(filename
)));
173 _bfd_evax_output_dump (abfd
, (unsigned char *)"noname", 6);
174 _bfd_evax_output_flush (abfd
);
178 _bfd_evax_output_begin (abfd
, EOBJ_S_C_EMH
, EMH_S_C_TTL
);
179 _bfd_evax_output_dump (abfd
, (unsigned char *)"TTL", 3);
180 _bfd_evax_output_flush (abfd
);
184 _bfd_evax_output_begin (abfd
, EOBJ_S_C_EMH
, EMH_S_C_CPR
);
185 _bfd_evax_output_dump (abfd
,
186 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
188 _bfd_evax_output_flush (abfd
);
193 /*-----------------------------------------------------------------------------*/
195 /* Process EEOM record
196 return 0 on success, -1 on error */
199 _bfd_evax_slurp_eeom (abfd
)
202 unsigned char *evax_rec
;
205 evax_debug(2, "EEOM\n");
208 evax_rec
= PRIV(evax_rec
);
210 PRIV(eeom_data
).eeom_l_total_lps
= bfd_getl32 (evax_rec
+ 4);
211 PRIV(eeom_data
).eeom_b_comcod
= *(evax_rec
+ 8);
212 if (PRIV(eeom_data
).eeom_b_comcod
> 1)
214 (*_bfd_error_handler
) ("Object module NOT error-free !\n");
215 bfd_set_error (bfd_error_bad_value
);
218 PRIV(eeom_data
).eeom_has_transfer
= false;
219 if (PRIV(rec_size
) > 10)
221 PRIV(eeom_data
).eeom_has_transfer
= true;
222 PRIV(eeom_data
).eeom_b_tfrflg
= *(evax_rec
+ 9);
223 PRIV(eeom_data
).eeom_l_psindx
= bfd_getl32 (evax_rec
+ 12);
224 PRIV(eeom_data
).eeom_l_tfradr
= bfd_getl32 (evax_rec
+ 16);
226 abfd
->start_address
= PRIV(eeom_data
).eeom_l_tfradr
;
232 /* Write eom record for bfd abfd */
235 _bfd_evax_write_eeom (abfd
)
239 evax_debug (2, "evax_write_eeom(%p)\n", abfd
);
242 _bfd_evax_output_begin (abfd
,EOBJ_S_C_EEOM
, -1);
243 _bfd_evax_output_long (abfd
, (unsigned long)(PRIV(evax_linkage_index
) >> 1));
244 _bfd_evax_output_byte (abfd
, 0); /* completion code */
245 _bfd_evax_output_byte (abfd
, 0); /* fill byte */
247 if (bfd_get_start_address (abfd
) != (bfd_vma
)-1)
251 section
= bfd_get_section_by_name (abfd
, ".link");
254 bfd_set_error (bfd_error_nonrepresentable_section
);
257 _bfd_evax_output_short (abfd
, 0);
258 _bfd_evax_output_long (abfd
, (unsigned long)(section
->index
));
259 _bfd_evax_output_long (abfd
,
260 (unsigned long) bfd_get_start_address (abfd
));
261 _bfd_evax_output_long (abfd
, 0);
264 _bfd_evax_output_end (abfd
);