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]

bfd/elf64-sh64.c patch for partial string section merging support


The sh64-elf port does not support string section merging.  This showed up as
a large number of gdb failures with -m5-64media on a toolchain here, because
gdb found out-of-range DW_FORM_strp references in the DWARF2 debug info in
almost every binary.

The sh64-elf port was added to binutils in parallel with the string section
merging support, so it isn't hard to see that this got accidentally missed.

I fixed this by moving some code from elf32-sh.c to elf64-sh64.c with only
minor modification.  I didn't try to fully understand what the code does,
but it is working well.  I get 10 fewer gcc failures, and gdb goes from almost
total failure to 46 failures.  So I think the patch is right.

I suspect the patch is incomplete since I made no attempt to test shared
library/dynamic linking support, and I see other ports have had some string
section merging patches in this area.  I don't have easy access to a system
where I can test or debug these kinds of problems though, so I am not going
to be able to try to fix them.  I'm also told that there are known problems
with the shared library/dynamic linking support, so it doesn't seem worth
the effort of even trying.

I am unable to test this with current BINUTILS/GCC/GDB sources because some
sh64 bits are missing from the public trees.  In particular, the simulator
and dejagnu support.  This was tested on a Red Hat internal tree that is
several months old, but which does have all of the sh64 naughty bits that I
need.  I don't believe that affects the correctness of the patch though.

I plan to check in the patch in a few days unless one of the sh maintainers
wants to comment on it.

2002-10-23  Jim Wilson  <wilson@redhat.com>

	* elf64-sh64.c (sh_elf64_relocate_section): Call
	_bfd_elf_rela_local_sym.  Handle relocs against STT_SECTION symbol
	of SHF_MERGE section.

Index: elf64-sh64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-sh64.c,v
retrieving revision 1.22
diff -p -r1.22 elf64-sh64.c
*** elf64-sh64.c	16 Oct 2002 08:39:37 -0000	1.22
--- elf64-sh64.c	23 Oct 2002 19:55:58 -0000
*************** sh_elf64_relocate_section (output_bfd, i
*** 1588,1593 ****
--- 1588,1622 ----
  
  	      continue;
  	    }
+ 	  else if (! howto->partial_inplace)
+ 	    {
+ 	      relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+ 	      relocation |= ((sym->st_other & STO_SH5_ISA32) != 0);
+ 	    }
+ 	  else if ((sec->flags & SEC_MERGE)
+ 		   && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ 	    {
+ 	      asection *msec;
+ 
+ 	      if (howto->rightshift || howto->src_mask != 0xffffffff)
+ 		{
+ 		  (*_bfd_error_handler)
+ 		    (_("%s(%s+0x%lx): %s relocation against SEC_MERGE section"),
+ 		     bfd_archive_filename (input_bfd),
+ 		     bfd_get_section_name (input_bfd, input_section),
+ 		     (long) rel->r_offset, howto->name);
+ 		  return false;
+ 		}
+ 
+               addend = bfd_get_32 (input_bfd, contents + rel->r_offset);
+               msec = sec;
+               addend =
+ 		_bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend)
+ 		- relocation;
+ 	      addend += msec->output_section->vma + msec->output_offset;
+ 	      bfd_put_32 (input_bfd, addend, contents + rel->r_offset);
+ 	      addend = 0;
+ 	    }
  	}
        else
  	{


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