diff options
author | Nick Clifton <nickc@redhat.com> | 2009-03-27 11:38:30 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2009-03-27 11:38:30 +0000 |
commit | ea882e87442529ff09a3382b23ab8f3594edc31d (patch) | |
tree | 924ae7cc415a6b28fd388eee540b0f0552703d7b | |
parent | c0157db47e63616660a5dafba8f7e0aa73e82242 (diff) | |
download | gdb-ea882e87442529ff09a3382b23ab8f3594edc31d.zip gdb-ea882e87442529ff09a3382b23ab8f3594edc31d.tar.gz gdb-ea882e87442529ff09a3382b23ab8f3594edc31d.tar.bz2 |
* 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.
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/section.c | 10 |
2 files changed, 16 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 11a0acb..1fcef7b 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -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 diff --git a/bfd/section.c b/bfd/section.c index 5a335a6..dc8225f 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -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; } |