diff options
author | Andrew Hsieh <andrewhsieh@google.com> | 2014-12-09 17:57:18 +0800 |
---|---|---|
committer | Andrew Hsieh <andrewhsieh@google.com> | 2014-12-09 19:50:14 +0800 |
commit | 5e8c1cf25beccac1d22d10dc866912394f42771b (patch) | |
tree | ee16b70f804484dc8e434e647e699ab50da2620f /binutils-2.25/bfd/peicode.h | |
parent | 8eebd7953384e6662ca926b003f2cdda8ccd3ee5 (diff) | |
download | toolchain_binutils-5e8c1cf25beccac1d22d10dc866912394f42771b.tar.gz toolchain_binutils-5e8c1cf25beccac1d22d10dc866912394f42771b.tar.bz2 toolchain_binutils-5e8c1cf25beccac1d22d10dc866912394f42771b.zip |
[2.25] sync to a30720e3e633f275250e26f85ccae5dbdddfb6c6
local patches will be re-applied later
commit a30720e3e633f275250e26f85ccae5dbdddfb6c6
Author: Alan Modra <amodra@gmail.com>
Date: Wed Nov 19 10:30:16 2014 +1030
daily update
Change-Id: Ieb2a3f4dd2ecb289ac5305ff08d428b2847494ab
Diffstat (limited to 'binutils-2.25/bfd/peicode.h')
-rw-r--r-- | binutils-2.25/bfd/peicode.h | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/binutils-2.25/bfd/peicode.h b/binutils-2.25/bfd/peicode.h index 64ca0929..83653535 100644 --- a/binutils-2.25/bfd/peicode.h +++ b/binutils-2.25/bfd/peicode.h @@ -1,5 +1,5 @@ /* Support for the generic parts of PE/PEI, for BFD. - Copyright 1995-2013 Free Software Foundation, Inc. + Copyright (C) 1995-2014 Free Software Foundation, Inc. Written by Cygnus Solutions. This file is part of BFD, the Binary File Descriptor library. @@ -271,6 +271,7 @@ pe_mkobject (bfd * abfd) /* in_reloc_p is architecture dependent. */ pe->in_reloc_p = in_reloc_p; + memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); return TRUE; } @@ -567,6 +568,7 @@ pe_ILF_make_a_symbol (pe_ILF_vars * vars, ent->u.syment.n_sclass = sclass; ent->u.syment.n_scnum = section->target_index; ent->u.syment._n._n_n._n_offset = (bfd_hostptr_t) sym; + ent->is_sym = TRUE; sym->symbol.the_bfd = vars->abfd; sym->symbol.name = vars->string_ptr; @@ -1077,7 +1079,7 @@ pe_ILF_build_a_bfd (bfd * abfd, static const bfd_target * pe_ILF_object_p (bfd * abfd) { - bfd_byte buffer[16]; + bfd_byte buffer[14]; bfd_byte * ptr; char * symbol_name; char * source_dll; @@ -1087,17 +1089,13 @@ pe_ILF_object_p (bfd * abfd) unsigned int types; unsigned int magic; - /* Upon entry the first four buyes of the ILF header have + /* Upon entry the first six bytes of the ILF header have already been read. Now read the rest of the header. */ - if (bfd_bread (buffer, (bfd_size_type) 16, abfd) != 16) + if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) return NULL; ptr = buffer; - /* We do not bother to check the version number. - version = H_GET_16 (abfd, ptr); */ - ptr += 2; - machine = H_GET_16 (abfd, ptr); ptr += 2; @@ -1251,7 +1249,7 @@ pe_ILF_object_p (bfd * abfd) static const bfd_target * pe_bfd_object_p (bfd * abfd) { - bfd_byte buffer[4]; + bfd_byte buffer[6]; struct external_PEI_DOS_hdr dos_hdr; struct external_PEI_IMAGE_hdr image_hdr; struct internal_filehdr internal_f; @@ -1260,15 +1258,18 @@ pe_bfd_object_p (bfd * abfd) file_ptr offset; /* Detect if this a Microsoft Import Library Format element. */ + /* First read the beginning of the header. */ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 - || bfd_bread (buffer, (bfd_size_type) 4, abfd) != 4) + || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) { if (bfd_get_error () != bfd_error_system_call) bfd_set_error (bfd_error_wrong_format); return NULL; } - if (H_GET_32 (abfd, buffer) == 0xffff0000) + /* Then check the magic and the version (only 0 is supported). */ + if (H_GET_32 (abfd, buffer) == 0xffff0000 + && H_GET_16 (abfd, buffer + 4) == 0) return pe_ILF_object_p (abfd); if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 @@ -1314,7 +1315,7 @@ pe_bfd_object_p (bfd * abfd) /* Swap file header, so that we get the location for calling real_object_p. */ - bfd_coff_swap_filehdr_in (abfd, (PTR)&image_hdr, &internal_f); + bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); if (! bfd_coff_bad_format_hook (abfd, &internal_f) || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) @@ -1328,16 +1329,21 @@ pe_bfd_object_p (bfd * abfd) if (opt_hdr_size != 0) { - PTR opthdr; + bfd_size_type amt = opt_hdr_size; + void * opthdr; + + /* PR 17521 file: 230-131433-0.004. */ + if (amt < sizeof (PEAOUTHDR)) + amt = sizeof (PEAOUTHDR); - opthdr = bfd_alloc (abfd, opt_hdr_size); + opthdr = bfd_zalloc (abfd, amt); if (opthdr == NULL) return NULL; if (bfd_bread (opthdr, opt_hdr_size, abfd) != (bfd_size_type) opt_hdr_size) return NULL; - bfd_coff_swap_aouthdr_in (abfd, opthdr, (PTR) & internal_a); + bfd_coff_swap_aouthdr_in (abfd, opthdr, & internal_a); } return coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, |