/* BFD back-end for ieee-695 objects.
- Copyright (C) 1990-2016 Free Software Foundation, Inc.
+ Copyright (C) 1990-2017 Free Software Foundation, Inc.
Written by Steve Chamberlain of Cygnus Support.
else
{
_bfd_error_handler
- (_("%s: string too long (%d chars, max 65535)"),
- bfd_get_filename (abfd), length);
+ /* xgettext:c-format */
+ (_("%B: string too long (%ld chars, max 65535)"), abfd, (long) length);
bfd_set_error (bfd_error_invalid_operation);
return FALSE;
}
standard requires. */
#define this_byte(ieee) *((ieee)->input_p)
-#define this_byte_and_next(ieee) (*((ieee)->input_p++))
+#define this_byte_and_next(ieee) ((ieee)->input_p < (ieee)->end_p ? *((ieee)->input_p++) : 0)
static bfd_boolean
next_byte (common_header_type * ieee)
length = (length * 256) + this_byte_and_next (ieee);
}
+ /* PR 21612: Check for an invalid length. */
+ if (ieee->input_p + length >= ieee->end_p)
+ {
+ _bfd_error_handler (_("IEEE parser: string length: %#lx longer than buffer: %#lx"),
+ (long) length, (long) (ieee->end_p - ieee->input_p));
+ bfd_set_error (bfd_error_invalid_operation);
+ return NULL;
+ }
+
/* Buy memory and read string. */
string = bfd_alloc (ieee->abfd, (bfd_size_type) length + 1);
if (!string)
else
{
_bfd_error_handler
- (_("%s: unrecognized symbol `%s' flags 0x%x"),
- bfd_get_filename (abfd), bfd_asymbol_name (symbol),
- symbol->flags);
+ /* xgettext:c-format */
+ (_("%B: unrecognized symbol `%s' flags 0x%x"),
+ abfd, bfd_asymbol_name (symbol), symbol->flags);
bfd_set_error (bfd_error_invalid_operation);
return FALSE;
}
if (offset < 0 || (bfd_size_type) offset >= ieee->h.total_amt)
{
ieee->h.input_p = ieee->h.first_byte + ieee->h.total_amt;
- ieee->h.last_byte = ieee->h.input_p;
+ ieee->h.end_p = ieee->h.last_byte = ieee->h.input_p;
return FALSE;
}
ieee->h.input_p = ieee->h.first_byte + offset;
- ieee->h.last_byte = (ieee->h.first_byte + ieee_part_after (ieee, offset));
+ ieee->h.end_p = ieee->h.last_byte = (ieee->h.first_byte + ieee_part_after (ieee, offset));
return TRUE;
}
break;
default:
_bfd_error_handler
+ /* xgettext:c-format */
(_("%B: unimplemented ATI record %u for symbol %u"),
abfd, symbol_attribute_def, symbol_name_index);
bfd_set_error (bfd_error_bad_value);
if (value != 0x3f)
{
_bfd_error_handler
- (_("%B: unexpected ATN type %d in external part"),
- abfd, (int) value);
+ /* xgettext:c-format */
+ (_("%B: unexpected ATN type %Ld in external part"),
+ abfd, value);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
/* Read section name, use it if non empty. */
name = read_id (&ieee->h);
+ if (name == NULL)
+ return FALSE;
if (name[0])
section->name = name;
{
char *library;
unsigned int i;
- unsigned char buffer[512];
+ static unsigned char buffer[512];
file_ptr buffer_offset = 0;
ieee_ar_data_type *save = abfd->tdata.ieee_ar_data;
ieee_ar_data_type *ieee;
ieee->h.first_byte = buffer;
ieee->h.input_p = buffer;
+ ieee->h.total_amt = sizeof (buffer);
+ ieee->h.end_p = buffer + sizeof (buffer);
ieee->h.abfd = abfd;
(void) next_byte (&(ieee->h));
library = read_id (&(ieee->h));
+ if (library == NULL)
+ goto got_wrong_format_error;
if (strcmp (library, "LIBRARY") != 0)
goto got_wrong_format_error;
bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd);
ieee->h.first_byte = buffer;
ieee->h.input_p = buffer;
+ ieee->h.total_amt = sizeof (buffer);
+ ieee->h.end_p = buffer + sizeof (buffer);
}
}
bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd);
ieee->h.first_byte = buffer;
ieee->h.input_p = buffer;
+ ieee->h.total_amt = sizeof (buffer);
+ ieee->h.end_p = buffer + sizeof (buffer);
(void) next_byte (&(ieee->h)); /* Drop F8. */
if (! next_byte (&(ieee->h))) /* Drop 14. */
char *processor;
unsigned int part;
ieee_data_type *ieee;
- unsigned char buffer[300];
+ static unsigned char buffer[300];
ieee_data_type *save = IEEE_DATA (abfd);
bfd_size_type amt;
ieee->h.input_p = buffer;
ieee->h.total_amt = sizeof (buffer);
+ ieee->h.end_p = buffer + sizeof (buffer);
+
if (this_byte_and_next (&(ieee->h)) != Module_Beginning)
goto got_wrong_format;
ieee->section_table_size = 0;
processor = ieee->mb.processor = read_id (&(ieee->h));
+ if (processor == NULL)
+ goto got_wrong_format;
if (strcmp (processor, "LIBRARY") == 0)
goto got_wrong_format;
ieee->mb.module_name = read_id (&(ieee->h));
+ if (ieee->mb.module_name == NULL)
+ goto got_wrong_format;
if (abfd->filename == (const char *) NULL)
abfd->filename = xstrdup (ieee->mb.module_name);
{
case 4:
OUT (value >> 24);
+ /* Fall through. */
case 3:
OUT (value >> 16);
+ /* Fall through. */
case 2:
OUT (value >> 8);
+ /* Fall through. */
case 1:
OUT (value);
}
case 0x84:
ch = THIS ();
NEXT ();
+ /* Fall through. */
case 0x83:
ch = THIS ();
NEXT ();
+ /* Fall through. */
case 0x82:
ch = THIS ();
NEXT ();
+ /* Fall through. */
case 0x81:
ch = THIS ();
NEXT ();
+ /* Fall through. */
case 0x80:
break;
}
ch = THIS ();
NEXT ();
OUT (ch);
+ /* Fall through. */
case 0x83:
ch = THIS ();
NEXT ();
OUT (ch);
+ /* Fall through. */
case 0x82:
ch = THIS ();
NEXT ();
OUT (ch);
+ /* Fall through. */
case 0x81:
ch = THIS ();
NEXT ();
OUT (ch);
+ /* Fall through. */
case 0x80:
break;
}
case 0x84:
OUT (THIS ());
NEXT ();
+ /* Fall through. */
case 0x83:
OUT (THIS ());
NEXT ();
+ /* Fall through. */
case 0x82:
OUT (THIS ());
NEXT ();
+ /* Fall through. */
case 0x81:
OUT (THIS ());
NEXT ();
#define ieee_section_already_linked \
_bfd_generic_section_already_linked
#define ieee_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define ieee_bfd_define_start_stop bfd_generic_define_start_stop
#define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
#define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols
#define ieee_bfd_link_just_syms _bfd_generic_link_just_syms
#define ieee_bfd_final_link _bfd_generic_final_link
#define ieee_bfd_link_split_section _bfd_generic_link_split_section
#define ieee_bfd_link_check_relocs _bfd_generic_link_check_relocs
+#define ieee_set_reloc _bfd_generic_set_reloc
const bfd_target ieee_vec =
{