aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2018-12-07 12:59:04 -0800
committerMax Filippov <jcmvbkbc@gmail.com>2018-12-11 14:21:39 -0800
commit00863b8e40a0afd0daf0925acf3f7c794dfd9c73 (patch)
tree8212f6293fe9fd89b0370776355ee05a83bef317
parent750b258ef80992e76a3b03fe57dc9517e63de7f5 (diff)
bfd: xtensa: ignore overflow in hight part of const16 relocation
32-bit constants loaded by two const16 opcodes that involve relocation (e.g. calculated as a sum of a symbol and a constant) may overflow, resulting in linking error with the following message: dangerous relocation: const16: cannot encode: (_start+0x70000000) They should wrap around instead. Limit const16 opcode immediate field to 16 least significant bits to implement this wrap around. bfd/ 2018-12-11 Max Filippov <jcmvbkbc@gmail.com> * elf32-xtensa.c (elf_xtensa_do_reloc): Limit const16 opcode immediate field to 16 least significant bits.
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/elf32-xtensa.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index b88fe7eb95a..9acd28dc7ba 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2018-12-11 Max Filippov <jcmvbkbc@gmail.com>
+
+ * elf32-xtensa.c (elf_xtensa_do_reloc): Limit const16 opcode
+ immediate field to 16 least significant bits.
+
2018-12-11 H.J. Lu <hongjiu.lu@intel.com>
* elf32-xc16x.c (elf32_xc16x_rtype_to_howto): New function.
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index cf085b7b075..de960cd3b8f 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -1957,8 +1957,9 @@ elf_xtensa_do_reloc (reloc_howto_type *howto,
}
else if (opcode == get_const16_opcode ())
{
- /* ALT used for high 16 bits. */
- newval = relocation >> 16;
+ /* ALT used for high 16 bits.
+ Ignore 32-bit overflow. */
+ newval = (relocation >> 16) & 0xffff;
opnd = 1;
}
else