fix ld/354

Alan Modra amodra@bigpond.net.au
Mon Oct 11 04:53:00 GMT 2004


	* elflink.c (elf_link_input_bfd): Check that relocs in SEC_ALLOC
	sections do not reference symbols in non-SEC_ALLOC sections.

Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.106
diff -u -p -r1.106 elflink.c
--- bfd/elflink.c	11 Oct 2004 01:13:10 -0000	1.106
+++ bfd/elflink.c	11 Oct 2004 04:45:06 -0000
@@ -6788,6 +6788,21 @@ elf_link_input_bfd (struct elf_final_lin
 		      rel->r_info &= r_type_mask;
 		      rel->r_addend = 0;
 		    }
+
+		  /* Check that loaded segments don't reference symbols
+		     in non-loaded segments.  */
+		  if ((o->flags & SEC_ALLOC) != 0
+		      && sec != NULL
+		      && !bfd_is_abs_section (sec)
+		      && !elf_discarded_section (sec)
+		      && sec->output_section != NULL
+		      && (sec->output_section->flags & SEC_ALLOC) == 0)
+		    {
+		      (*_bfd_error_handler)
+			(_("`%s' referenced in section `%A' of %B: "
+			   "defined in non-loaded section `%A' of %B\n"),
+			 o, input_bfd, sec, sec->owner, sym_name);
+		    }
 		}
 	    }
 

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list