[PATCH 4/4] or1k: Fail link if the PLT relocation overflows

Stafford Horne shorne@gmail.com
Mon Apr 19 00:05:24 GMT 2021


bfd/ChangeLog:

	PR 27746
	* elf32-or1k.c (or1k_elf_finish_dynamic_symbol): Add condition
	to check and fail if the PLT relocation overflows.
---
 bfd/elf32-or1k.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
index 1a5b3319646..6afacfa57cf 100644
--- a/bfd/elf32-or1k.c
+++ b/bfd/elf32-or1k.c
@@ -2453,6 +2453,14 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
       got_offset = (plt_index + 3) * 4;
       got_addr = got_base_addr + got_offset;
 
+      if (!htab->saw_gotha && plt_reloc > 0xffff)
+	{
+	  _bfd_error_handler (_("%pB: plt relocation overflow when writing %s"),
+		              output_bfd, h->root.root.string);
+	  bfd_set_error (bfd_error_bad_value);
+	  return false;
+	}
+
       /* Fill in the entry in the procedure linkage table.  */
       if (htab->saw_plta)
 	{
-- 
2.26.2



More information about the Binutils mailing list