diff options
author | Alan Modra <amodra@gmail.com> | 2024-04-04 20:48:14 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2024-04-04 21:02:29 +1030 |
commit | fab240554b76603775e8a0fec45c8b5808380684 (patch) | |
tree | 8fe5b7acb2aeae2119abade1320389b67dc86aa7 /binutils | |
parent | 1bc2544b895f001cef00c9d71e70557dacb8ee55 (diff) | |
download | gdb-fab240554b76603775e8a0fec45c8b5808380684.zip gdb-fab240554b76603775e8a0fec45c8b5808380684.tar.gz gdb-fab240554b76603775e8a0fec45c8b5808380684.tar.bz2 |
Re: Update objcopy's --section-alignment option
ubsan: left shift of 1 by 31 places cannot be represented in type 'int'
* objcopy.c (setup_section): Avoid undefined behaviour when
checking vma and lma for alignment.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/objcopy.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 77ab908..d9abfdf 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -4340,7 +4340,7 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg) and the VMA was not set by the user and the section does not have relocations associated with it then warn the user. */ - if (osection->vma & ((1 << alignment) - 1) + if ((osection->vma & (((bfd_vma) 1 << alignment) - 1)) != 0 && alignment != bfd_section_alignment (isection) && change_section_address == 0 && ! vma_set_by_user @@ -4352,7 +4352,7 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg) /* Similar check for a non-aligned LMA. FIXME: Since this is only an LMA, maybe it does not matter if it is not aligned ? */ - if (osection->lma & ((1 << alignment) - 1) + if ((osection->lma & (((bfd_vma) 1 << alignment) - 1)) != 0 && alignment != bfd_section_alignment (isection) && change_section_address == 0 && ! lma_set_by_user |