diff options
author | Alan Modra <amodra@gmail.com> | 2020-09-01 08:59:05 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-09-01 16:02:48 +0930 |
commit | f911bb2201c5642151d06622e6ad3d20d5d8cc7b (patch) | |
tree | 92118da533f94edc63a381d4b7f00a2c9b953544 | |
parent | 00c91124d44f799a4fb9cd45a0ef44dc47ab1b1a (diff) | |
download | gdb-f911bb2201c5642151d06622e6ad3d20d5d8cc7b.zip gdb-f911bb2201c5642151d06622e6ad3d20d5d8cc7b.tar.gz gdb-f911bb2201c5642151d06622e6ad3d20d5d8cc7b.tar.bz2 |
PR26429 UBSAN: elf32-arm.c load /store misaligned address
PR 26429
* elf32-arm.c (elf32_arm_allocate_local_sym_info): Allocate arrays
in descending order of alignment.
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/elf32-arm.c | 29 |
2 files changed, 27 insertions, 8 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 2091870..1d65c68 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,11 @@ 2020-09-01 Alan Modra <amodra@gmail.com> + PR 26429 + * elf32-arm.c (elf32_arm_allocate_local_sym_info): Allocate arrays + in descending order of alignment. + +2020-09-01 Alan Modra <amodra@gmail.com> + PR 26423 * elf32-arm.c (calculate_group_reloc_mask): Use 3u in shift. diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 4366b76..6202695 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -3593,27 +3593,40 @@ elf32_arm_allocate_local_sym_info (bfd *abfd) num_syms = elf_tdata (abfd)->symtab_hdr.sh_info; size = num_syms * (sizeof (bfd_signed_vma) - + sizeof (struct arm_local_iplt_info *) + sizeof (bfd_vma) - + sizeof (char) - + sizeof (struct fdpic_local)); + + sizeof (struct arm_local_iplt_info *) + + sizeof (struct fdpic_local) + + sizeof (char)); data = bfd_zalloc (abfd, size); if (data == NULL) return FALSE; - elf32_arm_local_fdpic_cnts (abfd) = (struct fdpic_local *) data; - data += num_syms * sizeof (struct fdpic_local); - + /* It is important that these all be allocated in descending + order of required alignment, so that arrays allocated later + will be sufficiently aligned. */ elf_local_got_refcounts (abfd) = (bfd_signed_vma *) data; data += num_syms * sizeof (bfd_signed_vma); + elf32_arm_local_tlsdesc_gotent (abfd) = (bfd_vma *) data; + data += num_syms * sizeof (bfd_vma); + elf32_arm_local_iplt (abfd) = (struct arm_local_iplt_info **) data; data += num_syms * sizeof (struct arm_local_iplt_info *); - elf32_arm_local_tlsdesc_gotent (abfd) = (bfd_vma *) data; - data += num_syms * sizeof (bfd_vma); + elf32_arm_local_fdpic_cnts (abfd) = (struct fdpic_local *) data; + data += num_syms * sizeof (struct fdpic_local); elf32_arm_local_got_tls_type (abfd) = data; +#if GCC_VERSION >= 3000 + BFD_ASSERT (__alignof__ (*elf32_arm_local_tlsdesc_gotent (abfd)) + <= __alignof__ (*elf_local_got_refcounts (abfd))); + BFD_ASSERT (__alignof__ (*elf32_arm_local_iplt (abfd)) + <= __alignof__ (*elf32_arm_local_tlsdesc_gotent (abfd))); + BFD_ASSERT (__alignof__ (*elf32_arm_local_fdpic_cnts (abfd)) + <= __alignof__ (*elf32_arm_local_iplt (abfd))); + BFD_ASSERT (__alignof__ (*elf32_arm_local_got_tls_type (abfd)) + <= __alignof__ (*elf32_arm_local_fdpic_cnts (abfd))); +#endif } return TRUE; } |