Skip to content

Commit ea882e8

Browse files
committed
* 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.
1 parent c0157db commit ea882e8

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Diff for: bfd/ChangeLog

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2009-03-27 Nick Clifton <[email protected]>
2+
3+
* section.c (bfd_get_section_contents): Detect and handle the case
4+
where a section has the SEC_IN_MEMORY flag set but no actual
5+
contents allocated.
6+
17
2009-03-26 Alan Modra <[email protected]>
28

39
PR 6494

Diff for: bfd/section.c

+10
Original file line numberDiff line numberDiff line change
@@ -1436,6 +1436,16 @@ bfd_get_section_contents (bfd *abfd,
14361436

14371437
if ((section->flags & SEC_IN_MEMORY) != 0)
14381438
{
1439+
if (section->contents == NULL)
1440+
{
1441+
/* This can happen because of errors earlier on in the linking process.
1442+
We do not want to seg-fault here, so clear the flag and return an
1443+
error code. */
1444+
section->flags &= ~ SEC_IN_MEMORY;
1445+
bfd_set_error (bfd_error_invalid_operation);
1446+
return FALSE;
1447+
}
1448+
14391449
memcpy (location, section->contents + offset, (size_t) count);
14401450
return TRUE;
14411451
}

0 commit comments

Comments
 (0)