| 1 | /* vms.c -- BFD back-end for VAX (openVMS/VAX) and
|
|---|
| 2 | EVAX (openVMS/Alpha) files.
|
|---|
| 3 | Copyright 1996, 1997, 1998, 1999, 2000, 2001
|
|---|
| 4 | Free Software Foundation, Inc.
|
|---|
| 5 |
|
|---|
| 6 | Written by Klaus K"ampf (kkaempf@rmi.de)
|
|---|
| 7 |
|
|---|
| 8 | This program is free software; you can redistribute it and/or modify
|
|---|
| 9 | it under the terms of the GNU General Public License as published by
|
|---|
| 10 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 11 | (at your option) any later version.
|
|---|
| 12 |
|
|---|
| 13 | This program is distributed in the hope that it will be useful,
|
|---|
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 16 | GNU General Public License for more details.
|
|---|
| 17 |
|
|---|
| 18 | You should have received a copy of the GNU General Public License
|
|---|
| 19 | along with this program; if not, write to the Free Software
|
|---|
| 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|---|
| 21 |
|
|---|
| 22 | #include "bfd.h"
|
|---|
| 23 | #include "sysdep.h"
|
|---|
| 24 | #include "bfdlink.h"
|
|---|
| 25 | #include "libbfd.h"
|
|---|
| 26 |
|
|---|
| 27 | #include "vms.h"
|
|---|
| 28 |
|
|---|
| 29 | static boolean vms_initialize PARAMS ((bfd *));
|
|---|
| 30 | static unsigned int priv_section_count;
|
|---|
| 31 | static boolean fill_section_ptr PARAMS ((struct bfd_hash_entry *, PTR));
|
|---|
| 32 | static boolean vms_fixup_sections PARAMS ((bfd *));
|
|---|
| 33 | static boolean copy_symbols PARAMS ((struct bfd_hash_entry *, PTR));
|
|---|
| 34 | static bfd_reloc_status_type reloc_nil
|
|---|
| 35 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
|---|
| 36 | static const struct bfd_target *vms_object_p PARAMS ((bfd *abfd));
|
|---|
| 37 | static const struct bfd_target *vms_archive_p PARAMS ((bfd *abfd));
|
|---|
| 38 | static boolean vms_mkobject PARAMS ((bfd *abfd));
|
|---|
| 39 | static boolean vms_write_object_contents PARAMS ((bfd *abfd));
|
|---|
| 40 | static boolean vms_close_and_cleanup PARAMS ((bfd *abfd));
|
|---|
| 41 | static boolean vms_bfd_free_cached_info PARAMS ((bfd *abfd));
|
|---|
| 42 | static boolean vms_new_section_hook PARAMS ((bfd *abfd, asection *section));
|
|---|
| 43 | static boolean vms_get_section_contents
|
|---|
| 44 | PARAMS ((bfd *abfd, asection *section, PTR x1, file_ptr x2,
|
|---|
| 45 | bfd_size_type x3));
|
|---|
| 46 | static boolean vms_get_section_contents_in_window
|
|---|
| 47 | PARAMS ((bfd *abfd, asection *section, bfd_window *w, file_ptr offset,
|
|---|
| 48 | bfd_size_type count));
|
|---|
| 49 | static boolean vms_bfd_copy_private_bfd_data PARAMS ((bfd *src, bfd *dest));
|
|---|
| 50 | static boolean vms_bfd_copy_private_section_data
|
|---|
| 51 | PARAMS ((bfd *srcbfd, asection *srcsec, bfd *dstbfd, asection *dstsec));
|
|---|
| 52 | static boolean vms_bfd_copy_private_symbol_data
|
|---|
| 53 | PARAMS ((bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym));
|
|---|
| 54 | static boolean vms_bfd_print_private_bfd_data
|
|---|
| 55 | PARAMS ((bfd *abfd, void *file));
|
|---|
| 56 | static char *vms_core_file_failing_command PARAMS ((bfd *abfd));
|
|---|
| 57 | static int vms_core_file_failing_signal PARAMS ((bfd *abfd));
|
|---|
| 58 | static boolean vms_core_file_matches_executable_p
|
|---|
| 59 | PARAMS ((bfd *abfd, bfd *bbfd));
|
|---|
| 60 | static boolean vms_slurp_armap PARAMS ((bfd *abfd));
|
|---|
| 61 | static boolean vms_slurp_extended_name_table PARAMS ((bfd *abfd));
|
|---|
| 62 | static boolean vms_construct_extended_name_table
|
|---|
| 63 | PARAMS ((bfd *abfd, char **tabloc, bfd_size_type *tablen,
|
|---|
| 64 | const char **name));
|
|---|
| 65 | static void vms_truncate_arname
|
|---|
| 66 | PARAMS ((bfd *abfd, CONST char *pathname, char *arhdr));
|
|---|
| 67 | static boolean vms_write_armap
|
|---|
| 68 | PARAMS ((bfd *arch, unsigned int elength, struct orl *map,
|
|---|
| 69 | unsigned int orl_count, int stridx));
|
|---|
| 70 | static PTR vms_read_ar_hdr PARAMS ((bfd *abfd));
|
|---|
| 71 | static bfd *vms_get_elt_at_index PARAMS ((bfd *abfd, symindex index));
|
|---|
| 72 | static bfd *vms_openr_next_archived_file PARAMS ((bfd *arch, bfd *prev));
|
|---|
| 73 | static boolean vms_update_armap_timestamp PARAMS ((bfd *abfd));
|
|---|
| 74 | static int vms_generic_stat_arch_elt PARAMS ((bfd *abfd, struct stat *stat));
|
|---|
| 75 | static long vms_get_symtab_upper_bound PARAMS ((bfd *abfd));
|
|---|
| 76 | static long vms_get_symtab PARAMS ((bfd *abfd, asymbol **symbols));
|
|---|
| 77 | static void vms_print_symbol
|
|---|
| 78 | PARAMS ((bfd *abfd, PTR file, asymbol *symbol, bfd_print_symbol_type how));
|
|---|
| 79 | static void vms_get_symbol_info
|
|---|
| 80 | PARAMS ((bfd *abfd, asymbol *symbol, symbol_info *ret));
|
|---|
| 81 | static boolean vms_bfd_is_local_label_name PARAMS ((bfd *abfd, const char *));
|
|---|
| 82 | static alent *vms_get_lineno PARAMS ((bfd *abfd, asymbol *symbol));
|
|---|
| 83 | static boolean vms_find_nearest_line
|
|---|
| 84 | PARAMS ((bfd *abfd, asection *section, asymbol **symbols, bfd_vma offset,
|
|---|
| 85 | const char **file, const char **func, unsigned int *line));
|
|---|
| 86 | static asymbol *vms_bfd_make_debug_symbol
|
|---|
| 87 | PARAMS ((bfd *abfd, void *ptr, unsigned long size));
|
|---|
| 88 | static long vms_read_minisymbols
|
|---|
| 89 | PARAMS ((bfd *abfd, boolean dynamic, PTR *minisymsp, unsigned int *sizep));
|
|---|
| 90 | static asymbol *vms_minisymbol_to_symbol
|
|---|
| 91 | PARAMS ((bfd *abfd, boolean dynamic, const PTR minisym, asymbol *sym));
|
|---|
| 92 | static long vms_get_reloc_upper_bound PARAMS ((bfd *abfd, asection *sect));
|
|---|
| 93 | static long vms_canonicalize_reloc
|
|---|
| 94 | PARAMS ((bfd *abfd, asection *srcsec, arelent **location,
|
|---|
| 95 | asymbol **symbols));
|
|---|
| 96 | static const struct reloc_howto_struct *vms_bfd_reloc_type_lookup
|
|---|
| 97 | PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
|
|---|
| 98 | static boolean vms_set_arch_mach
|
|---|
| 99 | PARAMS ((bfd *abfd, enum bfd_architecture arch, unsigned long mach));
|
|---|
| 100 | static boolean vms_set_section_contents
|
|---|
| 101 | PARAMS ((bfd *abfd, asection *section, PTR location, file_ptr offset,
|
|---|
| 102 | bfd_size_type count));
|
|---|
| 103 | static int vms_sizeof_headers PARAMS ((bfd *abfd, boolean reloc));
|
|---|
| 104 | static bfd_byte *vms_bfd_get_relocated_section_contents
|
|---|
| 105 | PARAMS ((bfd *abfd, struct bfd_link_info *link_info,
|
|---|
| 106 | struct bfd_link_order *link_order, bfd_byte *data,
|
|---|
| 107 | boolean relocateable, asymbol **symbols));
|
|---|
| 108 | static boolean vms_bfd_relax_section
|
|---|
| 109 | PARAMS ((bfd *abfd, asection *section, struct bfd_link_info *link_info,
|
|---|
| 110 | boolean *again));
|
|---|
| 111 | static boolean vms_bfd_gc_sections
|
|---|
| 112 | PARAMS ((bfd *abfd, struct bfd_link_info *link_info));
|
|---|
| 113 | static struct bfd_link_hash_table *vms_bfd_link_hash_table_create
|
|---|
| 114 | PARAMS ((bfd *abfd));
|
|---|
| 115 | static boolean vms_bfd_link_add_symbols
|
|---|
| 116 | PARAMS ((bfd *abfd, struct bfd_link_info *link_info));
|
|---|
| 117 | static boolean vms_bfd_final_link
|
|---|
| 118 | PARAMS ((bfd *abfd, struct bfd_link_info *link_info));
|
|---|
| 119 | static boolean vms_bfd_link_split_section
|
|---|
| 120 | PARAMS ((bfd *abfd, asection *section));
|
|---|
| 121 | static long vms_get_dynamic_symtab_upper_bound PARAMS ((bfd *abfd));
|
|---|
| 122 | static long vms_canonicalize_dynamic_symtab
|
|---|
| 123 | PARAMS ((bfd *abfd, asymbol **symbols));
|
|---|
| 124 | static long vms_get_dynamic_reloc_upper_bound PARAMS ((bfd *abfd));
|
|---|
| 125 | static long vms_canonicalize_dynamic_reloc
|
|---|
| 126 | PARAMS ((bfd *abfd, arelent **arel, asymbol **symbols));
|
|---|
| 127 | static boolean vms_bfd_merge_private_bfd_data PARAMS ((bfd *ibfd, bfd *obfd));
|
|---|
| 128 | static boolean vms_bfd_set_private_flags PARAMS ((bfd *abfd, flagword flags));
|
|---|
| 129 |
|
|---|
| 130 | #define vms_make_empty_symbol _bfd_vms_make_empty_symbol
|
|---|
| 131 | |
|---|
| 132 |
|
|---|
| 133 | /*===========================================================================*/
|
|---|
| 134 |
|
|---|
| 135 | const bfd_target vms_alpha_vec =
|
|---|
| 136 | {
|
|---|
| 137 | "vms-alpha", /* name */
|
|---|
| 138 | bfd_target_evax_flavour,
|
|---|
| 139 | BFD_ENDIAN_LITTLE, /* data byte order is little */
|
|---|
| 140 | BFD_ENDIAN_LITTLE, /* header byte order is little */
|
|---|
| 141 |
|
|---|
| 142 | (HAS_RELOC | HAS_SYMS
|
|---|
| 143 | | WP_TEXT | D_PAGED), /* object flags */
|
|---|
| 144 | (SEC_ALLOC | SEC_LOAD | SEC_RELOC
|
|---|
| 145 | | SEC_READONLY | SEC_CODE | SEC_DATA
|
|---|
| 146 | | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* sect flags */
|
|---|
| 147 | 0, /* symbol_leading_char */
|
|---|
| 148 | ' ', /* ar_pad_char */
|
|---|
| 149 | 15, /* ar_max_namelen */
|
|---|
| 150 | bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
|---|
| 151 | bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
|---|
| 152 | bfd_getl16, bfd_getl_signed_16, bfd_putl16,
|
|---|
| 153 | bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
|---|
| 154 | bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
|---|
| 155 | bfd_getl16, bfd_getl_signed_16, bfd_putl16,
|
|---|
| 156 |
|
|---|
| 157 | {_bfd_dummy_target, vms_object_p, /* bfd_check_format */
|
|---|
| 158 | vms_archive_p, _bfd_dummy_target},
|
|---|
| 159 | {bfd_false, vms_mkobject, /* bfd_set_format */
|
|---|
| 160 | _bfd_generic_mkarchive, bfd_false},
|
|---|
| 161 | {bfd_false, vms_write_object_contents, /* bfd_write_contents */
|
|---|
| 162 | _bfd_write_archive_contents, bfd_false},
|
|---|
| 163 |
|
|---|
| 164 | BFD_JUMP_TABLE_GENERIC (vms),
|
|---|
| 165 | BFD_JUMP_TABLE_COPY (vms),
|
|---|
| 166 | BFD_JUMP_TABLE_CORE (vms),
|
|---|
| 167 | BFD_JUMP_TABLE_ARCHIVE (vms),
|
|---|
| 168 | BFD_JUMP_TABLE_SYMBOLS (vms),
|
|---|
| 169 | BFD_JUMP_TABLE_RELOCS (vms),
|
|---|
| 170 | BFD_JUMP_TABLE_WRITE (vms),
|
|---|
| 171 | BFD_JUMP_TABLE_LINK (vms),
|
|---|
| 172 | BFD_JUMP_TABLE_DYNAMIC (vms),
|
|---|
| 173 |
|
|---|
| 174 | NULL,
|
|---|
| 175 |
|
|---|
| 176 | (PTR) 0
|
|---|
| 177 | };
|
|---|
| 178 |
|
|---|
| 179 | const bfd_target vms_vax_vec =
|
|---|
| 180 | {
|
|---|
| 181 | "vms-vax", /* name */
|
|---|
| 182 | bfd_target_ovax_flavour,
|
|---|
| 183 | BFD_ENDIAN_LITTLE, /* data byte order is little */
|
|---|
| 184 | BFD_ENDIAN_LITTLE, /* header byte order is little */
|
|---|
| 185 |
|
|---|
| 186 | (HAS_RELOC | HAS_SYMS /* object flags */
|
|---|
| 187 | | WP_TEXT | D_PAGED
|
|---|
| 188 | | HAS_LINENO | HAS_DEBUG | HAS_LOCALS),
|
|---|
| 189 |
|
|---|
| 190 | (SEC_ALLOC | SEC_LOAD | SEC_RELOC
|
|---|
| 191 | | SEC_READONLY | SEC_CODE | SEC_DATA
|
|---|
| 192 | | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* sect flags */
|
|---|
| 193 | 0, /* symbol_leading_char */
|
|---|
| 194 | ' ', /* ar_pad_char */
|
|---|
| 195 | 15, /* ar_max_namelen */
|
|---|
| 196 | bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
|---|
| 197 | bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
|---|
| 198 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
|---|
| 199 | bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
|---|
| 200 | bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
|---|
| 201 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
|---|
| 202 |
|
|---|
| 203 | {_bfd_dummy_target, vms_object_p, /* bfd_check_format */
|
|---|
| 204 | vms_archive_p, _bfd_dummy_target},
|
|---|
| 205 | {bfd_false, vms_mkobject, /* bfd_set_format */
|
|---|
| 206 | _bfd_generic_mkarchive, bfd_false},
|
|---|
| 207 | {bfd_false, vms_write_object_contents, /* bfd_write_contents */
|
|---|
| 208 | _bfd_write_archive_contents, bfd_false},
|
|---|
| 209 |
|
|---|
| 210 | BFD_JUMP_TABLE_GENERIC (vms),
|
|---|
| 211 | BFD_JUMP_TABLE_COPY (vms),
|
|---|
| 212 | BFD_JUMP_TABLE_CORE (vms),
|
|---|
| 213 | BFD_JUMP_TABLE_ARCHIVE (vms),
|
|---|
| 214 | BFD_JUMP_TABLE_SYMBOLS (vms),
|
|---|
| 215 | BFD_JUMP_TABLE_RELOCS (vms),
|
|---|
| 216 | BFD_JUMP_TABLE_WRITE (vms),
|
|---|
| 217 | BFD_JUMP_TABLE_LINK (vms),
|
|---|
| 218 | BFD_JUMP_TABLE_DYNAMIC (vms),
|
|---|
| 219 |
|
|---|
| 220 | NULL,
|
|---|
| 221 |
|
|---|
| 222 | (PTR) 0
|
|---|
| 223 | };
|
|---|
| 224 | |
|---|
| 225 |
|
|---|
| 226 | /*===========================================================================*/
|
|---|
| 227 |
|
|---|
| 228 | /* Initialize private data */
|
|---|
| 229 |
|
|---|
| 230 | static boolean
|
|---|
| 231 | vms_initialize (abfd)
|
|---|
| 232 | bfd *abfd;
|
|---|
| 233 | {
|
|---|
| 234 | int i;
|
|---|
| 235 |
|
|---|
| 236 | if (abfd->tdata.any != 0)
|
|---|
| 237 | return true;
|
|---|
| 238 |
|
|---|
| 239 | bfd_set_start_address (abfd, (bfd_vma)-1);
|
|---|
| 240 |
|
|---|
| 241 | abfd->tdata.any = ((struct vms_private_data_struct*)
|
|---|
| 242 | bfd_malloc (sizeof (struct vms_private_data_struct)));
|
|---|
| 243 | if (abfd->tdata.any == 0)
|
|---|
| 244 | return false;
|
|---|
| 245 |
|
|---|
| 246 | #ifdef __ALPHA
|
|---|
| 247 | PRIV (is_vax) = 0;
|
|---|
| 248 | #else
|
|---|
| 249 | PRIV (is_vax) = 1;
|
|---|
| 250 | #endif
|
|---|
| 251 | PRIV (vms_buf) = 0;
|
|---|
| 252 | PRIV (buf_size) = 0;
|
|---|
| 253 | PRIV (rec_length) = 0;
|
|---|
| 254 | PRIV (file_format) = FF_UNKNOWN;
|
|---|
| 255 | PRIV (fixup_done) = false;
|
|---|
| 256 | PRIV (sections) = NULL;
|
|---|
| 257 |
|
|---|
| 258 | PRIV (stack) = ((struct stack_struct *)
|
|---|
| 259 | bfd_malloc (sizeof (struct stack_struct) * STACKSIZE));
|
|---|
| 260 | if (PRIV (stack) == 0)
|
|---|
| 261 | {
|
|---|
| 262 | vms_init_no_mem1:
|
|---|
| 263 | free (abfd->tdata.any);
|
|---|
| 264 | abfd->tdata.any = 0;
|
|---|
| 265 | return false;
|
|---|
| 266 | }
|
|---|
| 267 | PRIV (stackptr) = 0;
|
|---|
| 268 |
|
|---|
| 269 | PRIV (vms_symbol_table) = ((struct bfd_hash_table *)
|
|---|
| 270 | bfd_malloc (sizeof (struct bfd_hash_table)));
|
|---|
| 271 | if (PRIV (vms_symbol_table) == 0)
|
|---|
| 272 | {
|
|---|
| 273 | vms_init_no_mem2:
|
|---|
| 274 | free (PRIV (stack));
|
|---|
| 275 | PRIV (stack) = 0;
|
|---|
| 276 | goto vms_init_no_mem1;
|
|---|
| 277 | }
|
|---|
| 278 |
|
|---|
| 279 | if (!bfd_hash_table_init (PRIV (vms_symbol_table), _bfd_vms_hash_newfunc))
|
|---|
| 280 | return false;
|
|---|
| 281 |
|
|---|
| 282 | PRIV (location_stack) = ((struct location_struct *)
|
|---|
| 283 | bfd_malloc (sizeof (struct location_struct)
|
|---|
| 284 | * LOCATION_SAVE_SIZE));
|
|---|
| 285 | if (PRIV (location_stack) == 0)
|
|---|
| 286 | {
|
|---|
| 287 | vms_init_no_mem3:
|
|---|
| 288 | free (PRIV (vms_symbol_table));
|
|---|
| 289 | PRIV (vms_symbol_table) = 0;
|
|---|
| 290 | goto vms_init_no_mem2;
|
|---|
| 291 | }
|
|---|
| 292 |
|
|---|
| 293 | for (i = 0; i < VMS_SECTION_COUNT; i++)
|
|---|
| 294 | PRIV (vms_section_table)[i] = NULL;
|
|---|
| 295 |
|
|---|
| 296 | PRIV (output_buf) = (unsigned char *) malloc (MAX_OUTREC_SIZE);
|
|---|
| 297 | if (PRIV (output_buf) == 0)
|
|---|
| 298 | {
|
|---|
| 299 | free (PRIV (location_stack));
|
|---|
| 300 | PRIV (location_stack) = 0;
|
|---|
| 301 | goto vms_init_no_mem3;
|
|---|
| 302 | }
|
|---|
| 303 | PRIV (push_level) = 0;
|
|---|
| 304 | PRIV (pushed_size) = 0;
|
|---|
| 305 | PRIV (length_pos) = 2;
|
|---|
| 306 | PRIV (output_size) = 0;
|
|---|
| 307 | PRIV (output_alignment) = 1;
|
|---|
| 308 |
|
|---|
| 309 | return true;
|
|---|
| 310 | }
|
|---|
| 311 |
|
|---|
| 312 | /* Fill symbol->section with section ptr
|
|---|
| 313 | symbol->section is filled with the section index for defined symbols
|
|---|
| 314 | during reading the GSD/EGSD section. But we need the pointer to the
|
|---|
| 315 | bfd section later.
|
|---|
| 316 |
|
|---|
| 317 | It has the correct value for referenced (undefined section) symbols
|
|---|
| 318 |
|
|---|
| 319 | called from bfd_hash_traverse in vms_fixup_sections */
|
|---|
| 320 |
|
|---|
| 321 | static boolean
|
|---|
| 322 | fill_section_ptr (entry, sections)
|
|---|
| 323 | struct bfd_hash_entry *entry;
|
|---|
| 324 | PTR sections;
|
|---|
| 325 | {
|
|---|
| 326 | asection *sec;
|
|---|
| 327 | asymbol *sym;
|
|---|
| 328 |
|
|---|
| 329 | sym = ((vms_symbol_entry *)entry)->symbol;
|
|---|
| 330 | sec = sym->section;
|
|---|
| 331 |
|
|---|
| 332 | #if VMS_DEBUG
|
|---|
| 333 | vms_debug (6, "fill_section_ptr: sym %p, sec %p\n", sym, sec);
|
|---|
| 334 | #endif
|
|---|
| 335 |
|
|---|
| 336 | /* fill forward references (these contain section number, not section ptr). */
|
|---|
| 337 |
|
|---|
| 338 | if ((unsigned int) sec < priv_section_count)
|
|---|
| 339 | {
|
|---|
| 340 | sec = ((vms_symbol_entry *)entry)->symbol->section =
|
|---|
| 341 | ((asection **)sections)[(int)sec];
|
|---|
| 342 | }
|
|---|
| 343 |
|
|---|
| 344 | if (strcmp (sym->name, sec->name) == 0)
|
|---|
| 345 | sym->flags |= BSF_SECTION_SYM;
|
|---|
| 346 |
|
|---|
| 347 | return true;
|
|---|
| 348 | }
|
|---|
| 349 |
|
|---|
| 350 | /* Fixup sections
|
|---|
| 351 | set up all pointers and arrays, counters and sizes are fixed now
|
|---|
| 352 |
|
|---|
| 353 | we build a private sections vector for easy access since sections
|
|---|
| 354 | are always referenced by an index number.
|
|---|
| 355 |
|
|---|
| 356 | alloc PRIV(sections) according to abfd->section_count
|
|---|
| 357 | copy abfd->sections to PRIV(sections) */
|
|---|
| 358 |
|
|---|
| 359 | static boolean
|
|---|
| 360 | vms_fixup_sections (abfd)
|
|---|
| 361 | bfd *abfd;
|
|---|
| 362 | {
|
|---|
| 363 | if (PRIV (fixup_done))
|
|---|
| 364 | return true;
|
|---|
| 365 |
|
|---|
| 366 | /*
|
|---|
| 367 | * traverse symbol table and fill in all section pointers
|
|---|
| 368 | */
|
|---|
| 369 |
|
|---|
| 370 | /* can't provide section count as argument to fill_section_ptr(). */
|
|---|
| 371 | priv_section_count = PRIV (section_count);
|
|---|
| 372 | bfd_hash_traverse (PRIV (vms_symbol_table), fill_section_ptr,
|
|---|
| 373 | (PTR) (PRIV (sections)));
|
|---|
| 374 |
|
|---|
| 375 | PRIV (fixup_done) = true;
|
|---|
| 376 |
|
|---|
| 377 | return true;
|
|---|
| 378 | }
|
|---|
| 379 |
|
|---|
| 380 | /*===========================================================================*/
|
|---|
| 381 |
|
|---|
| 382 | /* Check the format for a file being read.
|
|---|
| 383 | Return a (bfd_target *) if it's an object file or zero if not. */
|
|---|
| 384 |
|
|---|
| 385 | static const struct bfd_target *
|
|---|
| 386 | vms_object_p (abfd)
|
|---|
| 387 | bfd *abfd;
|
|---|
| 388 | {
|
|---|
| 389 | int err = 0;
|
|---|
| 390 | int prev_type;
|
|---|
| 391 | const struct bfd_target *target_vector = 0;
|
|---|
| 392 | const bfd_arch_info_type *arch = 0;
|
|---|
| 393 |
|
|---|
| 394 | #if VMS_DEBUG
|
|---|
| 395 | vms_debug (1, "vms_object_p(%p)\n", abfd);
|
|---|
| 396 | #endif
|
|---|
| 397 |
|
|---|
| 398 | if (!vms_initialize (abfd))
|
|---|
| 399 | {
|
|---|
| 400 | fprintf (stderr, "vms_initialize () failed !!\n");
|
|---|
| 401 | return 0;
|
|---|
| 402 | }
|
|---|
| 403 |
|
|---|
| 404 | if (bfd_seek (abfd, 0L, SEEK_SET))
|
|---|
| 405 | {
|
|---|
| 406 | bfd_set_error (bfd_error_file_truncated);
|
|---|
| 407 | return 0;
|
|---|
| 408 | }
|
|---|
| 409 |
|
|---|
| 410 | prev_type = -1;
|
|---|
| 411 |
|
|---|
| 412 | do
|
|---|
| 413 | {
|
|---|
| 414 | #if VMS_DEBUG
|
|---|
| 415 | vms_debug (7, "reading at %08lx\n", bfd_tell(abfd));
|
|---|
| 416 | #endif
|
|---|
| 417 | if (_bfd_vms_next_record (abfd) < 0)
|
|---|
| 418 | {
|
|---|
| 419 | #if VMS_DEBUG
|
|---|
| 420 | vms_debug (2, "next_record failed\n");
|
|---|
| 421 | #endif
|
|---|
| 422 | bfd_set_error (bfd_error_wrong_format);
|
|---|
| 423 | return 0;
|
|---|
| 424 | }
|
|---|
| 425 |
|
|---|
| 426 | if ((prev_type == EOBJ_S_C_EGSD)
|
|---|
| 427 | && (PRIV (rec_type) != EOBJ_S_C_EGSD))
|
|---|
| 428 | {
|
|---|
| 429 | if (vms_fixup_sections (abfd) == false)
|
|---|
| 430 | {
|
|---|
| 431 | #if VMS_DEBUG
|
|---|
| 432 | vms_debug (2, "vms_fixup_sections failed\n");
|
|---|
| 433 | #endif
|
|---|
| 434 | bfd_set_error (bfd_error_wrong_format);
|
|---|
| 435 | return 0;
|
|---|
| 436 | }
|
|---|
| 437 | }
|
|---|
| 438 |
|
|---|
| 439 | prev_type = PRIV (rec_type);
|
|---|
| 440 |
|
|---|
| 441 | if (target_vector == 0)
|
|---|
| 442 | {
|
|---|
| 443 | if (prev_type <= OBJ_S_C_MAXRECTYP)
|
|---|
| 444 | target_vector = &vms_vax_vec;
|
|---|
| 445 | else
|
|---|
| 446 | target_vector = &vms_alpha_vec;
|
|---|
| 447 | }
|
|---|
| 448 |
|
|---|
| 449 | switch (prev_type)
|
|---|
| 450 | {
|
|---|
| 451 | case OBJ_S_C_HDR:
|
|---|
| 452 | case EOBJ_S_C_EMH:
|
|---|
| 453 | err = _bfd_vms_slurp_hdr (abfd, prev_type);
|
|---|
| 454 | break;
|
|---|
| 455 | case OBJ_S_C_EOM:
|
|---|
| 456 | case OBJ_S_C_EOMW:
|
|---|
| 457 | case EOBJ_S_C_EEOM:
|
|---|
| 458 | err = _bfd_vms_slurp_eom (abfd, prev_type);
|
|---|
| 459 | break;
|
|---|
| 460 | case OBJ_S_C_GSD:
|
|---|
| 461 | case EOBJ_S_C_EGSD:
|
|---|
| 462 | err = _bfd_vms_slurp_gsd (abfd, prev_type);
|
|---|
| 463 | break;
|
|---|
| 464 | case OBJ_S_C_TIR:
|
|---|
| 465 | case EOBJ_S_C_ETIR:
|
|---|
| 466 | err = _bfd_vms_slurp_tir (abfd, prev_type);
|
|---|
| 467 | break;
|
|---|
| 468 | case OBJ_S_C_DBG:
|
|---|
| 469 | case EOBJ_S_C_EDBG:
|
|---|
| 470 | err = _bfd_vms_slurp_dbg (abfd, prev_type);
|
|---|
| 471 | break;
|
|---|
| 472 | case OBJ_S_C_TBT:
|
|---|
| 473 | case EOBJ_S_C_ETBT:
|
|---|
| 474 | err = _bfd_vms_slurp_tbt (abfd, prev_type);
|
|---|
| 475 | break;
|
|---|
| 476 | case OBJ_S_C_LNK:
|
|---|
| 477 | err = _bfd_vms_slurp_lnk (abfd, prev_type);
|
|---|
| 478 | break;
|
|---|
| 479 | default:
|
|---|
| 480 | err = -1;
|
|---|
| 481 | }
|
|---|
| 482 | if (err != 0)
|
|---|
| 483 | {
|
|---|
| 484 | #if VMS_DEBUG
|
|---|
| 485 | vms_debug (2, "slurp type %d failed with %d\n", prev_type, err);
|
|---|
| 486 | #endif
|
|---|
| 487 | bfd_set_error (bfd_error_wrong_format);
|
|---|
| 488 | return 0;
|
|---|
| 489 | }
|
|---|
| 490 | }
|
|---|
| 491 | while ((prev_type != EOBJ_S_C_EEOM) && (prev_type != OBJ_S_C_EOM) && (prev_type != OBJ_S_C_EOMW));
|
|---|
| 492 |
|
|---|
| 493 | if (target_vector == &vms_vax_vec)
|
|---|
| 494 | {
|
|---|
| 495 | if (vms_fixup_sections (abfd) == false)
|
|---|
| 496 | {
|
|---|
| 497 | #if VMS_DEBUG
|
|---|
| 498 | vms_debug (2, "vms_fixup_sections failed\n");
|
|---|
| 499 | #endif
|
|---|
| 500 | bfd_set_error (bfd_error_wrong_format);
|
|---|
| 501 | return 0;
|
|---|
| 502 | }
|
|---|
| 503 |
|
|---|
| 504 | /* set arch_info to vax */
|
|---|
| 505 |
|
|---|
| 506 | arch = bfd_scan_arch ("vax");
|
|---|
| 507 | PRIV (is_vax) = 1;
|
|---|
| 508 | #if VMS_DEBUG
|
|---|
| 509 | vms_debug (2, "arch is vax\n");
|
|---|
| 510 | #endif
|
|---|
| 511 | }
|
|---|
| 512 | else if (target_vector == &vms_alpha_vec)
|
|---|
| 513 | {
|
|---|
| 514 | /* set arch_info to alpha */
|
|---|
| 515 |
|
|---|
| 516 | arch = bfd_scan_arch ("alpha");
|
|---|
| 517 | PRIV (is_vax) = 0;
|
|---|
| 518 | #if VMS_DEBUG
|
|---|
| 519 | vms_debug (2, "arch is alpha\n");
|
|---|
| 520 | #endif
|
|---|
| 521 | }
|
|---|
| 522 |
|
|---|
| 523 | if (arch == 0)
|
|---|
| 524 | {
|
|---|
| 525 | #if VMS_DEBUG
|
|---|
| 526 | vms_debug (2, "arch not found\n");
|
|---|
| 527 | #endif
|
|---|
| 528 | bfd_set_error (bfd_error_wrong_format);
|
|---|
| 529 | return 0;
|
|---|
| 530 | }
|
|---|
| 531 | abfd->arch_info = arch;
|
|---|
| 532 |
|
|---|
| 533 | return target_vector;
|
|---|
| 534 | }
|
|---|
| 535 |
|
|---|
| 536 | /* Check the format for a file being read.
|
|---|
| 537 | Return a (bfd_target *) if it's an archive file or zero. */
|
|---|
| 538 |
|
|---|
| 539 | static const struct bfd_target *
|
|---|
| 540 | vms_archive_p (abfd)
|
|---|
| 541 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 542 | {
|
|---|
| 543 | #if VMS_DEBUG
|
|---|
| 544 | vms_debug (1, "vms_archive_p(%p)\n", abfd);
|
|---|
| 545 | #endif
|
|---|
| 546 |
|
|---|
| 547 | return 0;
|
|---|
| 548 | }
|
|---|
| 549 |
|
|---|
| 550 | /* Set the format of a file being written. */
|
|---|
| 551 |
|
|---|
| 552 | static boolean
|
|---|
| 553 | vms_mkobject (abfd)
|
|---|
| 554 | bfd *abfd;
|
|---|
| 555 | {
|
|---|
| 556 | #if VMS_DEBUG
|
|---|
| 557 | vms_debug (1, "vms_mkobject(%p)\n", abfd);
|
|---|
| 558 | #endif
|
|---|
| 559 |
|
|---|
| 560 | if (!vms_initialize (abfd))
|
|---|
| 561 | {
|
|---|
| 562 | fprintf (stderr, "vms_initialize () failed !!\n");
|
|---|
| 563 | return 0;
|
|---|
| 564 | }
|
|---|
| 565 |
|
|---|
| 566 | {
|
|---|
| 567 | #ifdef __VAX
|
|---|
| 568 | const bfd_arch_info_type *arch = bfd_scan_arch ("vax");
|
|---|
| 569 | #else
|
|---|
| 570 | const bfd_arch_info_type *arch = bfd_scan_arch ("alpha");
|
|---|
| 571 | #endif
|
|---|
| 572 | if (arch == 0)
|
|---|
| 573 | {
|
|---|
| 574 | bfd_set_error(bfd_error_wrong_format);
|
|---|
| 575 | return 0;
|
|---|
| 576 | }
|
|---|
| 577 | abfd->arch_info = arch;
|
|---|
| 578 | }
|
|---|
| 579 |
|
|---|
| 580 | return true;
|
|---|
| 581 | }
|
|---|
| 582 |
|
|---|
| 583 | /* Write cached information into a file being written, at bfd_close. */
|
|---|
| 584 |
|
|---|
| 585 | static boolean
|
|---|
| 586 | vms_write_object_contents (abfd)
|
|---|
| 587 | bfd *abfd;
|
|---|
| 588 | {
|
|---|
| 589 | #if VMS_DEBUG
|
|---|
| 590 | vms_debug (1, "vms_write_object_contents(%p)\n", abfd);
|
|---|
| 591 | #endif
|
|---|
| 592 |
|
|---|
| 593 | if (abfd->section_count > 0) /* we have sections */
|
|---|
| 594 | {
|
|---|
| 595 | if (PRIV (is_vax))
|
|---|
| 596 | {
|
|---|
| 597 | if (_bfd_vms_write_hdr (abfd, OBJ_S_C_HDR) != 0)
|
|---|
| 598 | return false;
|
|---|
| 599 | if (_bfd_vms_write_gsd (abfd, OBJ_S_C_GSD) != 0)
|
|---|
| 600 | return false;
|
|---|
| 601 | if (_bfd_vms_write_tir (abfd, OBJ_S_C_TIR) != 0)
|
|---|
| 602 | return false;
|
|---|
| 603 | if (_bfd_vms_write_tbt (abfd, OBJ_S_C_TBT) != 0)
|
|---|
| 604 | return false;
|
|---|
| 605 | if (_bfd_vms_write_dbg (abfd, OBJ_S_C_DBG) != 0)
|
|---|
| 606 | return false;
|
|---|
| 607 | if (abfd->section_count > 255)
|
|---|
| 608 | {
|
|---|
| 609 | if (_bfd_vms_write_eom (abfd, OBJ_S_C_EOMW) != 0)
|
|---|
| 610 | return false;
|
|---|
| 611 | }
|
|---|
| 612 | else
|
|---|
| 613 | {
|
|---|
| 614 | if (_bfd_vms_write_eom (abfd, OBJ_S_C_EOM) != 0)
|
|---|
| 615 | return false;
|
|---|
| 616 | }
|
|---|
| 617 | }
|
|---|
| 618 | else
|
|---|
| 619 | {
|
|---|
| 620 | if (_bfd_vms_write_hdr (abfd, EOBJ_S_C_EMH) != 0)
|
|---|
| 621 | return false;
|
|---|
| 622 | if (_bfd_vms_write_gsd (abfd, EOBJ_S_C_EGSD) != 0)
|
|---|
| 623 | return false;
|
|---|
| 624 | if (_bfd_vms_write_tir (abfd, EOBJ_S_C_ETIR) != 0)
|
|---|
| 625 | return false;
|
|---|
| 626 | if (_bfd_vms_write_tbt (abfd, EOBJ_S_C_ETBT) != 0)
|
|---|
| 627 | return false;
|
|---|
| 628 | if (_bfd_vms_write_dbg (abfd, EOBJ_S_C_EDBG) != 0)
|
|---|
| 629 | return false;
|
|---|
| 630 | if (_bfd_vms_write_eom (abfd, EOBJ_S_C_EEOM) != 0)
|
|---|
| 631 | return false;
|
|---|
| 632 | }
|
|---|
| 633 | }
|
|---|
| 634 | return true;
|
|---|
| 635 | }
|
|---|
| 636 |
|
|---|
| 637 | /*-- 4.1, generic -----------------------------------------------------------*/
|
|---|
| 638 |
|
|---|
| 639 | /* Called when the BFD is being closed to do any necessary cleanup. */
|
|---|
| 640 |
|
|---|
| 641 | static boolean
|
|---|
| 642 | vms_close_and_cleanup (abfd)
|
|---|
| 643 | bfd *abfd;
|
|---|
| 644 | {
|
|---|
| 645 | asection *sec;
|
|---|
| 646 | vms_section *es, *es1;
|
|---|
| 647 | int i;
|
|---|
| 648 |
|
|---|
| 649 | #if VMS_DEBUG
|
|---|
| 650 | vms_debug (1, "vms_close_and_cleanup(%p)\n", abfd);
|
|---|
| 651 | #endif
|
|---|
| 652 | if (abfd == 0)
|
|---|
| 653 | return true;
|
|---|
| 654 |
|
|---|
| 655 | if (PRIV (vms_buf) != NULL)
|
|---|
| 656 | {
|
|---|
| 657 | free (PRIV (vms_buf));
|
|---|
| 658 | PRIV (vms_buf) = NULL;
|
|---|
| 659 | }
|
|---|
| 660 | PRIV (buf_size) = 0;
|
|---|
| 661 |
|
|---|
| 662 | if (PRIV (output_buf) != 0)
|
|---|
| 663 | {
|
|---|
| 664 | free (PRIV (output_buf));
|
|---|
| 665 | PRIV (output_buf) = 0;
|
|---|
| 666 | }
|
|---|
| 667 |
|
|---|
| 668 | sec = abfd->sections;
|
|---|
| 669 | while (sec != NULL)
|
|---|
| 670 | {
|
|---|
| 671 | if (sec->contents)
|
|---|
| 672 | free (sec->contents);
|
|---|
| 673 | sec = sec->next;
|
|---|
| 674 | }
|
|---|
| 675 |
|
|---|
| 676 | if (PRIV (sections) != NULL)
|
|---|
| 677 | {
|
|---|
| 678 | free (PRIV (sections));
|
|---|
| 679 | PRIV (sections) = NULL;
|
|---|
| 680 | }
|
|---|
| 681 |
|
|---|
| 682 | if (PRIV (vms_symbol_table))
|
|---|
| 683 | {
|
|---|
| 684 | bfd_hash_table_free (PRIV (vms_symbol_table));
|
|---|
| 685 | PRIV (vms_symbol_table) = 0;
|
|---|
| 686 | }
|
|---|
| 687 |
|
|---|
| 688 | if (PRIV (stack))
|
|---|
| 689 | {
|
|---|
| 690 | free (PRIV (stack));
|
|---|
| 691 | PRIV (stack) = 0;
|
|---|
| 692 | }
|
|---|
| 693 |
|
|---|
| 694 | if (PRIV (location_stack))
|
|---|
| 695 | {
|
|---|
| 696 | free (PRIV (location_stack));
|
|---|
| 697 | PRIV (location_stack) = 0;
|
|---|
| 698 | }
|
|---|
| 699 |
|
|---|
| 700 | for (i = 0; i < VMS_SECTION_COUNT; i++)
|
|---|
| 701 | {
|
|---|
| 702 | es = PRIV (vms_section_table)[i];
|
|---|
| 703 | while (es != NULL)
|
|---|
| 704 | {
|
|---|
| 705 | es1 = es->next;
|
|---|
| 706 | free (es);
|
|---|
| 707 | es = es1;
|
|---|
| 708 | }
|
|---|
| 709 | PRIV (vms_section_table)[i] = NULL;
|
|---|
| 710 | }
|
|---|
| 711 |
|
|---|
| 712 | free (abfd->tdata.any);
|
|---|
| 713 | abfd->tdata.any = NULL;
|
|---|
| 714 |
|
|---|
| 715 | return true;
|
|---|
| 716 | }
|
|---|
| 717 |
|
|---|
| 718 | /* Ask the BFD to free all cached information. */
|
|---|
| 719 | static boolean
|
|---|
| 720 | vms_bfd_free_cached_info (abfd)
|
|---|
| 721 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 722 | {
|
|---|
| 723 | #if VMS_DEBUG
|
|---|
| 724 | vms_debug (1, "vms_bfd_free_cached_info(%p)\n", abfd);
|
|---|
| 725 | #endif
|
|---|
| 726 | return true;
|
|---|
| 727 | }
|
|---|
| 728 |
|
|---|
| 729 | /* Called when a new section is created. */
|
|---|
| 730 |
|
|---|
| 731 | static boolean
|
|---|
| 732 | vms_new_section_hook (abfd, section)
|
|---|
| 733 | bfd *abfd;
|
|---|
| 734 | asection *section;
|
|---|
| 735 | {
|
|---|
| 736 | #if VMS_DEBUG
|
|---|
| 737 | vms_debug (1, "vms_new_section_hook (%p, [%d]%s), count %d\n", abfd, section->index, section->name, abfd->section_count);
|
|---|
| 738 | #endif
|
|---|
| 739 | bfd_set_section_alignment(abfd, section, 4);
|
|---|
| 740 |
|
|---|
| 741 | if (abfd->section_count > PRIV (section_count))
|
|---|
| 742 | {
|
|---|
| 743 | PRIV (sections) = ((asection **)
|
|---|
| 744 | bfd_realloc (PRIV (sections), abfd->section_count * sizeof (asection *)));
|
|---|
| 745 | if (PRIV (sections) == 0)
|
|---|
| 746 | return false;
|
|---|
| 747 | PRIV (section_count) = abfd->section_count;
|
|---|
| 748 | }
|
|---|
| 749 | #if VMS_DEBUG
|
|---|
| 750 | vms_debug (6, "section_count: %d\n", PRIV (section_count));
|
|---|
| 751 | #endif
|
|---|
| 752 | PRIV (sections)[section->index] = section;
|
|---|
| 753 | #if VMS_DEBUG
|
|---|
| 754 | vms_debug (7, "%d: %s\n", section->index, section->name);
|
|---|
| 755 | #endif
|
|---|
| 756 |
|
|---|
| 757 | return true;
|
|---|
| 758 | }
|
|---|
| 759 |
|
|---|
| 760 | /* Read the contents of a section.
|
|---|
| 761 | buf points to a buffer of buf_size bytes to be filled with
|
|---|
| 762 | section data (starting at offset into section) */
|
|---|
| 763 |
|
|---|
| 764 | static boolean
|
|---|
| 765 | vms_get_section_contents (abfd, section, buf, offset, buf_size)
|
|---|
| 766 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 767 | asection *section ATTRIBUTE_UNUSED;
|
|---|
| 768 | PTR buf ATTRIBUTE_UNUSED;
|
|---|
| 769 | file_ptr offset ATTRIBUTE_UNUSED;
|
|---|
| 770 | bfd_size_type buf_size ATTRIBUTE_UNUSED;
|
|---|
| 771 | {
|
|---|
| 772 | #if VMS_DEBUG
|
|---|
| 773 | vms_debug (1, "vms_get_section_contents(%p, %s, %p, off %ld, size %d)\n",
|
|---|
| 774 | abfd, section->name, buf, offset, (int)buf_size);
|
|---|
| 775 | #endif
|
|---|
| 776 |
|
|---|
| 777 | /* shouldn't be called, since all sections are IN_MEMORY */
|
|---|
| 778 |
|
|---|
| 779 | return false;
|
|---|
| 780 | }
|
|---|
| 781 |
|
|---|
| 782 | /* Read the contents of a section.
|
|---|
| 783 | buf points to a buffer of buf_size bytes to be filled with
|
|---|
| 784 | section data (starting at offset into section) */
|
|---|
| 785 |
|
|---|
| 786 | static boolean
|
|---|
| 787 | vms_get_section_contents_in_window (abfd, section, w, offset, count)
|
|---|
| 788 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 789 | asection *section ATTRIBUTE_UNUSED;
|
|---|
| 790 | bfd_window *w ATTRIBUTE_UNUSED;
|
|---|
| 791 | file_ptr offset ATTRIBUTE_UNUSED;
|
|---|
| 792 | bfd_size_type count ATTRIBUTE_UNUSED;
|
|---|
| 793 | {
|
|---|
| 794 | #if VMS_DEBUG
|
|---|
| 795 | vms_debug (1, "vms_get_section_contents_in_window(%p, %s, %p, off %ld, count %d)\n",
|
|---|
| 796 | abfd, section->name, w, offset, (int)count);
|
|---|
| 797 | #endif
|
|---|
| 798 |
|
|---|
| 799 | /* shouldn't be called, since all sections are IN_MEMORY */
|
|---|
| 800 |
|
|---|
| 801 | return false;
|
|---|
| 802 | }
|
|---|
| 803 |
|
|---|
| 804 | /*-- Part 4.2, copy private data --------------------------------------------*/
|
|---|
| 805 |
|
|---|
| 806 | /* Called to copy BFD general private data from one object file
|
|---|
| 807 | to another. */
|
|---|
| 808 |
|
|---|
| 809 | static boolean
|
|---|
| 810 | vms_bfd_copy_private_bfd_data (src, dest)
|
|---|
| 811 | bfd *src ATTRIBUTE_UNUSED;
|
|---|
| 812 | bfd *dest ATTRIBUTE_UNUSED;
|
|---|
| 813 | {
|
|---|
| 814 | #if VMS_DEBUG
|
|---|
| 815 | vms_debug (1, "vms_bfd_copy_private_bfd_data(%p, %p)\n", src, dest);
|
|---|
| 816 | #endif
|
|---|
| 817 | return true;
|
|---|
| 818 | }
|
|---|
| 819 |
|
|---|
| 820 | /* Merge private BFD information from the BFD @var{ibfd} to the
|
|---|
| 821 | the output file BFD @var{obfd} when linking. Return <<true>>
|
|---|
| 822 | on success, <<false>> on error. Possible error returns are:
|
|---|
| 823 |
|
|---|
| 824 | o <<bfd_error_no_memory>> -
|
|---|
| 825 | Not enough memory exists to create private data for @var{obfd}. */
|
|---|
| 826 |
|
|---|
| 827 | static boolean
|
|---|
| 828 | vms_bfd_merge_private_bfd_data (ibfd, obfd)
|
|---|
| 829 | bfd *ibfd ATTRIBUTE_UNUSED;
|
|---|
| 830 | bfd *obfd ATTRIBUTE_UNUSED;
|
|---|
| 831 | {
|
|---|
| 832 | #if VMS_DEBUG
|
|---|
| 833 | vms_debug (1,"vms_bfd_merge_private_bfd_data(%p, %p)\n", ibfd, obfd);
|
|---|
| 834 | #endif
|
|---|
| 835 | return true;
|
|---|
| 836 | }
|
|---|
| 837 |
|
|---|
| 838 | /* Set private BFD flag information in the BFD @var{abfd}.
|
|---|
| 839 | Return <<true>> on success, <<false>> on error. Possible error
|
|---|
| 840 | returns are:
|
|---|
| 841 |
|
|---|
| 842 | o <<bfd_error_no_memory>> -
|
|---|
| 843 | Not enough memory exists to create private data for @var{obfd}. */
|
|---|
| 844 |
|
|---|
| 845 | static boolean
|
|---|
| 846 | vms_bfd_set_private_flags (abfd, flags)
|
|---|
| 847 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 848 | flagword flags ATTRIBUTE_UNUSED;
|
|---|
| 849 | {
|
|---|
| 850 | #if VMS_DEBUG
|
|---|
| 851 | vms_debug (1,"vms_bfd_set_private_flags(%p, %lx)\n", abfd, (long)flags);
|
|---|
| 852 | #endif
|
|---|
| 853 | return true;
|
|---|
| 854 | }
|
|---|
| 855 |
|
|---|
| 856 | /* Called to copy BFD private section data from one object file
|
|---|
| 857 | to another. */
|
|---|
| 858 |
|
|---|
| 859 | static boolean
|
|---|
| 860 | vms_bfd_copy_private_section_data (srcbfd, srcsec, dstbfd, dstsec)
|
|---|
| 861 | bfd *srcbfd ATTRIBUTE_UNUSED;
|
|---|
| 862 | asection *srcsec ATTRIBUTE_UNUSED;
|
|---|
| 863 | bfd *dstbfd ATTRIBUTE_UNUSED;
|
|---|
| 864 | asection *dstsec ATTRIBUTE_UNUSED;
|
|---|
| 865 | {
|
|---|
| 866 | #if VMS_DEBUG
|
|---|
| 867 | vms_debug (1, "vms_bfd_copy_private_section_data(%p, %s, %p, %s)\n",
|
|---|
| 868 | srcbfd, srcsec->name, dstbfd, dstsec->name);
|
|---|
| 869 | #endif
|
|---|
| 870 | return true;
|
|---|
| 871 | }
|
|---|
| 872 |
|
|---|
| 873 | /* Called to copy BFD private symbol data from one object file
|
|---|
| 874 | to another. */
|
|---|
| 875 |
|
|---|
| 876 | static boolean
|
|---|
| 877 | vms_bfd_copy_private_symbol_data (ibfd, isym, obfd, osym)
|
|---|
| 878 | bfd *ibfd ATTRIBUTE_UNUSED;
|
|---|
| 879 | asymbol *isym ATTRIBUTE_UNUSED;
|
|---|
| 880 | bfd *obfd ATTRIBUTE_UNUSED;
|
|---|
| 881 | asymbol *osym ATTRIBUTE_UNUSED;
|
|---|
| 882 | {
|
|---|
| 883 | #if VMS_DEBUG
|
|---|
| 884 | vms_debug (1, "vms_bfd_copy_private_symbol_data(%p, %s, %p, %s)\n",
|
|---|
| 885 | ibfd, isym->name, obfd, osym->name);
|
|---|
| 886 | #endif
|
|---|
| 887 | return true;
|
|---|
| 888 | }
|
|---|
| 889 |
|
|---|
| 890 | /*-- Part 4.3, core file ----------------------------------------------------*/
|
|---|
| 891 |
|
|---|
| 892 | /* Return a read-only string explaining which program was running
|
|---|
| 893 | when it failed and produced the core file abfd. */
|
|---|
| 894 |
|
|---|
| 895 | static char *
|
|---|
| 896 | vms_core_file_failing_command (abfd)
|
|---|
| 897 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 898 | {
|
|---|
| 899 | #if VMS_DEBUG
|
|---|
| 900 | vms_debug (1, "vms_core_file_failing_command(%p)\n", abfd);
|
|---|
| 901 | #endif
|
|---|
| 902 | return 0;
|
|---|
| 903 | }
|
|---|
| 904 |
|
|---|
| 905 | /* Returns the signal number which caused the core dump which
|
|---|
| 906 | generated the file the BFD abfd is attached to. */
|
|---|
| 907 |
|
|---|
| 908 | static int
|
|---|
| 909 | vms_core_file_failing_signal (abfd)
|
|---|
| 910 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 911 | {
|
|---|
| 912 | #if VMS_DEBUG
|
|---|
| 913 | vms_debug (1, "vms_core_file_failing_signal(%p)\n", abfd);
|
|---|
| 914 | #endif
|
|---|
| 915 | return 0;
|
|---|
| 916 | }
|
|---|
| 917 |
|
|---|
| 918 | /* Return true if the core file attached to core_bfd was generated
|
|---|
| 919 | by a run of the executable file attached to exec_bfd, false otherwise. */
|
|---|
| 920 |
|
|---|
| 921 | static boolean
|
|---|
| 922 | vms_core_file_matches_executable_p (abfd, bbfd)
|
|---|
| 923 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 924 | bfd *bbfd ATTRIBUTE_UNUSED;
|
|---|
| 925 | {
|
|---|
| 926 | #if VMS_DEBUG
|
|---|
| 927 | vms_debug (1, "vms_core_file_matches_executable_p(%p, %p)\n", abfd, bbfd);
|
|---|
| 928 | #endif
|
|---|
| 929 | return false;
|
|---|
| 930 | }
|
|---|
| 931 |
|
|---|
| 932 | /*-- Part 4.4, archive ------------------------------------------------------*/
|
|---|
| 933 |
|
|---|
| 934 | /* ??? do something with an archive map.
|
|---|
| 935 | Return false on error, true otherwise. */
|
|---|
| 936 |
|
|---|
| 937 | static boolean
|
|---|
| 938 | vms_slurp_armap (abfd)
|
|---|
| 939 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 940 | {
|
|---|
| 941 | #if VMS_DEBUG
|
|---|
| 942 | vms_debug (1, "vms_slurp_armap(%p)\n", abfd);
|
|---|
| 943 | #endif
|
|---|
| 944 | return false;
|
|---|
| 945 | }
|
|---|
| 946 |
|
|---|
| 947 | /* ??? do something with an extended name table.
|
|---|
| 948 | Return false on error, true otherwise. */
|
|---|
| 949 |
|
|---|
| 950 | static boolean
|
|---|
| 951 | vms_slurp_extended_name_table (abfd)
|
|---|
| 952 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 953 | {
|
|---|
| 954 | #if VMS_DEBUG
|
|---|
| 955 | vms_debug (1, "vms_slurp_extended_name_table(%p)\n", abfd);
|
|---|
| 956 | #endif
|
|---|
| 957 | return false;
|
|---|
| 958 | }
|
|---|
| 959 |
|
|---|
| 960 | /* ??? do something with an extended name table.
|
|---|
| 961 | Return false on error, true otherwise. */
|
|---|
| 962 |
|
|---|
| 963 | static boolean
|
|---|
| 964 | vms_construct_extended_name_table (abfd, tabloc, tablen, name)
|
|---|
| 965 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 966 | char **tabloc ATTRIBUTE_UNUSED;
|
|---|
| 967 | bfd_size_type *tablen ATTRIBUTE_UNUSED;
|
|---|
| 968 | const char **name ATTRIBUTE_UNUSED;
|
|---|
| 969 | {
|
|---|
| 970 | #if VMS_DEBUG
|
|---|
| 971 | vms_debug (1, "vms_construct_extended_name_table(%p)\n", abfd);
|
|---|
| 972 | #endif
|
|---|
| 973 | return false;
|
|---|
| 974 | }
|
|---|
| 975 |
|
|---|
| 976 | /* Truncate the name of an archive to match system-dependent restrictions */
|
|---|
| 977 |
|
|---|
| 978 | static void
|
|---|
| 979 | vms_truncate_arname (abfd, pathname, arhdr)
|
|---|
| 980 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 981 | CONST char *pathname ATTRIBUTE_UNUSED;
|
|---|
| 982 | char *arhdr ATTRIBUTE_UNUSED;
|
|---|
| 983 | {
|
|---|
| 984 | #if VMS_DEBUG
|
|---|
| 985 | vms_debug (1, "vms_truncate_arname(%p, %s, %s)\n", abfd, pathname, arhdr);
|
|---|
| 986 | #endif
|
|---|
| 987 | return;
|
|---|
| 988 | }
|
|---|
| 989 |
|
|---|
| 990 | /* ??? write archive map */
|
|---|
| 991 |
|
|---|
| 992 | static boolean
|
|---|
| 993 | vms_write_armap (arch, elength, map, orl_count, stridx)
|
|---|
| 994 | bfd *arch ATTRIBUTE_UNUSED;
|
|---|
| 995 | unsigned int elength ATTRIBUTE_UNUSED;
|
|---|
| 996 | struct orl *map ATTRIBUTE_UNUSED;
|
|---|
| 997 | unsigned int orl_count ATTRIBUTE_UNUSED;
|
|---|
| 998 | int stridx ATTRIBUTE_UNUSED;
|
|---|
| 999 | {
|
|---|
| 1000 | #if VMS_DEBUG
|
|---|
| 1001 | vms_debug (1, "vms_write_armap(%p, %d, %p, %d %d)\n",
|
|---|
| 1002 | arch, elength, map, orl_count, stridx);
|
|---|
| 1003 | #endif
|
|---|
| 1004 | return true;
|
|---|
| 1005 | }
|
|---|
| 1006 |
|
|---|
| 1007 | /* Read archive header ??? */
|
|---|
| 1008 |
|
|---|
| 1009 | static PTR
|
|---|
| 1010 | vms_read_ar_hdr (abfd)
|
|---|
| 1011 | bfd * abfd ATTRIBUTE_UNUSED;
|
|---|
| 1012 | {
|
|---|
| 1013 | #if VMS_DEBUG
|
|---|
| 1014 | vms_debug (1, "vms_read_ar_hdr(%p)\n", abfd);
|
|---|
| 1015 | #endif
|
|---|
| 1016 | return (PTR)0;
|
|---|
| 1017 | }
|
|---|
| 1018 |
|
|---|
| 1019 | /* Provided a BFD, @var{archive}, containing an archive and NULL, open
|
|---|
| 1020 | an input BFD on the first contained element and returns that.
|
|---|
| 1021 | Subsequent calls should pass the archive and the previous return value
|
|---|
| 1022 | to return a created BFD to the next contained element.
|
|---|
| 1023 | NULL is returned when there are no more. */
|
|---|
| 1024 |
|
|---|
| 1025 | static bfd *
|
|---|
| 1026 | vms_openr_next_archived_file (arch, prev)
|
|---|
| 1027 | bfd *arch ATTRIBUTE_UNUSED;
|
|---|
| 1028 | bfd *prev ATTRIBUTE_UNUSED;
|
|---|
| 1029 | {
|
|---|
| 1030 | #if VMS_DEBUG
|
|---|
| 1031 | vms_debug (1, "vms_openr_next_archived_file(%p, %p)\n", arch, prev);
|
|---|
| 1032 | #endif
|
|---|
| 1033 | return NULL;
|
|---|
| 1034 | }
|
|---|
| 1035 |
|
|---|
| 1036 | /* Return the BFD which is referenced by the symbol in ABFD indexed by
|
|---|
| 1037 | INDEX. INDEX should have been returned by bfd_get_next_mapent. */
|
|---|
| 1038 |
|
|---|
| 1039 | static bfd *
|
|---|
| 1040 | vms_get_elt_at_index (abfd, index)
|
|---|
| 1041 | bfd *abfd;
|
|---|
| 1042 | symindex index;
|
|---|
| 1043 | {
|
|---|
| 1044 | #if VMS_DEBUG
|
|---|
| 1045 | vms_debug (1, "vms_get_elt_at_index(%p, %p)\n", abfd, index);
|
|---|
| 1046 | #endif
|
|---|
| 1047 | return _bfd_generic_get_elt_at_index(abfd, index);
|
|---|
| 1048 | }
|
|---|
| 1049 |
|
|---|
| 1050 | /* ???
|
|---|
| 1051 | -> bfd_generic_stat_arch_elt */
|
|---|
| 1052 |
|
|---|
| 1053 | static int
|
|---|
| 1054 | vms_generic_stat_arch_elt (abfd, stat)
|
|---|
| 1055 | bfd *abfd;
|
|---|
| 1056 | struct stat *stat;
|
|---|
| 1057 | {
|
|---|
| 1058 | #if VMS_DEBUG
|
|---|
| 1059 | vms_debug (1, "vms_generic_stat_arch_elt(%p, %p)\n", abfd, stat);
|
|---|
| 1060 | #endif
|
|---|
| 1061 | return bfd_generic_stat_arch_elt(abfd, stat);
|
|---|
| 1062 | }
|
|---|
| 1063 |
|
|---|
| 1064 | /* This is a new function in bfd 2.5 */
|
|---|
| 1065 |
|
|---|
| 1066 | static boolean
|
|---|
| 1067 | vms_update_armap_timestamp (abfd)
|
|---|
| 1068 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1069 | {
|
|---|
| 1070 | #if VMS_DEBUG
|
|---|
| 1071 | vms_debug (1, "vms_update_armap_timestamp(%p)\n", abfd);
|
|---|
| 1072 | #endif
|
|---|
| 1073 | return true;
|
|---|
| 1074 | }
|
|---|
| 1075 |
|
|---|
| 1076 | /*-- Part 4.5, symbols --------------------------------------------------------*/
|
|---|
| 1077 |
|
|---|
| 1078 | /* Return the number of bytes required to store a vector of pointers
|
|---|
| 1079 | to asymbols for all the symbols in the BFD abfd, including a
|
|---|
| 1080 | terminal NULL pointer. If there are no symbols in the BFD,
|
|---|
| 1081 | then return 0. If an error occurs, return -1. */
|
|---|
| 1082 |
|
|---|
| 1083 | static long
|
|---|
| 1084 | vms_get_symtab_upper_bound (abfd)
|
|---|
| 1085 | bfd *abfd;
|
|---|
| 1086 | {
|
|---|
| 1087 | #if VMS_DEBUG
|
|---|
| 1088 | vms_debug (1, "vms_get_symtab_upper_bound(%p), %d symbols\n", abfd, PRIV (gsd_sym_count));
|
|---|
| 1089 | #endif
|
|---|
| 1090 | return (PRIV (gsd_sym_count)+1) * sizeof (asymbol *);
|
|---|
| 1091 | }
|
|---|
| 1092 |
|
|---|
| 1093 | /* Copy symbols from hash table to symbol vector
|
|---|
| 1094 |
|
|---|
| 1095 | called from bfd_hash_traverse in vms_get_symtab
|
|---|
| 1096 | init counter to 0 if entry == 0 */
|
|---|
| 1097 |
|
|---|
| 1098 | static boolean
|
|---|
| 1099 | copy_symbols (entry, arg)
|
|---|
| 1100 | struct bfd_hash_entry *entry;
|
|---|
| 1101 | PTR arg;
|
|---|
| 1102 | {
|
|---|
| 1103 | bfd *abfd = (bfd *) arg;
|
|---|
| 1104 |
|
|---|
| 1105 | if (entry == NULL) /* init counter */
|
|---|
| 1106 | PRIV (symnum) = 0;
|
|---|
| 1107 | else /* fill vector, inc counter */
|
|---|
| 1108 | PRIV (symcache)[PRIV (symnum)++] = ((vms_symbol_entry *)entry)->symbol;
|
|---|
| 1109 |
|
|---|
| 1110 | return true;
|
|---|
| 1111 | }
|
|---|
| 1112 |
|
|---|
| 1113 | /* Read the symbols from the BFD abfd, and fills in the vector
|
|---|
| 1114 | location with pointers to the symbols and a trailing NULL.
|
|---|
| 1115 |
|
|---|
| 1116 | return # of symbols read */
|
|---|
| 1117 |
|
|---|
| 1118 | static long
|
|---|
| 1119 | vms_get_symtab (abfd, symbols)
|
|---|
| 1120 | bfd *abfd;
|
|---|
| 1121 | asymbol **symbols;
|
|---|
| 1122 | {
|
|---|
| 1123 | #if VMS_DEBUG
|
|---|
| 1124 | vms_debug (1, "vms_get_symtab(%p, <ret>)\n", abfd);
|
|---|
| 1125 | #endif
|
|---|
| 1126 |
|
|---|
| 1127 | /* init counter */
|
|---|
| 1128 | (void)copy_symbols((struct bfd_hash_entry *)0, abfd);
|
|---|
| 1129 |
|
|---|
| 1130 | /* traverse table and fill symbols vector */
|
|---|
| 1131 |
|
|---|
| 1132 | PRIV (symcache) = symbols;
|
|---|
| 1133 | bfd_hash_traverse(PRIV (vms_symbol_table), copy_symbols, (PTR)abfd);
|
|---|
| 1134 |
|
|---|
| 1135 | symbols[PRIV (gsd_sym_count)] = NULL;
|
|---|
| 1136 |
|
|---|
| 1137 | return PRIV (gsd_sym_count);
|
|---|
| 1138 | }
|
|---|
| 1139 |
|
|---|
| 1140 | /* Create a new asymbol structure for the BFD abfd and return a pointer
|
|---|
| 1141 | to it.
|
|---|
| 1142 | This routine is necessary because each back end has private information
|
|---|
| 1143 | surrounding the asymbol. Building your own asymbol and pointing to it
|
|---|
| 1144 | will not create the private information, and will cause problems later on. */
|
|---|
| 1145 |
|
|---|
| 1146 | asymbol *
|
|---|
| 1147 | _bfd_vms_make_empty_symbol (abfd)
|
|---|
| 1148 | bfd *abfd;
|
|---|
| 1149 | {
|
|---|
| 1150 | asymbol *symbol = (asymbol *)bfd_zalloc(abfd, sizeof (asymbol));
|
|---|
| 1151 |
|
|---|
| 1152 | #if VMS_DEBUG
|
|---|
| 1153 | vms_debug (1, "_bfd_vms_make_empty_symbol(%p)\n", abfd);
|
|---|
| 1154 | #endif
|
|---|
| 1155 |
|
|---|
| 1156 | if (symbol == 0)
|
|---|
| 1157 | {
|
|---|
| 1158 | bfd_set_error (bfd_error_no_memory);
|
|---|
| 1159 | return 0;
|
|---|
| 1160 | }
|
|---|
| 1161 | symbol->the_bfd = abfd;
|
|---|
| 1162 |
|
|---|
| 1163 | return symbol;
|
|---|
| 1164 | }
|
|---|
| 1165 |
|
|---|
| 1166 | /* Print symbol to file according to how. how is one of
|
|---|
| 1167 | bfd_print_symbol_name just print the name
|
|---|
| 1168 | bfd_print_symbol_more print more (???)
|
|---|
| 1169 | bfd_print_symbol_all print all we know, which is not much right now :-) */
|
|---|
| 1170 |
|
|---|
| 1171 | static void
|
|---|
| 1172 | vms_print_symbol (abfd, file, symbol, how)
|
|---|
| 1173 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1174 | PTR file;
|
|---|
| 1175 | asymbol *symbol;
|
|---|
| 1176 | bfd_print_symbol_type how;
|
|---|
| 1177 | {
|
|---|
| 1178 | #if VMS_DEBUG
|
|---|
| 1179 | vms_debug (1, "vms_print_symbol(%p, %p, %p, %d)\n", abfd, file, symbol, how);
|
|---|
| 1180 | #endif
|
|---|
| 1181 |
|
|---|
| 1182 | switch (how)
|
|---|
| 1183 | {
|
|---|
| 1184 | case bfd_print_symbol_name:
|
|---|
| 1185 | case bfd_print_symbol_more:
|
|---|
| 1186 | fprintf ((FILE *)file," %s", symbol->name);
|
|---|
| 1187 | break;
|
|---|
| 1188 |
|
|---|
| 1189 | case bfd_print_symbol_all:
|
|---|
| 1190 | {
|
|---|
| 1191 | CONST char *section_name = symbol->section->name;
|
|---|
| 1192 |
|
|---|
| 1193 | bfd_print_symbol_vandf((PTR)file,symbol);
|
|---|
| 1194 |
|
|---|
| 1195 | fprintf ((FILE *)file," %-8s %s", section_name, symbol->name);
|
|---|
| 1196 | }
|
|---|
| 1197 | break;
|
|---|
| 1198 | }
|
|---|
| 1199 | return;
|
|---|
| 1200 | }
|
|---|
| 1201 |
|
|---|
| 1202 | /* Return information about symbol in ret.
|
|---|
| 1203 |
|
|---|
| 1204 | fill type, value and name
|
|---|
| 1205 | type:
|
|---|
| 1206 | A absolute
|
|---|
| 1207 | B bss segment symbol
|
|---|
| 1208 | C common symbol
|
|---|
| 1209 | D data segment symbol
|
|---|
| 1210 | f filename
|
|---|
| 1211 | t a static function symbol
|
|---|
| 1212 | T text segment symbol
|
|---|
| 1213 | U undefined
|
|---|
| 1214 | - debug */
|
|---|
| 1215 |
|
|---|
| 1216 | static void
|
|---|
| 1217 | vms_get_symbol_info (abfd, symbol, ret)
|
|---|
| 1218 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1219 | asymbol *symbol;
|
|---|
| 1220 | symbol_info *ret;
|
|---|
| 1221 | {
|
|---|
| 1222 | asection *sec;
|
|---|
| 1223 |
|
|---|
| 1224 | #if VMS_DEBUG
|
|---|
| 1225 | vms_debug (1, "vms_get_symbol_info(%p, %p, %p)\n", abfd, symbol, ret);
|
|---|
| 1226 | #endif
|
|---|
| 1227 |
|
|---|
| 1228 | sec = symbol->section;
|
|---|
| 1229 |
|
|---|
| 1230 | if (ret == 0)
|
|---|
| 1231 | return;
|
|---|
| 1232 |
|
|---|
| 1233 | if (bfd_is_com_section (sec))
|
|---|
| 1234 | ret->type = 'C';
|
|---|
| 1235 | else if (bfd_is_abs_section (sec))
|
|---|
| 1236 | ret->type = 'A';
|
|---|
| 1237 | else if (bfd_is_und_section (sec))
|
|---|
| 1238 | ret->type = 'U';
|
|---|
| 1239 | else if (bfd_is_ind_section (sec))
|
|---|
| 1240 | ret->type = 'I';
|
|---|
| 1241 | else if (bfd_get_section_flags (abfd, sec) & SEC_CODE)
|
|---|
| 1242 | ret->type = 'T';
|
|---|
| 1243 | else if (bfd_get_section_flags (abfd, sec) & SEC_DATA)
|
|---|
| 1244 | ret->type = 'D';
|
|---|
| 1245 | else if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
|
|---|
| 1246 | ret->type = 'B';
|
|---|
| 1247 | else
|
|---|
| 1248 | ret->type = '-';
|
|---|
| 1249 |
|
|---|
| 1250 | if (ret->type != 'U')
|
|---|
| 1251 | ret->value = symbol->value + symbol->section->vma;
|
|---|
| 1252 | else
|
|---|
| 1253 | ret->value = 0;
|
|---|
| 1254 | ret->name = symbol->name;
|
|---|
| 1255 |
|
|---|
| 1256 | return;
|
|---|
| 1257 | }
|
|---|
| 1258 |
|
|---|
| 1259 | /* Return true if the given symbol sym in the BFD abfd is
|
|---|
| 1260 | a compiler generated local label, else return false. */
|
|---|
| 1261 |
|
|---|
| 1262 | static boolean
|
|---|
| 1263 | vms_bfd_is_local_label_name (abfd, name)
|
|---|
| 1264 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1265 | const char *name;
|
|---|
| 1266 | {
|
|---|
| 1267 | #if VMS_DEBUG
|
|---|
| 1268 | vms_debug (1, "vms_bfd_is_local_label_name(%p, %s)\n", abfd, name);
|
|---|
| 1269 | #endif
|
|---|
| 1270 | return name[0] == '$';
|
|---|
| 1271 | }
|
|---|
| 1272 |
|
|---|
| 1273 | /* Get source line number for symbol */
|
|---|
| 1274 |
|
|---|
| 1275 | static alent *
|
|---|
| 1276 | vms_get_lineno (abfd, symbol)
|
|---|
| 1277 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1278 | asymbol *symbol ATTRIBUTE_UNUSED;
|
|---|
| 1279 | {
|
|---|
| 1280 | #if VMS_DEBUG
|
|---|
| 1281 | vms_debug (1, "vms_get_lineno(%p, %p)\n", abfd, symbol);
|
|---|
| 1282 | #endif
|
|---|
| 1283 | return 0;
|
|---|
| 1284 | }
|
|---|
| 1285 |
|
|---|
| 1286 | /* Provided a BFD, a section and an offset into the section, calculate and
|
|---|
| 1287 | return the name of the source file and the line nearest to the wanted
|
|---|
| 1288 | location. */
|
|---|
| 1289 |
|
|---|
| 1290 | static boolean
|
|---|
| 1291 | vms_find_nearest_line (abfd, section, symbols, offset, file, func, line)
|
|---|
| 1292 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1293 | asection *section ATTRIBUTE_UNUSED;
|
|---|
| 1294 | asymbol **symbols ATTRIBUTE_UNUSED;
|
|---|
| 1295 | bfd_vma offset ATTRIBUTE_UNUSED;
|
|---|
| 1296 | CONST char **file ATTRIBUTE_UNUSED;
|
|---|
| 1297 | CONST char **func ATTRIBUTE_UNUSED;
|
|---|
| 1298 | unsigned int *line ATTRIBUTE_UNUSED;
|
|---|
| 1299 | {
|
|---|
| 1300 | #if VMS_DEBUG
|
|---|
| 1301 | vms_debug (1, "vms_find_nearest_line(%p, %s, %p, %ld, <ret>, <ret>, <ret>)\n",
|
|---|
| 1302 | abfd, section->name, symbols, (long int)offset);
|
|---|
| 1303 | #endif
|
|---|
| 1304 | return false;
|
|---|
| 1305 | }
|
|---|
| 1306 |
|
|---|
| 1307 | /* Back-door to allow format-aware applications to create debug symbols
|
|---|
| 1308 | while using BFD for everything else. Currently used by the assembler
|
|---|
| 1309 | when creating COFF files. */
|
|---|
| 1310 |
|
|---|
| 1311 | static asymbol *
|
|---|
| 1312 | vms_bfd_make_debug_symbol (abfd, ptr, size)
|
|---|
| 1313 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1314 | void *ptr ATTRIBUTE_UNUSED;
|
|---|
| 1315 | unsigned long size ATTRIBUTE_UNUSED;
|
|---|
| 1316 | {
|
|---|
| 1317 | #if VMS_DEBUG
|
|---|
| 1318 | vms_debug (1, "vms_bfd_make_debug_symbol(%p, %p, %ld)\n", abfd, ptr, size);
|
|---|
| 1319 | #endif
|
|---|
| 1320 | return 0;
|
|---|
| 1321 | }
|
|---|
| 1322 |
|
|---|
| 1323 | /* Read minisymbols. For minisymbols, we use the unmodified a.out
|
|---|
| 1324 | symbols. The minisymbol_to_symbol function translates these into
|
|---|
| 1325 | BFD asymbol structures. */
|
|---|
| 1326 |
|
|---|
| 1327 | static long
|
|---|
| 1328 | vms_read_minisymbols (abfd, dynamic, minisymsp, sizep)
|
|---|
| 1329 | bfd *abfd;
|
|---|
| 1330 | boolean dynamic;
|
|---|
| 1331 | PTR *minisymsp;
|
|---|
| 1332 | unsigned int *sizep;
|
|---|
| 1333 | {
|
|---|
| 1334 | #if VMS_DEBUG
|
|---|
| 1335 | vms_debug (1, "vms_read_minisymbols(%p, %d, %p, %d)\n", abfd, dynamic, minisymsp, *sizep);
|
|---|
| 1336 | #endif
|
|---|
| 1337 | return _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep);
|
|---|
| 1338 | }
|
|---|
| 1339 |
|
|---|
| 1340 | /* Convert a minisymbol to a BFD asymbol. A minisymbol is just an
|
|---|
| 1341 | unmodified a.out symbol. The SYM argument is a structure returned
|
|---|
| 1342 | by bfd_make_empty_symbol, which we fill in here. */
|
|---|
| 1343 |
|
|---|
| 1344 | static asymbol *
|
|---|
| 1345 | vms_minisymbol_to_symbol (abfd, dynamic, minisym, sym)
|
|---|
| 1346 | bfd *abfd;
|
|---|
| 1347 | boolean dynamic;
|
|---|
| 1348 | const PTR minisym;
|
|---|
| 1349 | asymbol *sym;
|
|---|
| 1350 | {
|
|---|
| 1351 | #if VMS_DEBUG
|
|---|
| 1352 | vms_debug (1, "vms_minisymbol_to_symbol(%p, %d, %p, %p)\n", abfd, dynamic, minisym, sym);
|
|---|
| 1353 | #endif
|
|---|
| 1354 | return _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym);
|
|---|
| 1355 | }
|
|---|
| 1356 |
|
|---|
| 1357 | /*-- Part 4.6, relocations --------------------------------------------------*/
|
|---|
| 1358 |
|
|---|
| 1359 | /* Return the number of bytes required to store the relocation information
|
|---|
| 1360 | associated with section sect attached to bfd abfd.
|
|---|
| 1361 | If an error occurs, return -1. */
|
|---|
| 1362 |
|
|---|
| 1363 | static long
|
|---|
| 1364 | vms_get_reloc_upper_bound (abfd, section)
|
|---|
| 1365 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1366 | asection *section ATTRIBUTE_UNUSED;
|
|---|
| 1367 | {
|
|---|
| 1368 | #if VMS_DEBUG
|
|---|
| 1369 | vms_debug (1, "vms_get_reloc_upper_bound(%p, %s)\n", abfd, section->name);
|
|---|
| 1370 | #endif
|
|---|
| 1371 | return -1L;
|
|---|
| 1372 | }
|
|---|
| 1373 |
|
|---|
| 1374 | /* Call the back end associated with the open BFD abfd and translate the
|
|---|
| 1375 | external form of the relocation information attached to sec into the
|
|---|
| 1376 | internal canonical form. Place the table into memory at loc, which has
|
|---|
| 1377 | been preallocated, usually by a call to bfd_get_reloc_upper_bound.
|
|---|
| 1378 | Returns the number of relocs, or -1 on error. */
|
|---|
| 1379 |
|
|---|
| 1380 | static long
|
|---|
| 1381 | vms_canonicalize_reloc (abfd, section, location, symbols)
|
|---|
| 1382 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1383 | asection *section ATTRIBUTE_UNUSED;
|
|---|
| 1384 | arelent **location ATTRIBUTE_UNUSED;
|
|---|
| 1385 | asymbol **symbols ATTRIBUTE_UNUSED;
|
|---|
| 1386 | {
|
|---|
| 1387 | #if VMS_DEBUG
|
|---|
| 1388 | vms_debug (1, "vms_canonicalize_reloc(%p, %s, <ret>, <ret>)\n", abfd, section->name);
|
|---|
| 1389 | #endif
|
|---|
| 1390 | return false;
|
|---|
| 1391 | }
|
|---|
| 1392 |
|
|---|
| 1393 | /*---------------------------------------------------------------------------*/
|
|---|
| 1394 | /* this is just copied from ecoff-alpha, needs to be fixed probably */
|
|---|
| 1395 |
|
|---|
| 1396 | /* How to process the various reloc types. */
|
|---|
| 1397 |
|
|---|
| 1398 | static bfd_reloc_status_type
|
|---|
| 1399 | reloc_nil (abfd, reloc, sym, data, sec, output_bfd, error_message)
|
|---|
| 1400 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1401 | arelent *reloc ATTRIBUTE_UNUSED;
|
|---|
| 1402 | asymbol *sym ATTRIBUTE_UNUSED;
|
|---|
| 1403 | PTR data ATTRIBUTE_UNUSED;
|
|---|
| 1404 | asection *sec ATTRIBUTE_UNUSED;
|
|---|
| 1405 | bfd *output_bfd ATTRIBUTE_UNUSED;
|
|---|
| 1406 | char **error_message ATTRIBUTE_UNUSED;
|
|---|
| 1407 | {
|
|---|
| 1408 | #if VMS_DEBUG
|
|---|
| 1409 | vms_debug (1, "reloc_nil(abfd %p, output_bfd %p)\n", abfd, output_bfd);
|
|---|
| 1410 | vms_debug (2, "In section %s, symbol %s\n",
|
|---|
| 1411 | sec->name, sym->name);
|
|---|
| 1412 | vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
|
|---|
| 1413 | reloc->sym_ptr_ptr[0]->name,
|
|---|
| 1414 | (unsigned long)reloc->address,
|
|---|
| 1415 | (unsigned long)reloc->addend, reloc->howto->name);
|
|---|
| 1416 | vms_debug (2, "data at %p\n", data);
|
|---|
| 1417 | /* _bfd_hexdump (2, data, bfd_get_reloc_size(reloc->howto),0); */
|
|---|
| 1418 | #endif
|
|---|
| 1419 |
|
|---|
| 1420 | return bfd_reloc_ok;
|
|---|
| 1421 | }
|
|---|
| 1422 |
|
|---|
| 1423 | /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
|
|---|
| 1424 | from smaller values. Start with zero, widen, *then* decrement. */
|
|---|
| 1425 | #define MINUS_ONE (((bfd_vma)0) - 1)
|
|---|
| 1426 |
|
|---|
| 1427 | static reloc_howto_type alpha_howto_table[] =
|
|---|
| 1428 | {
|
|---|
| 1429 | HOWTO (ALPHA_R_IGNORE, /* type */
|
|---|
| 1430 | 0, /* rightshift */
|
|---|
| 1431 | 0, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1432 | 8, /* bitsize */
|
|---|
| 1433 | true, /* pc_relative */
|
|---|
| 1434 | 0, /* bitpos */
|
|---|
| 1435 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1436 | reloc_nil, /* special_function */
|
|---|
| 1437 | "IGNORE", /* name */
|
|---|
| 1438 | true, /* partial_inplace */
|
|---|
| 1439 | 0, /* src_mask */
|
|---|
| 1440 | 0, /* dst_mask */
|
|---|
| 1441 | true), /* pcrel_offset */
|
|---|
| 1442 |
|
|---|
| 1443 | /* A 64 bit reference to a symbol. */
|
|---|
| 1444 | HOWTO (ALPHA_R_REFQUAD, /* type */
|
|---|
| 1445 | 0, /* rightshift */
|
|---|
| 1446 | 4, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1447 | 64, /* bitsize */
|
|---|
| 1448 | false, /* pc_relative */
|
|---|
| 1449 | 0, /* bitpos */
|
|---|
| 1450 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 1451 | reloc_nil, /* special_function */
|
|---|
| 1452 | "REFQUAD", /* name */
|
|---|
| 1453 | true, /* partial_inplace */
|
|---|
| 1454 | MINUS_ONE, /* src_mask */
|
|---|
| 1455 | MINUS_ONE, /* dst_mask */
|
|---|
| 1456 | false), /* pcrel_offset */
|
|---|
| 1457 |
|
|---|
| 1458 | /* A 21 bit branch. The native assembler generates these for
|
|---|
| 1459 | branches within the text segment, and also fills in the PC
|
|---|
| 1460 | relative offset in the instruction. */
|
|---|
| 1461 | HOWTO (ALPHA_R_BRADDR, /* type */
|
|---|
| 1462 | 2, /* rightshift */
|
|---|
| 1463 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1464 | 21, /* bitsize */
|
|---|
| 1465 | true, /* pc_relative */
|
|---|
| 1466 | 0, /* bitpos */
|
|---|
| 1467 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 1468 | reloc_nil, /* special_function */
|
|---|
| 1469 | "BRADDR", /* name */
|
|---|
| 1470 | true, /* partial_inplace */
|
|---|
| 1471 | 0x1fffff, /* src_mask */
|
|---|
| 1472 | 0x1fffff, /* dst_mask */
|
|---|
| 1473 | false), /* pcrel_offset */
|
|---|
| 1474 |
|
|---|
| 1475 | /* A hint for a jump to a register. */
|
|---|
| 1476 | HOWTO (ALPHA_R_HINT, /* type */
|
|---|
| 1477 | 2, /* rightshift */
|
|---|
| 1478 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1479 | 14, /* bitsize */
|
|---|
| 1480 | true, /* pc_relative */
|
|---|
| 1481 | 0, /* bitpos */
|
|---|
| 1482 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1483 | reloc_nil, /* special_function */
|
|---|
| 1484 | "HINT", /* name */
|
|---|
| 1485 | true, /* partial_inplace */
|
|---|
| 1486 | 0x3fff, /* src_mask */
|
|---|
| 1487 | 0x3fff, /* dst_mask */
|
|---|
| 1488 | false), /* pcrel_offset */
|
|---|
| 1489 |
|
|---|
| 1490 | /* 16 bit PC relative offset. */
|
|---|
| 1491 | HOWTO (ALPHA_R_SREL16, /* type */
|
|---|
| 1492 | 0, /* rightshift */
|
|---|
| 1493 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1494 | 16, /* bitsize */
|
|---|
| 1495 | true, /* pc_relative */
|
|---|
| 1496 | 0, /* bitpos */
|
|---|
| 1497 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 1498 | reloc_nil, /* special_function */
|
|---|
| 1499 | "SREL16", /* name */
|
|---|
| 1500 | true, /* partial_inplace */
|
|---|
| 1501 | 0xffff, /* src_mask */
|
|---|
| 1502 | 0xffff, /* dst_mask */
|
|---|
| 1503 | false), /* pcrel_offset */
|
|---|
| 1504 |
|
|---|
| 1505 | /* 32 bit PC relative offset. */
|
|---|
| 1506 | HOWTO (ALPHA_R_SREL32, /* type */
|
|---|
| 1507 | 0, /* rightshift */
|
|---|
| 1508 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1509 | 32, /* bitsize */
|
|---|
| 1510 | true, /* pc_relative */
|
|---|
| 1511 | 0, /* bitpos */
|
|---|
| 1512 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 1513 | reloc_nil, /* special_function */
|
|---|
| 1514 | "SREL32", /* name */
|
|---|
| 1515 | true, /* partial_inplace */
|
|---|
| 1516 | 0xffffffff, /* src_mask */
|
|---|
| 1517 | 0xffffffff, /* dst_mask */
|
|---|
| 1518 | false), /* pcrel_offset */
|
|---|
| 1519 |
|
|---|
| 1520 | /* A 64 bit PC relative offset. */
|
|---|
| 1521 | HOWTO (ALPHA_R_SREL64, /* type */
|
|---|
| 1522 | 0, /* rightshift */
|
|---|
| 1523 | 4, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1524 | 64, /* bitsize */
|
|---|
| 1525 | true, /* pc_relative */
|
|---|
| 1526 | 0, /* bitpos */
|
|---|
| 1527 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 1528 | reloc_nil, /* special_function */
|
|---|
| 1529 | "SREL64", /* name */
|
|---|
| 1530 | true, /* partial_inplace */
|
|---|
| 1531 | MINUS_ONE, /* src_mask */
|
|---|
| 1532 | MINUS_ONE, /* dst_mask */
|
|---|
| 1533 | false), /* pcrel_offset */
|
|---|
| 1534 |
|
|---|
| 1535 | /* Push a value on the reloc evaluation stack. */
|
|---|
| 1536 | HOWTO (ALPHA_R_OP_PUSH, /* type */
|
|---|
| 1537 | 0, /* rightshift */
|
|---|
| 1538 | 0, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1539 | 0, /* bitsize */
|
|---|
| 1540 | false, /* pc_relative */
|
|---|
| 1541 | 0, /* bitpos */
|
|---|
| 1542 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1543 | reloc_nil, /* special_function */
|
|---|
| 1544 | "OP_PUSH", /* name */
|
|---|
| 1545 | false, /* partial_inplace */
|
|---|
| 1546 | 0, /* src_mask */
|
|---|
| 1547 | 0, /* dst_mask */
|
|---|
| 1548 | false), /* pcrel_offset */
|
|---|
| 1549 |
|
|---|
| 1550 | /* Store the value from the stack at the given address. Store it in
|
|---|
| 1551 | a bitfield of size r_size starting at bit position r_offset. */
|
|---|
| 1552 | HOWTO (ALPHA_R_OP_STORE, /* type */
|
|---|
| 1553 | 0, /* rightshift */
|
|---|
| 1554 | 4, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1555 | 64, /* bitsize */
|
|---|
| 1556 | false, /* pc_relative */
|
|---|
| 1557 | 0, /* bitpos */
|
|---|
| 1558 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1559 | reloc_nil, /* special_function */
|
|---|
| 1560 | "OP_STORE", /* name */
|
|---|
| 1561 | false, /* partial_inplace */
|
|---|
| 1562 | 0, /* src_mask */
|
|---|
| 1563 | MINUS_ONE, /* dst_mask */
|
|---|
| 1564 | false), /* pcrel_offset */
|
|---|
| 1565 |
|
|---|
| 1566 | /* Subtract the reloc address from the value on the top of the
|
|---|
| 1567 | relocation stack. */
|
|---|
| 1568 | HOWTO (ALPHA_R_OP_PSUB, /* type */
|
|---|
| 1569 | 0, /* rightshift */
|
|---|
| 1570 | 0, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1571 | 0, /* bitsize */
|
|---|
| 1572 | false, /* pc_relative */
|
|---|
| 1573 | 0, /* bitpos */
|
|---|
| 1574 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1575 | reloc_nil, /* special_function */
|
|---|
| 1576 | "OP_PSUB", /* name */
|
|---|
| 1577 | false, /* partial_inplace */
|
|---|
| 1578 | 0, /* src_mask */
|
|---|
| 1579 | 0, /* dst_mask */
|
|---|
| 1580 | false), /* pcrel_offset */
|
|---|
| 1581 |
|
|---|
| 1582 | /* Shift the value on the top of the relocation stack right by the
|
|---|
| 1583 | given value. */
|
|---|
| 1584 | HOWTO (ALPHA_R_OP_PRSHIFT, /* type */
|
|---|
| 1585 | 0, /* rightshift */
|
|---|
| 1586 | 0, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1587 | 0, /* bitsize */
|
|---|
| 1588 | false, /* pc_relative */
|
|---|
| 1589 | 0, /* bitpos */
|
|---|
| 1590 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1591 | reloc_nil, /* special_function */
|
|---|
| 1592 | "OP_PRSHIFT", /* name */
|
|---|
| 1593 | false, /* partial_inplace */
|
|---|
| 1594 | 0, /* src_mask */
|
|---|
| 1595 | 0, /* dst_mask */
|
|---|
| 1596 | false), /* pcrel_offset */
|
|---|
| 1597 |
|
|---|
| 1598 | /* Hack. Linkage is done by linker. */
|
|---|
| 1599 | HOWTO (ALPHA_R_LINKAGE, /* type */
|
|---|
| 1600 | 0, /* rightshift */
|
|---|
| 1601 | 8, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1602 | 256, /* bitsize */
|
|---|
| 1603 | false, /* pc_relative */
|
|---|
| 1604 | 0, /* bitpos */
|
|---|
| 1605 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1606 | reloc_nil, /* special_function */
|
|---|
| 1607 | "LINKAGE", /* name */
|
|---|
| 1608 | false, /* partial_inplace */
|
|---|
| 1609 | 0, /* src_mask */
|
|---|
| 1610 | 0, /* dst_mask */
|
|---|
| 1611 | false), /* pcrel_offset */
|
|---|
| 1612 |
|
|---|
| 1613 | /* A 32 bit reference to a symbol. */
|
|---|
| 1614 | HOWTO (ALPHA_R_REFLONG, /* type */
|
|---|
| 1615 | 0, /* rightshift */
|
|---|
| 1616 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1617 | 32, /* bitsize */
|
|---|
| 1618 | false, /* pc_relative */
|
|---|
| 1619 | 0, /* bitpos */
|
|---|
| 1620 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 1621 | reloc_nil, /* special_function */
|
|---|
| 1622 | "REFLONG", /* name */
|
|---|
| 1623 | true, /* partial_inplace */
|
|---|
| 1624 | 0xffffffff, /* src_mask */
|
|---|
| 1625 | 0xffffffff, /* dst_mask */
|
|---|
| 1626 | false), /* pcrel_offset */
|
|---|
| 1627 |
|
|---|
| 1628 | /* A 64 bit reference to a procedure, written as 32 bit value. */
|
|---|
| 1629 | HOWTO (ALPHA_R_CODEADDR, /* type */
|
|---|
| 1630 | 0, /* rightshift */
|
|---|
| 1631 | 4, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1632 | 64, /* bitsize */
|
|---|
| 1633 | false, /* pc_relative */
|
|---|
| 1634 | 0, /* bitpos */
|
|---|
| 1635 | complain_overflow_signed,/* complain_on_overflow */
|
|---|
| 1636 | reloc_nil, /* special_function */
|
|---|
| 1637 | "CODEADDR", /* name */
|
|---|
| 1638 | false, /* partial_inplace */
|
|---|
| 1639 | 0xffffffff, /* src_mask */
|
|---|
| 1640 | 0xffffffff, /* dst_mask */
|
|---|
| 1641 | false), /* pcrel_offset */
|
|---|
| 1642 |
|
|---|
| 1643 | };
|
|---|
| 1644 |
|
|---|
| 1645 | /* Return a pointer to a howto structure which, when invoked, will perform
|
|---|
| 1646 | the relocation code on data from the architecture noted. */
|
|---|
| 1647 |
|
|---|
| 1648 | static const struct reloc_howto_struct *
|
|---|
| 1649 | vms_bfd_reloc_type_lookup (abfd, code)
|
|---|
| 1650 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1651 | bfd_reloc_code_real_type code;
|
|---|
| 1652 | {
|
|---|
| 1653 | int alpha_type;
|
|---|
| 1654 |
|
|---|
| 1655 | #if VMS_DEBUG
|
|---|
| 1656 | vms_debug (1, "vms_bfd_reloc_type_lookup(%p, %d)\t", abfd, code);
|
|---|
| 1657 | #endif
|
|---|
| 1658 |
|
|---|
| 1659 | switch (code)
|
|---|
| 1660 | {
|
|---|
| 1661 | case BFD_RELOC_16: alpha_type = ALPHA_R_SREL16; break;
|
|---|
| 1662 | case BFD_RELOC_32: alpha_type = ALPHA_R_REFLONG; break;
|
|---|
| 1663 | case BFD_RELOC_64: alpha_type = ALPHA_R_REFQUAD; break;
|
|---|
| 1664 | case BFD_RELOC_CTOR: alpha_type = ALPHA_R_REFQUAD; break;
|
|---|
| 1665 | case BFD_RELOC_23_PCREL_S2: alpha_type = ALPHA_R_BRADDR; break;
|
|---|
| 1666 | case BFD_RELOC_ALPHA_HINT: alpha_type = ALPHA_R_HINT; break;
|
|---|
| 1667 | case BFD_RELOC_16_PCREL: alpha_type = ALPHA_R_SREL16; break;
|
|---|
| 1668 | case BFD_RELOC_32_PCREL: alpha_type = ALPHA_R_SREL32; break;
|
|---|
| 1669 | case BFD_RELOC_64_PCREL: alpha_type = ALPHA_R_SREL64; break;
|
|---|
| 1670 | case BFD_RELOC_ALPHA_LINKAGE: alpha_type = ALPHA_R_LINKAGE; break;
|
|---|
| 1671 | case BFD_RELOC_ALPHA_CODEADDR: alpha_type = ALPHA_R_CODEADDR; break;
|
|---|
| 1672 | default:
|
|---|
| 1673 | (*_bfd_error_handler) ("reloc (%d) is *UNKNOWN*", code);
|
|---|
| 1674 | return (const struct reloc_howto_struct *) NULL;
|
|---|
| 1675 | }
|
|---|
| 1676 | #if VMS_DEBUG
|
|---|
| 1677 | vms_debug (2, "reloc is %s\n", alpha_howto_table[alpha_type].name);
|
|---|
| 1678 | #endif
|
|---|
| 1679 | return &alpha_howto_table[alpha_type];
|
|---|
| 1680 | }
|
|---|
| 1681 |
|
|---|
| 1682 | /*-- Part 4.7, writing an object file ---------------------------------------*/
|
|---|
| 1683 |
|
|---|
| 1684 | /* Set the architecture and machine type in BFD abfd to arch and mach.
|
|---|
| 1685 | Find the correct pointer to a structure and insert it into the arch_info
|
|---|
| 1686 | pointer. */
|
|---|
| 1687 |
|
|---|
| 1688 | static boolean
|
|---|
| 1689 | vms_set_arch_mach (abfd, arch, mach)
|
|---|
| 1690 | bfd *abfd;
|
|---|
| 1691 | enum bfd_architecture arch ATTRIBUTE_UNUSED;
|
|---|
| 1692 | unsigned long mach ATTRIBUTE_UNUSED;
|
|---|
| 1693 | {
|
|---|
| 1694 | #if VMS_DEBUG
|
|---|
| 1695 | vms_debug (1, "vms_set_arch_mach(%p, %d, %ld)\n", abfd, arch, mach);
|
|---|
| 1696 | #endif
|
|---|
| 1697 | abfd->arch_info = bfd_scan_arch("alpha");
|
|---|
| 1698 |
|
|---|
| 1699 | return true;
|
|---|
| 1700 | }
|
|---|
| 1701 |
|
|---|
| 1702 | /* Sets the contents of the section section in BFD abfd to the data starting
|
|---|
| 1703 | in memory at data. The data is written to the output section starting at
|
|---|
| 1704 | offset offset for count bytes.
|
|---|
| 1705 |
|
|---|
| 1706 | Normally true is returned, else false. Possible error returns are:
|
|---|
| 1707 | o bfd_error_no_contents - The output section does not have the
|
|---|
| 1708 | SEC_HAS_CONTENTS attribute, so nothing can be written to it.
|
|---|
| 1709 | o and some more too */
|
|---|
| 1710 |
|
|---|
| 1711 | static boolean
|
|---|
| 1712 | vms_set_section_contents (abfd, section, location, offset, count)
|
|---|
| 1713 | bfd *abfd;
|
|---|
| 1714 | asection *section;
|
|---|
| 1715 | PTR location;
|
|---|
| 1716 | file_ptr offset;
|
|---|
| 1717 | bfd_size_type count;
|
|---|
| 1718 | {
|
|---|
| 1719 | #if VMS_DEBUG
|
|---|
| 1720 | vms_debug (1, "vms_set_section_contents(%p, sec %s, loc %p, off %ld, count %d)\n",
|
|---|
| 1721 | abfd, section->name, location, (long int)offset, (int)count);
|
|---|
| 1722 | vms_debug (2, "secraw %d, seccooked %d\n", (int)section->_raw_size, (int)section->_cooked_size);
|
|---|
| 1723 | #endif
|
|---|
| 1724 | return _bfd_save_vms_section(abfd, section, location, offset, count);
|
|---|
| 1725 | }
|
|---|
| 1726 |
|
|---|
| 1727 | /*-- Part 4.8, linker -------------------------------------------------------*/
|
|---|
| 1728 |
|
|---|
| 1729 | /* Get the size of the section headers. */
|
|---|
| 1730 |
|
|---|
| 1731 | static int
|
|---|
| 1732 | vms_sizeof_headers (abfd, reloc)
|
|---|
| 1733 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1734 | boolean reloc ATTRIBUTE_UNUSED;
|
|---|
| 1735 | {
|
|---|
| 1736 | #if VMS_DEBUG
|
|---|
| 1737 | vms_debug (1, "vms_sizeof_headers(%p, %s)\n", abfd, (reloc)?"True":"False");
|
|---|
| 1738 | #endif
|
|---|
| 1739 | return 0;
|
|---|
| 1740 | }
|
|---|
| 1741 |
|
|---|
| 1742 | /* Provides default handling of relocation effort for back ends
|
|---|
| 1743 | which can't be bothered to do it efficiently. */
|
|---|
| 1744 |
|
|---|
| 1745 | static bfd_byte *
|
|---|
| 1746 | vms_bfd_get_relocated_section_contents (abfd, link_info, link_order, data,
|
|---|
| 1747 | relocateable, symbols)
|
|---|
| 1748 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1749 | struct bfd_link_info *link_info ATTRIBUTE_UNUSED;
|
|---|
| 1750 | struct bfd_link_order *link_order ATTRIBUTE_UNUSED;
|
|---|
| 1751 | bfd_byte *data ATTRIBUTE_UNUSED;
|
|---|
| 1752 | boolean relocateable ATTRIBUTE_UNUSED;
|
|---|
| 1753 | asymbol **symbols ATTRIBUTE_UNUSED;
|
|---|
| 1754 | {
|
|---|
| 1755 | #if VMS_DEBUG
|
|---|
| 1756 | vms_debug (1, "vms_bfd_get_relocated_section_contents(%p, %p, %p, %p, %s, %p)\n",
|
|---|
| 1757 | abfd, link_info, link_order, data, (relocateable)?"True":"False", symbols);
|
|---|
| 1758 | #endif
|
|---|
| 1759 | return 0;
|
|---|
| 1760 | }
|
|---|
| 1761 |
|
|---|
| 1762 | /* ??? */
|
|---|
| 1763 |
|
|---|
| 1764 | static boolean
|
|---|
| 1765 | vms_bfd_relax_section (abfd, section, link_info, again)
|
|---|
| 1766 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1767 | asection *section ATTRIBUTE_UNUSED;
|
|---|
| 1768 | struct bfd_link_info *link_info ATTRIBUTE_UNUSED;
|
|---|
| 1769 | boolean *again ATTRIBUTE_UNUSED;
|
|---|
| 1770 | {
|
|---|
| 1771 | #if VMS_DEBUG
|
|---|
| 1772 | vms_debug (1, "vms_bfd_relax_section(%p, %s, %p, <ret>)\n",
|
|---|
| 1773 | abfd, section->name, link_info);
|
|---|
| 1774 | #endif
|
|---|
| 1775 | return true;
|
|---|
| 1776 | }
|
|---|
| 1777 |
|
|---|
| 1778 | static boolean
|
|---|
| 1779 | vms_bfd_gc_sections (abfd, link_info)
|
|---|
| 1780 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1781 | struct bfd_link_info *link_info ATTRIBUTE_UNUSED;
|
|---|
| 1782 | {
|
|---|
| 1783 | #if VMS_DEBUG
|
|---|
| 1784 | vms_debug (1, "vms_bfd_gc_sections(%p, %p)\n", abfd, link_info);
|
|---|
| 1785 | #endif
|
|---|
| 1786 | return true;
|
|---|
| 1787 | }
|
|---|
| 1788 |
|
|---|
| 1789 | /* Create a hash table for the linker. Different backends store
|
|---|
| 1790 | different information in this table. */
|
|---|
| 1791 |
|
|---|
| 1792 | static struct bfd_link_hash_table *
|
|---|
| 1793 | vms_bfd_link_hash_table_create (abfd)
|
|---|
| 1794 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1795 | {
|
|---|
| 1796 | #if VMS_DEBUG
|
|---|
| 1797 | vms_debug (1, "vms_bfd_link_hash_table_create(%p)\n", abfd);
|
|---|
| 1798 | #endif
|
|---|
| 1799 | return 0;
|
|---|
| 1800 | }
|
|---|
| 1801 |
|
|---|
| 1802 | /* Add symbols from this object file into the hash table. */
|
|---|
| 1803 |
|
|---|
| 1804 | static boolean
|
|---|
| 1805 | vms_bfd_link_add_symbols (abfd, link_info)
|
|---|
| 1806 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1807 | struct bfd_link_info *link_info ATTRIBUTE_UNUSED;
|
|---|
| 1808 | {
|
|---|
| 1809 | #if VMS_DEBUG
|
|---|
| 1810 | vms_debug (1, "vms_bfd_link_add_symbols(%p, %p)\n", abfd, link_info);
|
|---|
| 1811 | #endif
|
|---|
| 1812 | return false;
|
|---|
| 1813 | }
|
|---|
| 1814 |
|
|---|
| 1815 | /* Do a link based on the link_order structures attached to each
|
|---|
| 1816 | section of the BFD. */
|
|---|
| 1817 |
|
|---|
| 1818 | static boolean
|
|---|
| 1819 | vms_bfd_final_link (abfd, link_info)
|
|---|
| 1820 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1821 | struct bfd_link_info *link_info ATTRIBUTE_UNUSED;
|
|---|
| 1822 | {
|
|---|
| 1823 | #if VMS_DEBUG
|
|---|
| 1824 | vms_debug (1, "vms_bfd_final_link(%p, %p)\n", abfd, link_info);
|
|---|
| 1825 | #endif
|
|---|
| 1826 | return true;
|
|---|
| 1827 | }
|
|---|
| 1828 |
|
|---|
| 1829 | /* Should this section be split up into smaller pieces during linking. */
|
|---|
| 1830 |
|
|---|
| 1831 | static boolean
|
|---|
| 1832 | vms_bfd_link_split_section (abfd, section)
|
|---|
| 1833 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1834 | asection *section ATTRIBUTE_UNUSED;
|
|---|
| 1835 | {
|
|---|
| 1836 | #if VMS_DEBUG
|
|---|
| 1837 | vms_debug (1, "vms_bfd_link_split_section(%p, %s)\n", abfd, section->name);
|
|---|
| 1838 | #endif
|
|---|
| 1839 | return false;
|
|---|
| 1840 | }
|
|---|
| 1841 |
|
|---|
| 1842 | /*-- Part 4.9, dynamic symbols and relocations ------------------------------*/
|
|---|
| 1843 |
|
|---|
| 1844 | /* Get the amount of memory required to hold the dynamic symbols. */
|
|---|
| 1845 |
|
|---|
| 1846 | static long
|
|---|
| 1847 | vms_get_dynamic_symtab_upper_bound (abfd)
|
|---|
| 1848 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1849 | {
|
|---|
| 1850 | #if VMS_DEBUG
|
|---|
| 1851 | vms_debug (1, "vms_get_dynamic_symtab_upper_bound(%p)\n", abfd);
|
|---|
| 1852 | #endif
|
|---|
| 1853 | return 0;
|
|---|
| 1854 | }
|
|---|
| 1855 |
|
|---|
| 1856 | static boolean
|
|---|
| 1857 | vms_bfd_print_private_bfd_data (abfd, file)
|
|---|
| 1858 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1859 | void *file ATTRIBUTE_UNUSED;
|
|---|
| 1860 | {
|
|---|
| 1861 | #if VMS_DEBUG
|
|---|
| 1862 | vms_debug (1, "vms_bfd_print_private_bfd_data(%p)\n", abfd);
|
|---|
| 1863 | #endif
|
|---|
| 1864 | return 0;
|
|---|
| 1865 | }
|
|---|
| 1866 |
|
|---|
| 1867 | /* Read in the dynamic symbols. */
|
|---|
| 1868 |
|
|---|
| 1869 | static long
|
|---|
| 1870 | vms_canonicalize_dynamic_symtab (abfd, symbols)
|
|---|
| 1871 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1872 | asymbol **symbols ATTRIBUTE_UNUSED;
|
|---|
| 1873 | {
|
|---|
| 1874 | #if VMS_DEBUG
|
|---|
| 1875 | vms_debug (1, "vms_canonicalize_dynamic_symtab(%p, <ret>)\n", abfd);
|
|---|
| 1876 | #endif
|
|---|
| 1877 | return 0L;
|
|---|
| 1878 | }
|
|---|
| 1879 |
|
|---|
| 1880 | /* Get the amount of memory required to hold the dynamic relocs. */
|
|---|
| 1881 |
|
|---|
| 1882 | static long
|
|---|
| 1883 | vms_get_dynamic_reloc_upper_bound (abfd)
|
|---|
| 1884 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1885 | {
|
|---|
| 1886 | #if VMS_DEBUG
|
|---|
| 1887 | vms_debug (1, "vms_get_dynamic_reloc_upper_bound(%p)\n", abfd);
|
|---|
| 1888 | #endif
|
|---|
| 1889 | return 0L;
|
|---|
| 1890 | }
|
|---|
| 1891 |
|
|---|
| 1892 | /* Read in the dynamic relocs. */
|
|---|
| 1893 |
|
|---|
| 1894 | static long
|
|---|
| 1895 | vms_canonicalize_dynamic_reloc (abfd, arel, symbols)
|
|---|
| 1896 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1897 | arelent **arel ATTRIBUTE_UNUSED;
|
|---|
| 1898 | asymbol **symbols ATTRIBUTE_UNUSED;
|
|---|
| 1899 | {
|
|---|
| 1900 | #if VMS_DEBUG
|
|---|
| 1901 | vms_debug (1, "vms_canonicalize_dynamic_reloc(%p)\n", abfd);
|
|---|
| 1902 | #endif
|
|---|
| 1903 | return 0L;
|
|---|
| 1904 | }
|
|---|