This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [arm-gnu] interlinking with other EABI toolchains


Hi Kevin,

For simple tests, I can use the GNU linker to link GNU-compiled and
TI-compiled files.  However, I started applying this to a bigger
project and I'm seeing a crash (SIGSEGV) in the GNU linker.

Although the cause of this problem has now been found (the TI assembler was emitting WEAK symbols in the LOCAL section of the symbol table) this does not excuse the linker - it should never seg fault. Instead it should issue a proper error message and exit without completing the link.


Hence I am going to apply the patch below to fix this fault. With the patch applied I now get:

ld: error: bspSystem.o contains a reloc (0x00000602) for section .data that references a non-existent global symbol
ld: final link failed: Bad value


when attempting to link your test case.

Daniel - I would like this patch to go into the 2.16 branch if there is still time ?

Cheers
  Nick

bfd/ChangeLog
2005-04-27  Nick Clifton  <nickc@redhat.com>

	* elflink.c (elf_link_input_bfd): Handle the case where a badly
	formatted input file results in a reloc which has no associated
	global symbol.

Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.147
diff -c -3 -p -r1.147 elflink.c
*** bfd/elflink.c	25 Apr 2005 14:59:09 -0000	1.147
--- bfd/elflink.c	27 Apr 2005 10:07:21 -0000
*************** elf_link_input_bfd (struct elf_final_lin
*** 7019,7024 ****
--- 7019,7041 ----
  			  && finfo->sections[r_symndx] == NULL))
  		    {
  		      h = sym_hashes[r_symndx - extsymoff];
+ 		      
+ 		      /* Badly formatted input files can contain relocs that
+ 			 reference non-existant symbols.  Check here so that
+ 			 we do not seg fault.  */
+ 		      if (h == NULL)
+ 			{
+ 			  char buffer [32];
+ 
+ 			  sprintf_vma (buffer, rel->r_info);
+ 			  (*_bfd_error_handler)
+ 			    (_("error: %B contains a reloc (0x%s) for section %A "
+ 			       "that references a non-existant global symbol"),
+ 			     input_bfd, o, buffer);
+ 			  bfd_set_error (bfd_error_bad_value);
+ 			  return FALSE;
+ 			}
+ 		      
  		      while (h->root.type == bfd_link_hash_indirect
  			     || h->root.type == bfd_link_hash_warning)
  			h = (struct elf_link_hash_entry *) h->root.u.i.link;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]