* arm: ubsan: shift exponent 4G
@ 2020-09-01 6:55 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2020-09-01 6:55 UTC (permalink / raw)
To: binutils
* reloc.c (N_ONES): Handle N=0.
* elf32-arm.c (elf32_arm_howto_table_1): Set complain_overflow_dont
for R_ARM_TLS_DESCSEQ and R_ARM_THM_TLS_DESCSEQ.
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 6202695ed3..2f6bd88555 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -1391,7 +1391,7 @@ static reloc_howto_type elf32_arm_howto_table_1[] =
0, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
- complain_overflow_bitfield,/* complain_on_overflow */
+ complain_overflow_dont,/* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
"R_ARM_TLS_DESCSEQ", /* name */
FALSE, /* partial_inplace */
@@ -1683,7 +1683,7 @@ static reloc_howto_type elf32_arm_howto_table_1[] =
0, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
- complain_overflow_bitfield,/* complain_on_overflow */
+ complain_overflow_dont,/* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
"R_ARM_THM_TLS_DESCSEQ",/* name */
FALSE, /* partial_inplace */
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 7d3479acef..b17c5e64ec 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -432,8 +432,9 @@ DESCRIPTION
.
*/
-/* N_ONES produces N one bits, without overflowing machine arithmetic. */
-#define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1)
+/* N_ONES produces N one bits, without undefined behaviour for N
+ between zero and the number of bits in a bfd_vma. */
+#define N_ONES(n) ((n) == 0 ? 0 : ((bfd_vma) 1 << ((n) - 1) << 1) - 1)
/*
FUNCTION
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-01 6:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 6:55 arm: ubsan: shift exponent 4G Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).