Written by Cygnus Solutions.
This file is part of BFD, the Binary File Descriptor library.
Written by Cygnus Solutions.
This file is part of BFD, the Binary File Descriptor library.
#define coff_bfd_print_private_bfd_data pe_print_private_bfd_data
static bfd_boolean (*pe_saved_coff_bfd_copy_private_bfd_data) (bfd *, bfd *) =
#define coff_bfd_print_private_bfd_data pe_print_private_bfd_data
static bfd_boolean (*pe_saved_coff_bfd_copy_private_bfd_data) (bfd *, bfd *) =
- coff_symbol_type * sym_cache;
- coff_symbol_type * sym_ptr;
- unsigned int sym_index;
+ coff_symbol_type * sym_cache;
+ coff_symbol_type * sym_ptr;
+ unsigned int sym_index;
if (scnhdr_int->s_paddr > 0
&& (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0
&& (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0))
if (scnhdr_int->s_paddr > 0
&& (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0
&& (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0))
/* This code used to set scnhdr_int->s_paddr to 0. However,
coff_set_alignment_hook stores s_paddr in virt_size, which
only works if it correctly holds the virtual size of the
/* This code used to set scnhdr_int->s_paddr to 0. However,
coff_set_alignment_hook stores s_paddr in virt_size, which
only works if it correctly holds the virtual size of the
#define SIZEOF_ILF_SYMS (NUM_ILF_SYMS * sizeof (* vars.sym_cache))
#define SIZEOF_ILF_SYM_TABLE (NUM_ILF_SYMS * sizeof (* vars.sym_table))
#define SIZEOF_ILF_SYMS (NUM_ILF_SYMS * sizeof (* vars.sym_cache))
#define SIZEOF_ILF_SYM_TABLE (NUM_ILF_SYMS * sizeof (* vars.sym_table))
#define SIZEOF_IDATA6 (2 + strlen (symbol_name) + 1 + 1)
#define SIZEOF_IDATA7 (strlen (source_dll) + 1 + 1)
#define SIZEOF_IDATA6 (2 + strlen (symbol_name) + 1 + 1)
#define SIZEOF_IDATA7 (strlen (source_dll) + 1 + 1)
-pe_ILF_make_a_symbol_reloc (pe_ILF_vars * vars,
- bfd_vma address,
- bfd_reloc_code_real_type reloc,
- struct bfd_symbol ** sym,
- unsigned int sym_index)
+pe_ILF_make_a_symbol_reloc (pe_ILF_vars * vars,
+ bfd_vma address,
+ bfd_reloc_code_real_type reloc,
+ struct bfd_symbol ** sym,
+ unsigned int sym_index)
{
pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr,
coff_section_data (vars->abfd, sec)->i);
{
pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr,
coff_section_data (vars->abfd, sec)->i);
zero initialised. They are just kept here as reminders. */
/* Initialise the internal symbol structure. */
zero initialised. They are just kept here as reminders. */
/* Initialise the internal symbol structure. */
sym->symbol.name = vars->string_ptr;
sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags;
sym->symbol.section = section;
sym->symbol.name = vars->string_ptr;
sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags;
sym->symbol.section = section;
- unsigned int import_type;
- unsigned int import_name_type;
- asection_ptr id4, id5, id6 = NULL, text = NULL;
- coff_symbol_type ** imp_sym;
- unsigned int imp_index;
+ unsigned int import_type;
+ unsigned int import_name_type;
+ asection_ptr id4, id5, id6 = NULL, text = NULL;
+ coff_symbol_type ** imp_sym;
+ unsigned int imp_index;
/* Upon entry the first six bytes of the ILF header have
already been read. Now read the rest of the header. */
/* Upon entry the first six bytes of the ILF header have
already been read. Now read the rest of the header. */
bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress;
bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size;
bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress;
bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size;
for (section = abfd->sections; section != NULL; section = section->next)
{
if ((addr >= section->vma) && (addr < (section->vma + section->size)))
for (section = abfd->sections; section != NULL; section = section->next)
{
if ((addr >= section->vma) && (addr < (section->vma + section->size)))
- /* PR 20605: Make sure that the data is really there. */
- if (dataoff + size > section->size)
+ /* PR 20605 and 22373: Make sure that the data is really there.
+ Note - since we are dealing with unsigned quantities we have
+ to be careful to check for potential overflows. */
+ if (dataoff >= section->size
+ || size > section->size - dataoff)
/* Read the whole section. */
if (!bfd_malloc_and_get_section (abfd, section, &data))
{
/* Read the whole section. */
if (!bfd_malloc_and_get_section (abfd, section, &data))
{
_bfd_XXi_swap_debugdir_in (abfd, ext, &idd);
if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW)
_bfd_XXi_swap_debugdir_in (abfd, ext, &idd);
if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW)
- {
- char buffer[256 + 1];
- CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer;
-
- /*
- The debug entry doesn't have to have to be in a section, in which
- case AddressOfRawData is 0, so always use PointerToRawData.
- */
- if (_bfd_XXi_slurp_codeview_record (abfd,
- (file_ptr) idd.PointerToRawData,
- idd.SizeOfData, cvinfo))
- {
- struct bfd_build_id* build_id = bfd_alloc (abfd,
- sizeof (struct bfd_build_id) + cvinfo->SignatureLength);
- if (build_id)
- {
- build_id->size = cvinfo->SignatureLength;
- memcpy(build_id->data, cvinfo->Signature,
- cvinfo->SignatureLength);
- abfd->build_id = build_id;
- }
- }
- break;
- }
+ {
+ char buffer[256 + 1];
+ CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer;
+
+ /*
+ The debug entry doesn't have to have to be in a section, in which
+ case AddressOfRawData is 0, so always use PointerToRawData.
+ */
+ if (_bfd_XXi_slurp_codeview_record (abfd,
+ (file_ptr) idd.PointerToRawData,
+ idd.SizeOfData, cvinfo))
+ {
+ struct bfd_build_id* build_id = bfd_alloc (abfd,
+ sizeof (struct bfd_build_id) + cvinfo->SignatureLength);
+ if (build_id)
+ {
+ build_id->size = cvinfo->SignatureLength;
+ memcpy(build_id->data, cvinfo->Signature,
+ cvinfo->SignatureLength);
+ abfd->build_id = build_id;
+ }
+ }
+ break;
+ }
struct external_PEI_IMAGE_hdr image_hdr;
struct internal_filehdr internal_f;
struct internal_aouthdr internal_a;
struct external_PEI_IMAGE_hdr image_hdr;
struct internal_filehdr internal_f;
struct internal_aouthdr internal_a;
/* There are really two magic numbers involved; the magic number
that says this is a NT executable (PEI) and the magic number that
/* There are really two magic numbers involved; the magic number
that says this is a NT executable (PEI) and the magic number that
the e_magic field. The latter is stored in the f_magic field.
If the NT magic number isn't valid, the architecture magic number
could be mimicked by some other field (specifically, the number
the e_magic field. The latter is stored in the f_magic field.
If the NT magic number isn't valid, the architecture magic number
could be mimicked by some other field (specifically, the number
correctly for a PEI file, check the e_magic number here, and, if
it doesn't match, clobber the f_magic number so that we don't get
a false match. */
correctly for a PEI file, check the e_magic number here, and, if
it doesn't match, clobber the f_magic number so that we don't get
a false match. */
result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f,
result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f,