diff options
-rw-r--r-- | bfd/ChangeLog | 7 | ||||
-rw-r--r-- | bfd/elf-nacl.c | 10 |
2 files changed, 12 insertions, 5 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index a24957a..4fc9552 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,12 @@ 2020-08-25 Alan Modra <amodra@gmail.com> + PR 26430 + * elf-nacl.c (nacl_modify_segment_map): Correct alloc size and + amount copied for elf_segment_map defined with one element + sections array. + +2020-08-25 Alan Modra <amodra@gmail.com> + PR 26422 * elf32-arm.c (elf32_arm_final_link_relocate): Use the appropriate bfd_get_x size function to read addends out of fields. Apply diff --git a/bfd/elf-nacl.c b/bfd/elf-nacl.c index 3a232df..a7cd827 100644 --- a/bfd/elf-nacl.c +++ b/bfd/elf-nacl.c @@ -156,13 +156,13 @@ nacl_modify_segment_map (bfd *abfd, struct bfd_link_info *info) secdata->this_hdr.sh_addr = sec->vma; secdata->this_hdr.sh_size = sec->size; - newseg = bfd_alloc (abfd, - sizeof *newseg + ((seg->count + 1) - * sizeof (asection *))); + newseg + = bfd_alloc (abfd, (sizeof (*newseg) + + seg->count * sizeof (asection *))); if (newseg == NULL) return FALSE; - memcpy (newseg, seg, - sizeof *newseg + (seg->count * sizeof (asection *))); + memcpy (newseg, seg, (sizeof (*newseg) - sizeof (asection *) + + seg->count * sizeof (asection *))); newseg->sections[newseg->count++] = sec; *m = seg = newseg; } |