binutils-gdb/bfd/libieee.h

137 lines
3.4 KiB
C
Raw Normal View History

1999-05-03 09:29:11 +02:00
/* IEEE-695 object file formats: definitions internal to BFD.
Copyright (C) 1990-2015 Free Software Foundation, Inc.
1999-05-03 09:29:11 +02:00
Written by Cygnus Support. Mostly Steve Chamberlain's fault.
This file is part of BFD, the Binary File Descriptor library.
1999-05-03 09:29:11 +02:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
1999-05-03 09:29:11 +02:00
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
1999-05-03 09:29:11 +02:00
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
1999-05-03 09:29:11 +02:00
typedef struct {
unsigned int index:24;
char letter;
} ieee_symbol_index_type;
typedef struct ct {
bfd *this;
struct ct *next;
} bfd_chain_type;
typedef struct ieee_symbol
1999-05-03 09:29:11 +02:00
{
asymbol symbol;
struct ieee_symbol *next;
unsigned int index;
} ieee_symbol_type;
typedef struct ieee_reloc {
arelent relent;
struct ieee_reloc *next;
ieee_symbol_index_type symbol;
} ieee_reloc_type;
#define ieee_symbol(x) ((ieee_symbol_type *)(x))
typedef struct ieee_per_section
{
asection *section;
bfd_byte *data;
bfd_vma offset;
bfd_vma pc;
/* For output */
file_ptr current_pos;
unsigned int current_byte;
bfd_boolean initialized;
1999-05-03 09:29:11 +02:00
ieee_reloc_type **reloc_tail_ptr;
} ieee_per_section_type;
#define ieee_per_section(x) ((ieee_per_section_type *)((x)->used_by_bfd))
1999-05-03 09:29:11 +02:00
typedef struct {
unsigned char *input_p;
1999-05-03 09:29:11 +02:00
unsigned char *first_byte;
unsigned char *last_byte;
Fixes for memory access violations exposed by fuzzinf various binaries. PR binutils/17512 * dwarf.c (get_encoded_value): Check for an encoded size of 0. (display_debug_lines_raw): Check for an invalid line range value. (display_debug_frames): Check for corrupt augmentation data. * coffgen.c (coff_get_normalized_symtab): Check for an excessive number of auxillary entries. * ieee.c (next_byte): Convert to a function. Return FALSE if the next byte is beyond the end of the buffer. (parse_int): Test the return value of next_byte. (parse_expression): Convert to boolean. Return FALSE if the parsing failed. Test the return value of next_byte. (ieee_seek): Convert to a function. Return FALSE if the seek goes beyond the end of the buffer. (ieee_slurp_external_symbols): Test the return value of ieee_seek and next_byte. (ieee_slurp_sections): Convert to boolean. Return FALSE if the operation failed. Test the return value of ieee_seek and next_byte. (ieee_archive_p): Test the return value of ieee_seek and next_byte. (do_one): Likewise. (ieee_slurp_section_data): Likewise. (ieee_object_p): Likewise. Store the size of the buffer in the total_amt field in the header. * libieee.h (common_header_type): Add amt field. * mach-o.c (bfd_mach_o_canonicalize_one_reloc): Check that the reloc's value is within range. (bfd_mach_o_read_symtab_symbols): Nullify the symbols field if the operation fails. * pei-x86_64.c (pex64_xdata_print_uwd_codes): Replace abort with an error message. (pex64_dump_xdata): Check for buffer overflows. * versados.c (process_otr): Check that the section exists before taking its size. (versados_object_p): Make sure that enough data was read for the header to be checked. * vms-alpha.c (vms_get_remaining_object_record): Change read_so_far parameter to an unsigned int. Check that the amount read is in range.
2014-11-21 22:44:04 +01:00
bfd_size_type total_amt;
1999-05-03 09:29:11 +02:00
bfd *abfd;
} common_header_type ;
typedef struct ieee_data_struct
{
common_header_type h;
bfd_boolean read_symbols;
bfd_boolean read_data;
1999-05-03 09:29:11 +02:00
file_ptr output_cursor;
/* Map of section indexes to section ptrs */
asection **section_table;
unsigned int section_table_size;
ieee_address_descriptor_type ad;
ieee_module_begin_type mb;
ieee_w_variable_type w;
1999-05-03 09:29:11 +02:00
unsigned int section_count;
1999-05-03 09:29:11 +02:00
unsigned int map_idx;
/* List of GLOBAL EXPORT symbols */
ieee_symbol_type *external_symbols;
/* List of UNDEFINED symbols */
ieee_symbol_type *external_reference;
1999-05-03 09:29:11 +02:00
/* When the symbols have been canonicalized, they are in a
* special order, we remember various bases here.. */
unsigned int external_symbol_max_index;
unsigned int external_symbol_min_index;
unsigned int external_symbol_count;
int external_symbol_base_offset;
1999-05-03 09:29:11 +02:00
unsigned int external_reference_max_index;
unsigned int external_reference_min_index;
unsigned int external_reference_count;
int external_reference_base_offset;
1999-05-03 09:29:11 +02:00
bfd_boolean symbol_table_full;
1999-05-03 09:29:11 +02:00
bfd_boolean done_debug;
1999-05-03 09:29:11 +02:00
bfd_chain_type *chain_head;
bfd_chain_type *chain_root;
} ieee_data_type;
typedef struct {
file_ptr file_offset;
bfd *abfd;
} ieee_ar_obstack_type;
typedef struct ieee_ar_data_struct
1999-05-03 09:29:11 +02:00
{
common_header_type h;
ieee_ar_obstack_type *elements;
1999-05-03 09:29:11 +02:00
unsigned int element_index ;
unsigned int element_count;
} ieee_ar_data_type;
#define IEEE_DATA(abfd) ((abfd)->tdata.ieee_data)
#define IEEE_AR_DATA(abfd) ((abfd)->tdata.ieee_ar_data)
#define ptr(abfd) (ieee_data(abfd)->input_p)