aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-08-31 11:38:05 +0930
committerAlan Modra <amodra@gmail.com>2020-08-31 20:28:10 +0930
commit227d539b17c60a74c583dc66a2c0467243eb4bb2 (patch)
tree425307d891720f74dab29a3c2c2ce4fe41f552e3
parent1a211fc7d87dc92c2c91d24d0424d8f0485587f9 (diff)
downloadgdb-227d539b17c60a74c583dc66a2c0467243eb4bb2.zip
gdb-227d539b17c60a74c583dc66a2c0467243eb4bb2.tar.gz
gdb-227d539b17c60a74c583dc66a2c0467243eb4bb2.tar.bz2
PR26476, PR26477 UBSAN: elfxx-mips.c:2695,5370 cannot be represented
PR 26476 PR 26477 * elfxx-mips.c (CRINFO_CTYPE, CRINFO_RTYPE, CRINFO_DIST2TO), (CRINFO_RELVADDR): Make unsigned. (mips_elf_nullify_got_load): Use unsigned constant when shifting into sign bit.
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/elfxx-mips.c10
2 files changed, 14 insertions, 5 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index f972a5a..ae405e8 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,14 @@
2020-08-31 Alan Modra <amodra@gmail.com>
+ PR 26476
+ PR 26477
+ * elfxx-mips.c (CRINFO_CTYPE, CRINFO_RTYPE, CRINFO_DIST2TO),
+ (CRINFO_RELVADDR): Make unsigned.
+ (mips_elf_nullify_got_load): Use unsigned constant when shifting
+ into sign bit.
+
+2020-08-31 Alan Modra <amodra@gmail.com>
+
PR 26466
* mep-relocs.pl (emit_apply): Handle HI16S adjustment. Use "u"
variable and rewrite signed overflow check.
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index bc08435..c0970fb 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -698,13 +698,13 @@ typedef struct
/* These are the constants used to swap the bitfields in a crinfo. */
-#define CRINFO_CTYPE (0x1)
+#define CRINFO_CTYPE (0x1U)
#define CRINFO_CTYPE_SH (31)
-#define CRINFO_RTYPE (0xf)
+#define CRINFO_RTYPE (0xfU)
#define CRINFO_RTYPE_SH (27)
-#define CRINFO_DIST2TO (0xff)
+#define CRINFO_DIST2TO (0xffU)
#define CRINFO_DIST2TO_SH (19)
-#define CRINFO_RELVADDR (0x7ffff)
+#define CRINFO_RELVADDR (0x7ffffU)
#define CRINFO_RELVADDR_SH (0)
/* A compact relocation info has long (3 words) or short (2 words)
@@ -5367,7 +5367,7 @@ mips_elf_nullify_got_load (bfd *input_bfd, bfd_byte *contents,
if (mips16_reloc_p (r_type)
&& (((x >> 22) & 0x3ff) == 0x3d3 /* LW */
|| ((x >> 22) & 0x3ff) == 0x3c7)) /* LD */
- x = (0x3cd << 22) | (x & (7 << 16)) << 3; /* LI */
+ x = (0x3cdU << 22) | (x & (7 << 16)) << 3; /* LI */
else if (micromips_reloc_p (r_type)
&& ((x >> 26) & 0x37) == 0x37) /* LW/LD */
x = (0xc << 26) | (x & (0x1f << 21)); /* ADDIU */