vms.c
来自「基于4个mips核的noc设计」· C语言 代码 · 共 1,903 行 · 第 1/4 页
C
1,903 行
default: err = -1; } if (err != 0) {#if VMS_DEBUG vms_debug (2, "slurp type %d failed with %d\n", prev_type, err);#endif bfd_set_error (bfd_error_wrong_format); return 0; } } while ((prev_type != EOBJ_S_C_EEOM) && (prev_type != OBJ_S_C_EOM) && (prev_type != OBJ_S_C_EOMW)); if (target_vector == &vms_vax_vec) { if (vms_fixup_sections (abfd) == false) {#if VMS_DEBUG vms_debug (2, "vms_fixup_sections failed\n");#endif bfd_set_error (bfd_error_wrong_format); return 0; } /* set arch_info to vax */ arch = bfd_scan_arch ("vax"); PRIV (is_vax) = 1;#if VMS_DEBUG vms_debug (2, "arch is vax\n");#endif } else if (target_vector == &vms_alpha_vec) { /* set arch_info to alpha */ arch = bfd_scan_arch ("alpha"); PRIV (is_vax) = 0;#if VMS_DEBUG vms_debug (2, "arch is alpha\n");#endif } if (arch == 0) {#if VMS_DEBUG vms_debug (2, "arch not found\n");#endif bfd_set_error (bfd_error_wrong_format); return 0; } abfd->arch_info = arch; return target_vector;}/* Check the format for a file being read. Return a (bfd_target *) if it's an archive file or zero. */static const struct bfd_target *vms_archive_p (abfd) bfd *abfd ATTRIBUTE_UNUSED;{#if VMS_DEBUG vms_debug (1, "vms_archive_p(%p)\n", abfd);#endif return 0;}/* Set the format of a file being written. */static booleanvms_mkobject (abfd) bfd *abfd;{#if VMS_DEBUG vms_debug (1, "vms_mkobject(%p)\n", abfd);#endif if (!vms_initialize (abfd)) { fprintf (stderr, "vms_initialize () failed !!\n"); return 0; } {#ifdef __VAX const bfd_arch_info_type *arch = bfd_scan_arch ("vax");#else const bfd_arch_info_type *arch = bfd_scan_arch ("alpha");#endif if (arch == 0) { bfd_set_error(bfd_error_wrong_format); return 0; } abfd->arch_info = arch; } return true;}/* Write cached information into a file being written, at bfd_close. */static booleanvms_write_object_contents (abfd) bfd *abfd;{#if VMS_DEBUG vms_debug (1, "vms_write_object_contents(%p)\n", abfd);#endif if (abfd->section_count > 0) /* we have sections */ { if (PRIV (is_vax)) { if (_bfd_vms_write_hdr (abfd, OBJ_S_C_HDR) != 0) return false; if (_bfd_vms_write_gsd (abfd, OBJ_S_C_GSD) != 0) return false; if (_bfd_vms_write_tir (abfd, OBJ_S_C_TIR) != 0) return false; if (_bfd_vms_write_tbt (abfd, OBJ_S_C_TBT) != 0) return false; if (_bfd_vms_write_dbg (abfd, OBJ_S_C_DBG) != 0) return false; if (abfd->section_count > 255) { if (_bfd_vms_write_eom (abfd, OBJ_S_C_EOMW) != 0) return false; } else { if (_bfd_vms_write_eom (abfd, OBJ_S_C_EOM) != 0) return false; } } else { if (_bfd_vms_write_hdr (abfd, EOBJ_S_C_EMH) != 0) return false; if (_bfd_vms_write_gsd (abfd, EOBJ_S_C_EGSD) != 0) return false; if (_bfd_vms_write_tir (abfd, EOBJ_S_C_ETIR) != 0) return false; if (_bfd_vms_write_tbt (abfd, EOBJ_S_C_ETBT) != 0) return false; if (_bfd_vms_write_dbg (abfd, EOBJ_S_C_EDBG) != 0) return false; if (_bfd_vms_write_eom (abfd, EOBJ_S_C_EEOM) != 0) return false; } } return true;}/*-- 4.1, generic -----------------------------------------------------------*//* Called when the BFD is being closed to do any necessary cleanup. */static booleanvms_close_and_cleanup (abfd) bfd *abfd;{ asection *sec; vms_section *es, *es1; int i;#if VMS_DEBUG vms_debug (1, "vms_close_and_cleanup(%p)\n", abfd);#endif if (abfd == 0) return true; if (PRIV (vms_buf) != NULL) { free (PRIV (vms_buf)); PRIV (vms_buf) = NULL; } PRIV (buf_size) = 0; if (PRIV (output_buf) != 0) { free (PRIV (output_buf)); PRIV (output_buf) = 0; } sec = abfd->sections; while (sec != NULL) { if (sec->contents) free (sec->contents); sec = sec->next; } if (PRIV (sections) != NULL) { free (PRIV (sections)); PRIV (sections) = NULL; } if (PRIV (vms_symbol_table)) { bfd_hash_table_free (PRIV (vms_symbol_table)); PRIV (vms_symbol_table) = 0; } if (PRIV (stack)) { free (PRIV (stack)); PRIV (stack) = 0; } if (PRIV (location_stack)) { free (PRIV (location_stack)); PRIV (location_stack) = 0; } for (i = 0; i < VMS_SECTION_COUNT; i++) { es = PRIV (vms_section_table)[i]; while (es != NULL) { es1 = es->next; free (es); es = es1; } PRIV (vms_section_table)[i] = NULL; } free (abfd->tdata.any); abfd->tdata.any = NULL; return true;}/* Ask the BFD to free all cached information. */static booleanvms_bfd_free_cached_info (abfd) bfd *abfd ATTRIBUTE_UNUSED;{#if VMS_DEBUG vms_debug (1, "vms_bfd_free_cached_info(%p)\n", abfd);#endif return true;}/* Called when a new section is created. */static booleanvms_new_section_hook (abfd, section) bfd *abfd; asection *section;{#if VMS_DEBUG vms_debug (1, "vms_new_section_hook (%p, [%d]%s), count %d\n", abfd, section->index, section->name, abfd->section_count);#endif bfd_set_section_alignment(abfd, section, 4); if (abfd->section_count > PRIV (section_count)) { PRIV (sections) = ((asection **) bfd_realloc (PRIV (sections), abfd->section_count * sizeof (asection *))); if (PRIV (sections) == 0) return false; PRIV (section_count) = abfd->section_count; }#if VMS_DEBUG vms_debug (6, "section_count: %d\n", PRIV (section_count));#endif PRIV (sections)[section->index] = section;#if VMS_DEBUG vms_debug (7, "%d: %s\n", section->index, section->name);#endif return true;}/* Read the contents of a section. buf points to a buffer of buf_size bytes to be filled with section data (starting at offset into section) */static booleanvms_get_section_contents (abfd, section, buf, offset, buf_size) bfd *abfd ATTRIBUTE_UNUSED; asection *section ATTRIBUTE_UNUSED; PTR buf ATTRIBUTE_UNUSED; file_ptr offset ATTRIBUTE_UNUSED; bfd_size_type buf_size ATTRIBUTE_UNUSED;{#if VMS_DEBUG vms_debug (1, "vms_get_section_contents(%p, %s, %p, off %ld, size %d)\n", abfd, section->name, buf, offset, (int)buf_size);#endif /* shouldn't be called, since all sections are IN_MEMORY */ return false;}/* Read the contents of a section. buf points to a buffer of buf_size bytes to be filled with section data (starting at offset into section) */static booleanvms_get_section_contents_in_window (abfd, section, w, offset, count) bfd *abfd ATTRIBUTE_UNUSED; asection *section ATTRIBUTE_UNUSED; bfd_window *w ATTRIBUTE_UNUSED; file_ptr offset ATTRIBUTE_UNUSED; bfd_size_type count ATTRIBUTE_UNUSED;{#if VMS_DEBUG vms_debug (1, "vms_get_section_contents_in_window(%p, %s, %p, off %ld, count %d)\n", abfd, section->name, w, offset, (int)count);#endif /* shouldn't be called, since all sections are IN_MEMORY */ return false;}/*-- Part 4.2, copy private data --------------------------------------------*//* Called to copy BFD general private data from one object file to another. */static booleanvms_bfd_copy_private_bfd_data (src, dest) bfd *src ATTRIBUTE_UNUSED; bfd *dest ATTRIBUTE_UNUSED;{#if VMS_DEBUG vms_debug (1, "vms_bfd_copy_private_bfd_data(%p, %p)\n", src, dest);#endif return true;}/* Merge private BFD information from the BFD @var{ibfd} to the the output file BFD @var{obfd} when linking. Return <<true>> on success, <<false>> on error. Possible error returns are: o <<bfd_error_no_memory>> - Not enough memory exists to create private data for @var{obfd}. */static booleanvms_bfd_merge_private_bfd_data (ibfd, obfd) bfd *ibfd ATTRIBUTE_UNUSED; bfd *obfd ATTRIBUTE_UNUSED;{#if VMS_DEBUG vms_debug (1,"vms_bfd_merge_private_bfd_data(%p, %p)\n", ibfd, obfd);#endif return true;}/* Set private BFD flag information in the BFD @var{abfd}. Return <<true>> on success, <<false>> on error. Possible error returns are: o <<bfd_error_no_memory>> - Not enough memory exists to create private data for @var{obfd}. */static booleanvms_bfd_set_private_flags (abfd, flags) bfd *abfd ATTRIBUTE_UNUSED; flagword flags ATTRIBUTE_UNUSED;{#if VMS_DEBUG vms_debug (1,"vms_bfd_set_private_flags(%p, %lx)\n", abfd, (long)flags);#endif return true;}/* Called to copy BFD private section data from one object file to another. */static booleanvms_bfd_copy_private_section_data (srcbfd, srcsec, dstbfd, dstsec) bfd *srcbfd ATTRIBUTE_UNUSED; asection *srcsec ATTRIBUTE_UNUSED; bfd *dstbfd ATTRIBUTE_UNUSED; asection *dstsec ATTRIBUTE_UNUSED;{#if VMS_DEBUG vms_debug (1, "vms_bfd_copy_private_section_data(%p, %s, %p, %s)\n", srcbfd, srcsec->name, dstbfd, dstsec->name);#endif return true;}/* Called to copy BFD private symbol data from one object file to another. */static booleanvms_bfd_copy_private_symbol_data (ibfd, isym, obfd, osym) bfd *ibfd ATTRIBUTE_UNUSED; asymbol *isym ATTRIBUTE_UNUSED; bfd *obfd ATTRIBUTE_UNUSED; asymbol *osym ATTRIBUTE_UNUSED;{#if VMS_DEBUG vms_debug (1, "vms_bfd_copy_private_symbol_data(%p, %s, %p, %s)\n", ibfd, isym->name, obfd, osym->name);#endif return true;}/*-- Part 4.3, core file ----------------------------------------------------*//* Return a read-only string explaining which program was running when it failed and produced the core file abfd. */static char *vms_core_file_failing_command (abfd) bfd *abfd ATTRIBUTE_UNUSED;{#if VMS_DEBUG vms_debug (1, "vms_core_file_failing_command(%p)\n", abfd);#endif return 0;}/* Returns the signal number which caused the core dump which generated the file the BFD abfd is attached to. */static intvms_core_file_failing_signal (abfd) bfd *abfd ATTRIBUTE_UNUSED;{#if VMS_DEBUG vms_debug (1, "vms_core_file_failing_signal(%p)\n", abfd);#endif return 0;}/* Return true if the core file attached to core_bfd was generated by a run of the executable file attached to exec_bfd, false otherwise. */static booleanvms_core_file_matches_executable_p (abfd, bbfd) bfd *abfd ATTRIBUTE_UNUSED; bfd *bbfd ATTRIBUTE_UNUSED;{#if VMS_DEBUG vms_debug (1, "vms_core_file_matches_executable_p(%p, %p)\n", abfd, bbfd);#endif return false;}/*-- Part 4.4, archive ------------------------------------------------------*//* ??? do something with an archive map. Return false on error, true otherwise. */static booleanvms_slurp_armap (abfd) bfd *abfd ATTRIBUTE_UNUSED;{#if VMS_DEBUG vms_debug (1, "vms_slurp_armap(%p)\n", abfd);#endif return false;}/* ??? do something with an extended name table. Return false on error, true otherwise. */static booleanvms_slurp_extended_name_table (abfd) bfd *abfd ATTRIBUTE_UNUSED;{#if VMS_DEBUG
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?