diff options
author | Ian Lance Taylor <ian@airs.com> | 2011-05-29 17:17:57 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2011-05-29 17:17:57 +0000 |
commit | b97f4c0f752f8dbe7d9376a33e7280f7464e9750 (patch) | |
tree | d46b148e6c8d1414da5aa657b9c7bc1814c78561 /gold | |
parent | 252f08f15e43e8b4350bb906fe94e3722c98890a (diff) | |
download | fsf-binutils-gdb-b97f4c0f752f8dbe7d9376a33e7280f7464e9750.zip fsf-binutils-gdb-b97f4c0f752f8dbe7d9376a33e7280f7464e9750.tar.gz fsf-binutils-gdb-b97f4c0f752f8dbe7d9376a33e7280f7464e9750.tar.bz2 |
* binary.cc (Binary_to_elf::sized_convert): Don't crash if the
binary input file is empty.
Diffstat (limited to 'gold')
-rw-r--r-- | gold/ChangeLog | 5 | ||||
-rw-r--r-- | gold/binary.cc | 17 |
2 files changed, 17 insertions, 5 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog index 081f900..96f0949 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,8 @@ +2011-05-29 Ian Lance Taylor <iant@google.com> + + * binary.cc (Binary_to_elf::sized_convert): Don't crash if the + binary input file is empty. + 2011-05-06 Ian Lance Taylor <iant@google.com> * layout.cc (Layout::layout): If the output section flags change, diff --git a/gold/binary.cc b/gold/binary.cc index f14df0d..6cc99a9 100644 --- a/gold/binary.cc +++ b/gold/binary.cc @@ -132,7 +132,11 @@ Binary_to_elf::sized_convert(const Task* task) } section_size_type filesize = convert_to_section_size_type(f.filesize()); - const unsigned char* fileview = f.get_view(0, 0, filesize, false, false); + const unsigned char* fileview; + if (filesize == 0) + fileview = NULL; + else + fileview = f.get_view(0, 0, filesize, false, false); unsigned int align; if (size == 32) @@ -223,10 +227,13 @@ Binary_to_elf::sized_convert(const Task* task) shstrtab.get_strtab_size(), 0, 0, 1, 0, &pout); - memcpy(pout, fileview, filesize); - pout += filesize; - memset(pout, 0, aligned_filesize - filesize); - pout += aligned_filesize - filesize; + if (filesize > 0) + { + memcpy(pout, fileview, filesize); + pout += filesize; + memset(pout, 0, aligned_filesize - filesize); + pout += aligned_filesize - filesize; + } this->write_symbol<size, big_endian>("", &strtab, 0, 0, &pout); this->write_symbol<size, big_endian>(start_symbol_name, &strtab, 0, 1, |