* section.c (bfd_get_section_contents): Detect and handle the case

where a section has the SEC_IN_MEMORY flag set but no actual
        contents allocated.
This commit is contained in:
Nick Clifton 2009-03-27 11:38:30 +00:00
parent c0157db47e
commit ea882e8744
2 changed files with 16 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2009-03-27 Nick Clifton <nickc@redhat.com>
* section.c (bfd_get_section_contents): Detect and handle the case
where a section has the SEC_IN_MEMORY flag set but no actual
contents allocated.
2009-03-26 Alan Modra <amodra@bigpond.net.au>
PR 6494

View File

@ -1436,6 +1436,16 @@ bfd_get_section_contents (bfd *abfd,
if ((section->flags & SEC_IN_MEMORY) != 0)
{
if (section->contents == NULL)
{
/* This can happen because of errors earlier on in the linking process.
We do not want to seg-fault here, so clear the flag and return an
error code. */
section->flags &= ~ SEC_IN_MEMORY;
bfd_set_error (bfd_error_invalid_operation);
return FALSE;
}
memcpy (location, section->contents + offset, (size_t) count);
return TRUE;
}