This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: ld.gold: internal error in make_view, at fileread.cc:458
- From: Ian Lance Taylor <iant at google dot com>
- To: Arkadiusz Miskiewicz <arekm at maven dot pl>
- Cc: bug-binutils at gnu dot org, binutils at sourceware dot org
- Date: Sun, 29 May 2011 10:18:08 -0700
- Subject: Re: ld.gold: internal error in make_view, at fileread.cc:458
- References: <201105272232.18025.arekm@maven.pl>
Arkadiusz Miskiewicz <arekm@maven.pl> writes:
> uClibc does one test and checks exit status. For gold it causes internal
> error.
>
> binutils 2.21.51.0.9 on x86_64 linux.
>
> $ ld.gold --hash-style=gnu -o /dev/null -b binary /dev/null
> ld.gold: internal error in make_view, at fileread.cc:458
> zsh: exit 1 ld.gold --hash-style=gnu -o /dev/null -b binary /dev/null
>
> $ ld.bfd --hash-style=gnu -o /dev/null -b binary /dev/null
> ld.bfd: warning: cannot find entry symbol _start; not setting start address
Thanks for the bug report. Fixed with this patch, committed to both
mainline and the 2.21 branch.
Ian
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.
Index: binary.cc
===================================================================
RCS file: /cvs/src/src/gold/binary.cc,v
retrieving revision 1.4
diff -p -u -r1.4 binary.cc
--- binary.cc 7 Feb 2009 01:03:32 -0000 1.4
+++ binary.cc 29 May 2011 17:08:52 -0000
@@ -132,7 +132,11 @@ Binary_to_elf::sized_convert(const 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*
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,