PATCH: Disallow IA64 imm relocations against dynamic symbols

H. J. Lu hjl@lucon.org
Thu Jan 15 22:08:00 GMT 2004


The IA64 imm relocations against dynamic symbols aren't supported by
dynamic linker. Linker disallows them in shared libraries. There is
no reason to allow them in executables either.


H.J.
----
2004-01-15  H.J. Lu  <hongjiu.lu@intel.com>

	* elfxx-ia64.c (elfNN_ia64_relocate_section): Disallow imm
	relocations against dynamic symbols.

--- bfd/elfxx-ia64.c.imm	2004-01-13 20:58:07.000000000 -0800
+++ bfd/elfxx-ia64.c	2004-01-15 14:01:37.000000000 -0800
@@ -3987,6 +3987,24 @@ elfNN_ia64_relocate_section (output_bfd,
 
 	      BFD_ASSERT (srel != NULL);
 
+	      switch (r_type)
+		{
+		case R_IA64_IMM14:
+		case R_IA64_IMM22:
+		case R_IA64_IMM64:
+		  /* ??? People shouldn't be doing non-pic code in
+		     shared libraries nor dynamic executables.  */
+		  (*_bfd_error_handler)
+		    (_("%s: non-pic code with imm relocation against dynamic symbol `%s'"),
+		     bfd_archive_filename (input_bfd),
+		     h->root.root.string);
+		  ret_val = FALSE;
+		  continue;
+
+		default:
+		  break;
+		}
+
 	      /* If we don't need dynamic symbol lookup, find a
 		 matching RELATIVE relocation.  */
 	      dyn_r_type = r_type;
@@ -4014,17 +4032,7 @@ elfNN_ia64_relocate_section (output_bfd,
 		      break;
 
 		    default:
-		      /* We can't represent this without a dynamic symbol.
-			 Adjust the relocation to be against an output
-			 section symbol, which are always present in the
-			 dynamic symbol table.  */
-		      /* ??? People shouldn't be doing non-pic code in
-			 shared libraries.  Hork.  */
-		      (*_bfd_error_handler)
-			(_("%s: linking non-pic code in a shared library"),
-			 bfd_archive_filename (input_bfd));
-		      ret_val = FALSE;
-		      continue;
+		      break;
 		    }
 		  dynindx = 0;
 		  addend = value;



More information about the Binutils mailing list