summaryrefslogtreecommitdiff
path: root/bfd/elfcode.h
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/elfcode.h')
-rw-r--r--bfd/elfcode.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index c3ab0536321..4d4cb68164a 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -997,6 +997,19 @@ elf_write_relocs (bfd *abfd, asection *sec, void *data)
return;
}
+#if defined(BFD64) && ARCH_SIZE == 32
+ if (rela_hdr->sh_type == SHT_RELA
+ && ptr->howto->bitsize > 32
+ && ptr->addend - INT32_MIN > UINT32_MAX)
+ {
+ _bfd_error_handler (_("%pB: %pA+%"BFD_VMA_FMT"x: "
+ "relocation addend %"BFD_VMA_FMT"x too large"),
+ abfd, sec, ptr->address, ptr->addend);
+ *failedp = true;
+ bfd_set_error (bfd_error_bad_value);
+ }
+#endif
+
src_rela.r_offset = ptr->address + addr_offset;
src_rela.r_info = ELF_R_INFO (n, ptr->howto->type);
src_rela.r_addend = ptr->addend;