From: Alan Modra Date: Tue, 1 Sep 2020 03:08:03 +0000 (+0930) Subject: arm: ubsan: shift exponent 4G X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=821e059c2626fb0b2ee91898b1c74ea9636c6175;p=binutils-gdb.git arm: ubsan: shift exponent 4G * 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/ChangeLog b/bfd/ChangeLog index 1d65c6829f5..4c152f51830 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2020-09-01 Alan Modra + + * 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. + 2020-09-01 Alan Modra PR 26429 diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 6202695ed30..2f6bd885550 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 7d3479acef4..b17c5e64ec9 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