diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-01-08 21:38:39 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-01-08 21:38:51 -0800 |
commit | b1b29aa51a6a67d5e35391ad31a80765839d6eb4 (patch) | |
tree | 385666f3042415bebce50f6e6285b34b9bb40975 /bfd/elflink.c | |
parent | aae7fcb8d755a2eb3f32a3f945a4e8f30cf5c5e2 (diff) | |
download | binutils-gdb-b1b29aa51a6a67d5e35391ad31a80765839d6eb4.tar.gz |
elf: Verify section size for mixed ordered/unordered inputs
When fixing up SHF_LINK_ORDER, issue a fatal error if the output section
size is increased. Otherwise, bfd_set_section_contents will fail later
when attempting to write contents past the end of the output section.
PR ld/26256
PR ld/27160
* elflink.c (elf_fixup_link_order): Verify that fixing up
SHF_LINK_ORDER doesn't increase the output section size.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r-- | bfd/elflink.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index a7c952b6fc1..acc959d526a 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -12039,6 +12039,14 @@ elf_fixup_link_order (struct bfd_link_info *info, bfd *abfd, asection *o) offset = sections[n]->offset + sections[n]->size; free (sections); + + /* Verify that fixing up SHF_LINK_ORDER doesn't increase the section + size. */ + if (offset > o->size) + info->callbacks->einfo + (_("%F%P: %pA has ordered sections with incompatible alignments\n"), + o); + return TRUE; } |