X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Fsrec.c;h=5fdd68bdd0f8066e019028acb4020a50b024bad5;hb=5b677558bc6c7b2477bb33c709e6017e68e7ae8c;hp=f11e74a0295fafe7d0bf1b4cc2719e10b11bba7d;hpb=caa4096e844a000ff63c4fa9180d70ca2093fd2a;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/srec.c b/bfd/srec.c index f11e74a029..5fdd68bdd0 100644 --- a/bfd/srec.c +++ b/bfd/srec.c @@ -1,5 +1,5 @@ /* BFD back-end for s-record objects. - Copyright (C) 1990-2014 Free Software Foundation, Inc. + Copyright (C) 1990-2016 Free Software Foundation, Inc. Written by Steve Chamberlain of Cygnus Support . This file is part of BFD, the Binary File Descriptor library. @@ -246,10 +246,10 @@ srec_bad_byte (bfd *abfd, } else { - char buf[10]; + char buf[40]; if (! ISPRINT (c)) - sprintf (buf, "\\%03o", (unsigned int) c); + sprintf (buf, "\\%03o", (unsigned int) c & 0xff); else { buf[0] = c; @@ -452,8 +452,8 @@ srec_scan (bfd *abfd) case 'S': { file_ptr pos; - char hdr[3]; - unsigned int bytes; + unsigned char hdr[3]; + unsigned int bytes, min_bytes; bfd_vma address; bfd_byte *data; unsigned char check_sum; @@ -476,6 +476,19 @@ srec_scan (bfd *abfd) } check_sum = bytes = HEX (hdr + 1); + min_bytes = 3; + if (hdr[0] == '2' || hdr[0] == '8') + min_bytes = 4; + else if (hdr[0] == '3' || hdr[0] == '7') + min_bytes = 5; + if (bytes < min_bytes) + { + (*_bfd_error_handler) (_("%B:%d: byte count %d too small\n"), + abfd, lineno, bytes); + bfd_set_error (bfd_error_bad_value); + goto error_return; + } + if (bytes * 2 > bufsize) { if (buf != NULL) @@ -1242,8 +1255,10 @@ srec_print_symbol (bfd *abfd, #define srec_bfd_is_local_label_name bfd_generic_is_local_label_name #define srec_get_lineno _bfd_nosymbols_get_lineno #define srec_find_nearest_line _bfd_nosymbols_find_nearest_line +#define srec_find_line _bfd_nosymbols_find_line #define srec_find_inliner_info _bfd_nosymbols_find_inliner_info #define srec_make_empty_symbol _bfd_generic_make_empty_symbol +#define srec_get_symbol_version_string _bfd_nosymbols_get_symbol_version_string #define srec_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol #define srec_read_minisymbols _bfd_generic_read_minisymbols #define srec_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol @@ -1260,10 +1275,10 @@ srec_print_symbol (bfd *abfd, #define srec_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define srec_bfd_link_add_symbols _bfd_generic_link_add_symbols #define srec_bfd_link_just_syms _bfd_generic_link_just_syms -#define srec_bfd_copy_link_hash_symbol_type \ - _bfd_generic_copy_link_hash_symbol_type +#define srec_bfd_copy_link_hash_symbol_type _bfd_generic_copy_link_hash_symbol_type #define srec_bfd_final_link _bfd_generic_final_link #define srec_bfd_link_split_section _bfd_generic_link_split_section +#define srec_bfd_link_check_relocs _bfd_generic_link_check_relocs const bfd_target srec_vec = {