/* BFD back-end for ieee-695 objects.
- Copyright (C) 1990-2016 Free Software Foundation, Inc.
+ Copyright (C) 1990-2018 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);
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%pB: string too long (%ld chars, max 65535)"), abfd, (long) length);
bfd_set_error (bfd_error_invalid_operation);
return FALSE;
}
/* Functions for reading from ieee files in the strange way that the
standard requires. */
-#define this_byte(ieee) *((ieee)->input_p)
-#define this_byte_and_next(ieee) (*((ieee)->input_p++))
+#define this_byte(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);
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%pB: 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;
}
parse_int (&ieee->h, &value);
break;
default:
- (*_bfd_error_handler)
- (_("%B: unimplemented ATI record %u for symbol %u"),
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%pB: unimplemented ATI record %u for symbol %u"),
abfd, symbol_attribute_def, symbol_name_index);
bfd_set_error (bfd_error_bad_value);
return FALSE;
parse_int (&ieee->h, &value);
if (value != 0x3f)
{
- (*_bfd_error_handler)
- (_("%B: unexpected ATN type %d in external part"),
- abfd, (int) value);
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%pB: unexpected ATN type %" PRId64 " in external part"),
+ abfd, (int64_t) value);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
break;
default:
- (*_bfd_error_handler)
- (_("%B: unexpected type after ATN"), abfd);
+ _bfd_error_handler
+ (_("%pB: unexpected type after ATN"), abfd);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
return FALSE;
/* Fully linked IEEE-695 files tend to give every symbol
- an absolute value. Try to convert that back into a
- section relative value. FIXME: This won't always to
- the right thing. */
+ an absolute value. Try to convert that back into a
+ section relative value. FIXME: This won't always to
+ the right thing. */
if (bfd_is_abs_section (symbol->symbol.section)
&& (abfd->flags & HAS_RELOC) == 0)
{
/* 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':
if (processor[4] == '9') /* 68349 */
strcpy (family, "68030"); /* CPU030 */
- else /* 68340, 68341 */
+ else /* 68340, 68341 */
strcpy (family, "68332"); /* CPU32 and CPU32+ */
break;
}
}
else if (TOUPPER (processor[3]) == 'F') /* 68F333 */
- strcpy (family, "68332"); /* CPU32 */
+ strcpy (family, "68332"); /* CPU32 */
else if ((TOUPPER (processor[3]) == 'C') /* Embedded controllers. */
&& ((TOUPPER (processor[2]) == 'E')
|| (TOUPPER (processor[2]) == 'H')
{
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 ();
for (s = abfd->sections; s != (asection *) NULL; s = s->next)
{
/* Skip sections that have no loadable contents (.bss,
- debugging, etc.) */
+ debugging, etc.) */
if ((s->flags & SEC_LOAD) == 0)
continue;
return FALSE;
}
/* bfd_set_section_contents has already checked that everything
- is within range. */
+ is within range. */
memcpy (section->contents + offset, location, (size_t) count);
return TRUE;
}
else
{
/* This can happen - when there are gaps in the symbols read
- from an input ieee file. */
+ from an input ieee file. */
}
}
}
}
#define ieee_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define ieee_find_line _bfd_nosymbols_find_line
+#define ieee_find_line _bfd_nosymbols_find_line
#define ieee_find_inliner_info _bfd_nosymbols_find_inliner_info
static int
#define ieee_close_and_cleanup _bfd_generic_close_and_cleanup
#define ieee_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-#define ieee_slurp_armap bfd_true
-#define ieee_slurp_extended_name_table bfd_true
+#define ieee_slurp_armap _bfd_bool_bfd_true
+#define ieee_slurp_extended_name_table _bfd_bool_bfd_true
#define ieee_construct_extended_name_table \
- ((bfd_boolean (*) \
- (bfd *, char **, bfd_size_type *, const char **)) \
- bfd_true)
+ _bfd_noarchive_construct_extended_name_table
#define ieee_truncate_arname bfd_dont_truncate_arname
-#define ieee_write_armap \
- ((bfd_boolean (*) \
- (bfd *, unsigned int, struct orl *, unsigned int, int)) \
- bfd_true)
-#define ieee_read_ar_hdr bfd_nullvoidptr
-#define ieee_write_ar_hdr ((bfd_boolean (*) (bfd *, bfd *)) bfd_false)
-#define ieee_update_armap_timestamp bfd_true
+#define ieee_write_armap _bfd_noarchive_write_armap
+#define ieee_read_ar_hdr _bfd_ptr_bfd_null_error
+#define ieee_write_ar_hdr _bfd_noarchive_write_ar_hdr
+#define ieee_update_armap_timestamp _bfd_bool_bfd_true
#define ieee_get_elt_at_index _bfd_generic_get_elt_at_index
#define ieee_get_symbol_version_string \
_bfd_nosymbols_get_symbol_version_string
-#define ieee_bfd_is_target_special_symbol \
- ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define ieee_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
#define ieee_bfd_is_local_label_name bfd_generic_is_local_label_name
#define ieee_get_lineno _bfd_nosymbols_get_lineno
#define ieee_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
#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 =
{
_bfd_dummy_target,
},
{
- bfd_false,
+ _bfd_bool_bfd_false_error,
ieee_mkobject,
_bfd_generic_mkarchive,
- bfd_false
+ _bfd_bool_bfd_false_error
},
{
- bfd_false,
+ _bfd_bool_bfd_false_error,
ieee_write_object_contents,
_bfd_write_archive_contents,
- bfd_false,
+ _bfd_bool_bfd_false_error,
},
/* ieee_close_and_cleanup, ieee_bfd_free_cached_info, ieee_new_section_hook,