X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Fvms-alpha.c;h=4b0b23fd7eedd9ea501eac46fe49c6b67ef522d4;hb=ec892a0718dc47c2d009532865c353daa749eaa1;hp=e038f1a7b4fceb1a0659cf7c90e7ca66c082081e;hpb=4b95cf5c0c75d6efc1b2f96af72317aecca079f1;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c index e038f1a7b4..4b0b23fd7e 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -1,5 +1,5 @@ /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files. - Copyright (C) 1996-2014 Free Software Foundation, Inc. + Copyright (C) 1996-2015 Free Software Foundation, Inc. Initial version written by Klaus Kaempf (kkaempf@rmi.de) Major rewrite by Adacore. @@ -364,9 +364,9 @@ struct vms_section_data_struct ((struct vms_section_data_struct *)sec->used_by_bfd) /* To be called from the debugger. */ -struct vms_private_data_struct *bfd_vms_get_data (bfd *abfd); +struct vms_private_data_struct *bfd_vms_get_data (bfd *); -static int vms_get_remaining_object_record (bfd *abfd, int read_so_far); +static int vms_get_remaining_object_record (bfd *, unsigned int); static bfd_boolean _bfd_vms_slurp_object_records (bfd * abfd); static void alpha_vms_add_fixup_lp (struct bfd_link_info *, bfd *, bfd *); static void alpha_vms_add_fixup_ca (struct bfd_link_info *, bfd *, bfd *); @@ -374,8 +374,8 @@ static void alpha_vms_add_fixup_qr (struct bfd_link_info *, bfd *, bfd *, bfd_vma); static void alpha_vms_add_fixup_lr (struct bfd_link_info *, unsigned int, bfd_vma); -static void alpha_vms_add_lw_reloc (struct bfd_link_info *info); -static void alpha_vms_add_qw_reloc (struct bfd_link_info *info); +static void alpha_vms_add_lw_reloc (struct bfd_link_info *); +static void alpha_vms_add_qw_reloc (struct bfd_link_info *); struct vector_type { @@ -521,9 +521,11 @@ _bfd_vms_slurp_eisd (bfd *abfd, unsigned int offset) asection *section; flagword bfd_flags; + /* PR 17512: file: 3d9e9fe9. */ + if (offset >= PRIV (recrd.rec_size)) + return FALSE; eisd = (struct vms_eisd *)(PRIV (recrd.rec) + offset); rec_size = bfd_getl32 (eisd->eisdsize); - if (rec_size == 0) break; @@ -788,7 +790,7 @@ _bfd_vms_get_object_record (bfd *abfd) Return the size of the record or 0 on failure. */ static int -vms_get_remaining_object_record (bfd *abfd, int read_so_far) +vms_get_remaining_object_record (bfd *abfd, unsigned int read_so_far) { unsigned int to_read; @@ -824,6 +826,9 @@ vms_get_remaining_object_record (bfd *abfd, int read_so_far) return 0; PRIV (recrd.buf_size) = to_read; } + /* PR 17512: file: 025-1974-0.004. */ + else if (to_read <= read_so_far) + return 0; /* Read the remaining record. */ to_read -= read_so_far; @@ -854,9 +859,12 @@ _bfd_vms_slurp_ehdr (bfd *abfd) { unsigned char *ptr; unsigned char *vms_rec; + unsigned char *end; int subtype; vms_rec = PRIV (recrd.rec); + /* PR 17512: file: 62736583. */ + end = PRIV (recrd.buf) + PRIV (recrd.buf_size); vms_debug2 ((2, "HDR/EMH\n")); @@ -868,28 +876,42 @@ _bfd_vms_slurp_ehdr (bfd *abfd) { case EMH__C_MHD: /* Module header. */ + if (vms_rec + 21 >= end) + goto fail; PRIV (hdr_data).hdr_b_strlvl = vms_rec[6]; PRIV (hdr_data).hdr_l_arch1 = bfd_getl32 (vms_rec + 8); PRIV (hdr_data).hdr_l_arch2 = bfd_getl32 (vms_rec + 12); PRIV (hdr_data).hdr_l_recsiz = bfd_getl32 (vms_rec + 16); + if ((vms_rec + 20 + vms_rec[20] + 1) >= end) + goto fail; PRIV (hdr_data).hdr_t_name = _bfd_vms_save_counted_string (vms_rec + 20); ptr = vms_rec + 20 + vms_rec[20] + 1; + if ((ptr + *ptr + 1) >= end) + goto fail; PRIV (hdr_data).hdr_t_version =_bfd_vms_save_counted_string (ptr); ptr += *ptr + 1; + if (ptr + 17 >= end) + goto fail; PRIV (hdr_data).hdr_t_date = _bfd_vms_save_sized_string (ptr, 17); break; case EMH__C_LNM: + if (vms_rec + PRIV (recrd.rec_size - 6) > end) + goto fail; PRIV (hdr_data).hdr_c_lnm = _bfd_vms_save_sized_string (vms_rec, PRIV (recrd.rec_size - 6)); break; case EMH__C_SRC: + if (vms_rec + PRIV (recrd.rec_size - 6) > end) + goto fail; PRIV (hdr_data).hdr_c_src = _bfd_vms_save_sized_string (vms_rec, PRIV (recrd.rec_size - 6)); break; case EMH__C_TTL: + if (vms_rec + PRIV (recrd.rec_size - 6) > end) + goto fail; PRIV (hdr_data).hdr_c_ttl = _bfd_vms_save_sized_string (vms_rec, PRIV (recrd.rec_size - 6)); break; @@ -900,6 +922,7 @@ _bfd_vms_slurp_ehdr (bfd *abfd) break; default: + fail: bfd_set_error (bfd_error_wrong_format); return FALSE; } @@ -2474,10 +2497,7 @@ alpha_vms_object_p (bfd *abfd) PRIV (recrd.rec) = buf; if (bfd_bread (buf, test_len, abfd) != test_len) - { - bfd_set_error (bfd_error_file_truncated); - goto error_ret; - } + goto err_wrong_format; /* Is it an image? */ if ((bfd_getl32 (buf) == EIHD__K_MAJORID) @@ -2502,7 +2522,6 @@ alpha_vms_object_p (bfd *abfd) if (buf == NULL) { PRIV (recrd.buf) = NULL; - bfd_set_error (bfd_error_no_memory); goto error_ret; } PRIV (recrd.buf) = buf; @@ -2517,10 +2536,7 @@ alpha_vms_object_p (bfd *abfd) while (remaining > 0) { if (bfd_bread (buf + read_so_far, to_read, abfd) != to_read) - { - bfd_set_error (bfd_error_file_truncated); - goto err_wrong_format; - } + goto err_wrong_format; read_so_far += to_read; remaining -= to_read; @@ -2531,6 +2547,9 @@ alpha_vms_object_p (bfd *abfd) /* Reset the record pointer. */ PRIV (recrd.rec) = buf; + /* PR 17512: file: 7d7c57c2. */ + if (PRIV (recrd.rec_size) < sizeof (struct vms_eihd)) + goto error_ret; vms_debug2 ((2, "file type is image\n")); if (_bfd_vms_slurp_eihd (abfd, &eisd_offset, &eihs_offset) != TRUE) @@ -4582,10 +4601,14 @@ module_find_nearest_line (bfd *abfd, struct module *module, bfd_vma addr, location. */ static bfd_boolean -_bfd_vms_find_nearest_dst_line (bfd *abfd, asection *section, - asymbol **symbols ATTRIBUTE_UNUSED, - bfd_vma offset, const char **file, - const char **func, unsigned int *line) +_bfd_vms_find_nearest_line (bfd *abfd, + asymbol **symbols ATTRIBUTE_UNUSED, + asection *section, + bfd_vma offset, + const char **file, + const char **func, + unsigned int *line, + unsigned int *discriminator) { struct module *module; @@ -4595,6 +4618,8 @@ _bfd_vms_find_nearest_dst_line (bfd *abfd, asection *section, *file = NULL; *func = NULL; *line = 0; + if (discriminator) + *discriminator = 0; /* We can't do anything if there is no DST (debug symbol table). */ if (PRIV (dst_section) == NULL) @@ -4614,26 +4639,6 @@ _bfd_vms_find_nearest_dst_line (bfd *abfd, asection *section, return FALSE; } - -/* Likewise but with a discriminator. */ - -static bfd_boolean -_bfd_vms_find_nearest_line_discriminator (bfd *abfd, - asection *section, - asymbol **symbols, - bfd_vma offset, - const char **filename_ptr, - const char **functionname_ptr, - unsigned int *line_ptr, - unsigned int *discriminator) -{ - *discriminator = 0; - - return _bfd_vms_find_nearest_dst_line (abfd, section, symbols, offset, - filename_ptr, functionname_ptr, - line_ptr); -} - /* Canonicalizations. */ /* Set name, value, section and flags of SYM from E. */ @@ -8592,7 +8597,7 @@ alpha_vms_bfd_final_link (bfd *abfd, struct bfd_link_info *info) asection *dst; asection *dmt; - if (info->relocatable) + if (bfd_link_relocatable (info)) { /* FIXME: we do not yet support relocatable link. It is not obvious how to do it for debug infos. */ @@ -8652,7 +8657,7 @@ alpha_vms_bfd_final_link (bfd *abfd, struct bfd_link_info *info) { bfd *startbfd = NULL; - for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) + for (sub = info->input_bfds; sub != NULL; sub = sub->link.next) { /* Consider only VMS object files. */ if (sub->xvec != abfd->xvec) @@ -8756,7 +8761,7 @@ alpha_vms_bfd_final_link (bfd *abfd, struct bfd_link_info *info) dmt = NULL; /* Read all sections from the inputs. */ - for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) + for (sub = info->input_bfds; sub != NULL; sub = sub->link.next) { if (sub->flags & DYNAMIC) { @@ -8807,7 +8812,7 @@ alpha_vms_bfd_final_link (bfd *abfd, struct bfd_link_info *info) unsigned int off = 0; /* For each object file (ie for each module). */ - for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) + for (sub = info->input_bfds; sub != NULL; sub = sub->link.next) { asection *sub_dst; struct vms_dmt_header *dmth = NULL; @@ -9008,13 +9013,13 @@ vms_new_section_hook (bfd * abfd, asection *section) { bfd_size_type amt; - vms_debug2 ((1, "vms_new_section_hook (%p, [%d]%s)\n", + vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n", abfd, section->index, section->name)); if (! bfd_set_section_alignment (abfd, section, 0)) return FALSE; - vms_debug2 ((7, "%d: %s\n", section->index, section->name)); + vms_debug2 ((7, "%u: %s\n", section->index, section->name)); amt = sizeof (struct vms_section_data_struct); section->used_by_bfd = bfd_zalloc (abfd, amt); @@ -9209,14 +9214,16 @@ bfd_vms_get_data (bfd *abfd) ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false) #define alpha_vms_print_symbol vms_print_symbol #define alpha_vms_get_symbol_info vms_get_symbol_info +#define alpha_vms_get_symbol_version_string \ + _bfd_nosymbols_get_symbol_version_string + #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol -#define alpha_vms_find_nearest_line _bfd_vms_find_nearest_dst_line -#define _bfd_generic_find_nearest_line_discriminator \ - _bfd_vms_find_nearest_line_discriminator +#define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line +#define alpha_vms_find_line _bfd_nosymbols_find_line #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name /* Generic table. */ @@ -9239,7 +9246,6 @@ bfd_vms_get_data (bfd *abfd) _bfd_generic_section_already_linked #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol -#define alpha_vms_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms #define alpha_vms_bfd_copy_link_hash_symbol_type \ _bfd_generic_copy_link_hash_symbol_type @@ -9255,7 +9261,7 @@ bfd_vms_get_data (bfd *abfd) #define alpha_vms_canonicalize_dynamic_reloc \ _bfd_nodynamic_canonicalize_dynamic_reloc -const bfd_target vms_alpha_vec = +const bfd_target alpha_vms_vec = { "vms-alpha", /* Name. */ bfd_target_evax_flavour,