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 /bfd/section.c | |
| parent | c0157db47e63616660a5dafba8f7e0aa73e82242 (diff) | |
| download | ppe42-binutils-ea882e87442529ff09a3382b23ab8f3594edc31d.tar.gz ppe42-binutils-ea882e87442529ff09a3382b23ab8f3594edc31d.zip | |
* 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.
Diffstat (limited to 'bfd/section.c')
| -rw-r--r-- | bfd/section.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/bfd/section.c b/bfd/section.c index 5a335a6290..dc8225f39d 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; } |

