aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog8
-rw-r--r--bfd/elfxx-mips.c17
2 files changed, 22 insertions, 3 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index b84a3d1..6820732 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,13 @@
2018-02-19 Maciej W. Rozycki <macro@mips.com>
+ * elfxx-mips.c (_bfd_mips_elf_always_size_sections): Set
+ SEC_FIXED_SIZE and SEC_HAS_CONTENTS flags for `.reginfo' and
+ `.MIPS.abiflags' sections.
+ (_bfd_mips_elf_final_link): Avoid reading beyond `.reginfo'
+ section's end.
+
+2018-02-19 Maciej W. Rozycki <macro@mips.com>
+
* section.c (SEC_FIXED_SIZE): New macro.
* bfd-in2.h: Regenerate.
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 211f6f9..1b24f66 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -9294,12 +9294,19 @@ _bfd_mips_elf_always_size_sections (bfd *output_bfd,
/* The .reginfo section has a fixed size. */
sect = bfd_get_section_by_name (output_bfd, ".reginfo");
if (sect != NULL)
- bfd_set_section_size (output_bfd, sect, sizeof (Elf32_External_RegInfo));
+ {
+ bfd_set_section_size (output_bfd, sect, sizeof (Elf32_External_RegInfo));
+ sect->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS;
+ }
/* The .MIPS.abiflags section has a fixed size. */
sect = bfd_get_section_by_name (output_bfd, ".MIPS.abiflags");
if (sect != NULL)
- bfd_set_section_size (output_bfd, sect, sizeof (Elf_External_ABIFlags_v0));
+ {
+ bfd_set_section_size (output_bfd, sect,
+ sizeof (Elf_External_ABIFlags_v0));
+ sect->flags |= SEC_FIXED_SIZE | SEC_HAS_CONTENTS;
+ }
hti.info = info;
hti.output_bfd = output_bfd;
@@ -14368,6 +14375,7 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info)
bfd *input_bfd;
Elf32_External_RegInfo ext;
Elf32_RegInfo sub;
+ bfd_size_type sz;
if (p->type != bfd_indirect_link_order)
{
@@ -14379,8 +14387,11 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info)
input_section = p->u.indirect.section;
input_bfd = input_section->owner;
+ sz = (input_section->size < sizeof (ext)
+ ? input_section->size : sizeof (ext));
+ memset (&ext, 0, sizeof (ext));
if (! bfd_get_section_contents (input_bfd, input_section,
- &ext, 0, sizeof ext))
+ &ext, 0, sz))
return FALSE;
bfd_mips_elf32_swap_reginfo_in (input_bfd, &ext, &sub);