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]

[PATCH] Allow STT_SECTION + offset for SHF_MERGE sections


Hi!

Here is the full reloc -> STT_SECTION sym in SHF_MERGE section patch.
Bootstrapped with --enable-targets=all --enable-64-bit-bfd, no regressions
on i386-redhat-linux, visually tested some programs using SHF_MERGE on i386
and sparc.
Ok to commit?

2001-11-22  Jakub Jelinek  <jakub@redhat.com>

	* elf.c (_bfd_elf_rela_local_sym): New.
	* elflink.h (elf_link_input_bfd): Don't consider empty
	merged sections as removed in relocation tests.
	* elf-bfd.h (_bfd_elf_rela_local_sym): Add prototype.
	* elf32-i386.c (elf_i386_relocate_section): Handle relocs
	against STT_SECTION symbol of SHF_MERGE section.
	* elf32-arm.h (elf32_arm_relocate_section): Likewise.
	* elf32-avr.c (elf32_avr_relocate_section): Call
	_bfd_elf_rela_local_sym.
	* elf32-cris.c (cris_elf_relocate_section): Likewise.
	* elf32-d10v.c (elf32_d10v_relocate_section): Likewise.
	* elf32-fr30.c (fr30_final_link_relocate): Likewise.
	* elf32-h8300.c (elf32_h8_relocate_section): Likewise.
	* elf32-hppa.c (elf32_hppa_relocate_section): Likewise.
	* elf32-i370.c (i370_elf_relocate_section): Likewise.
	* elf32-i860.c (elf32_i860_relocate_section): Likewise.
	* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
	* elf32-m68k.c (elf_m68k_relocate_section): Likewise.
	* elf32-mcore.c (mcore_elf_relocate_section): Likewise.
	* elf32-openrisc.c (openrisc_elf_relocate_section): Likewise.
	* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
	* elf32-s390.c (elf_s390_relocate_section): Likewise.
	* elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
	* elf32-v850.c (v850_elf_relocate_section): Likewise.
	* elf64-alpha.c (elf64_alpha_relocate_section): Likewise.
	* elf64-mmix.c (mmix_elf_relocate_section): Likewise.
	* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
	* elf64-s390.c (elf_s390_relocate_section): Likewise.
	* elf64-sparc.c (sparc64_elf_relocate_section): Likewise.
	* elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
	* elf-hppa.h (elf_hppa_relocate_section): Likewise.
	* elf-m10200.c (mn10200_elf_relocate_section): Likewise.
	* elf-m10300.c (mn10300_elf_relocate_section): Likewise.
	* elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise.
	* elf32-sh.c (sh_elf_relocate_section): Likewise for
	!partial_inplace relocs. Handle relocs against STT_SECTION
	symbol of SHF_MERGE for partial_inplace relocs.

	* config/tc-alpha.c (tc_gen_reloc): Remove SEC_MERGE test.
	* write.c (adjust_reloc_syms): Don't handle relocs against
	SEC_MERGE section symbols specially.
	(fixup_segment): Likewise.

--- bfd/elf.c.jj	Tue Nov 13 18:25:56 2001
+++ bfd/elf.c	Thu Nov 22 11:35:02 2001
@@ -6370,3 +6370,35 @@ _bfd_elf_reloc_type_class (rela)
 {
   return reloc_class_normal;
 }
+
+/* For RELA architectures, return what the relocation value for
+   relocation against local symbol.  */
+
+bfd_vma
+_bfd_elf_rela_local_sym (abfd, sym, sec, rel)
+     bfd *abfd;
+     Elf_Internal_Sym *sym;
+     asection *sec;
+     Elf_Internal_Rela *rel;
+{
+  bfd_vma relocation;
+
+  relocation = (sec->output_section->vma
+		+ sec->output_offset
+		+ sym->st_value);
+  if ((sec->flags & SEC_MERGE)
+      && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+    {
+      asection *msec;
+
+      msec = sec;
+      rel->r_addend =
+	_bfd_merged_section_offset (abfd, &msec,
+				    elf_section_data (sec)->merge_info,
+				    sym->st_value + rel->r_addend,
+				    (bfd_vma) 0)
+	- relocation;
+      rel->r_addend += msec->output_section->vma + msec->output_offset;
+    }
+  return relocation;
+}
--- bfd/elflink.h.jj	Wed Nov 21 16:58:01 2001
+++ bfd/elflink.h	Thu Nov 22 11:19:32 2001
@@ -6317,7 +6317,9 @@ elf_link_input_bfd (finfo, input_bfd)
 			   || h->root.type == bfd_link_hash_defweak)
 			  && ! bfd_is_abs_section (h->root.u.def.section)
 			  && bfd_is_abs_section (h->root.u.def.section
-						 ->output_section))
+						 ->output_section)
+			  && elf_section_data (h->root.u.def.section)->merge_info
+			     == NULL)
 			{
 #if BFD_VERSION_DATE < 20031005
 			  if ((o->flags & SEC_DEBUGGING) != 0)
@@ -6348,7 +6350,8 @@ elf_link_input_bfd (finfo, input_bfd)
 
 		      if (sec != NULL
 			  && ! bfd_is_abs_section (sec)
-			  && bfd_is_abs_section (sec->output_section))
+			  && bfd_is_abs_section (sec->output_section)
+			  && elf_section_data (sec)->merge_info == NULL)
 			{
 #if BFD_VERSION_DATE < 20031005
 			  if ((o->flags & SEC_DEBUGGING) != 0
--- bfd/elf32-i386.c.jj	Wed Nov 21 16:57:53 2001
+++ bfd/elf32-i386.c	Thu Nov 22 11:19:32 2001
@@ -1770,6 +1770,32 @@ elf_i386_relocate_section (output_bfd, i
 	  relocation = (sec->output_section->vma
 			+ sec->output_offset
 			+ sym->st_value);
+	  if ((sec->flags & SEC_MERGE)
+	      && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+	    {
+	      asection *msec;
+	      bfd_vma addend;
+
+	      if (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_merged_section_offset (output_bfd, &msec,
+					    elf_section_data (sec)->merge_info,
+					    sym->st_value + addend, (bfd_vma) 0)
+		- relocation;
+	      addend += msec->output_section->vma + msec->output_offset;
+	      bfd_put_32 (input_bfd, addend, contents + rel->r_offset);
+	    }
 	}
       else
 	{
--- bfd/elf32-avr.c.jj	Fri Oct  5 13:02:02 2001
+++ bfd/elf32-avr.c	Thu Nov 22 11:19:32 2001
@@ -778,9 +778,7 @@ elf32_avr_relocate_section (output_bfd, 
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections [r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 
 	  name = bfd_elf_string_from_elf_section
 	    (input_bfd, symtab_hdr->sh_link, sym->st_name);
--- bfd/elf-bfd.h.jj	Fri Nov 16 21:49:42 2001
+++ bfd/elf-bfd.h	Thu Nov 22 11:27:05 2001
@@ -1140,6 +1140,8 @@ extern void _bfd_elf_fprintf_vma
 
 extern enum elf_reloc_type_class _bfd_elf_reloc_type_class
   PARAMS ((const Elf_Internal_Rela *));
+extern bfd_vma _bfd_elf_rela_local_sym
+  PARAMS ((bfd *, Elf_Internal_Sym *, asection *, Elf_Internal_Rela *));
 
 extern unsigned long bfd_elf_hash
   PARAMS ((const char *));
--- bfd/elf32-cris.c.jj	Tue Nov 13 18:25:56 2001
+++ bfd/elf32-cris.c	Thu Nov 22 11:19:32 2001
@@ -870,9 +870,7 @@ cris_elf_relocate_section (output_bfd, i
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections [r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 
 	  symname = (bfd_elf_string_from_elf_section
 		     (input_bfd, symtab_hdr->sh_link, sym->st_name));
--- bfd/elf32-d10v.c.jj	Fri Oct  5 13:02:02 2001
+++ bfd/elf32-d10v.c	Thu Nov 22 11:19:32 2001
@@ -356,7 +356,7 @@ elf32_d10v_check_relocs (abfd, info, sec
 static boolean
 elf32_d10v_relocate_section (output_bfd, info, input_bfd, input_section,
 			    contents, relocs, local_syms, local_sections)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
+     bfd *output_bfd;
      struct bfd_link_info *info;
      bfd *input_bfd;
      asection *input_section;
@@ -422,9 +422,7 @@ elf32_d10v_relocate_section (output_bfd,
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 	}
       else
 	{
--- bfd/elf32-fr30.c.jj	Fri Oct  5 13:02:02 2001
+++ bfd/elf32-fr30.c	Thu Nov 22 11:19:32 2001
@@ -503,7 +503,7 @@ fr30_final_link_relocate (howto, input_b
 static boolean
 fr30_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 			   contents, relocs, local_syms, local_sections)
-     bfd *                   output_bfd ATTRIBUTE_UNUSED;
+     bfd *                   output_bfd;
      struct bfd_link_info *  info;
      bfd *                   input_bfd;
      asection *              input_section;
@@ -571,9 +571,7 @@ fr30_elf_relocate_section (output_bfd, i
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections [r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 
 	  name = bfd_elf_string_from_elf_section
 	    (input_bfd, symtab_hdr->sh_link, sym->st_name);
--- bfd/elf32-h8300.c.jj	Fri Nov  2 10:58:29 2001
+++ bfd/elf32-h8300.c	Thu Nov 22 11:19:32 2001
@@ -473,9 +473,7 @@ elf32_h8_relocate_section (output_bfd, i
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 	}
       else
 	{
--- bfd/elf32-hppa.c.jj	Wed Nov 21 16:57:53 2001
+++ bfd/elf32-hppa.c	Thu Nov 22 11:44:52 2001
@@ -3650,10 +3650,7 @@ elf32_hppa_relocate_section (output_bfd,
 	  /* This is a local symbol, h defaults to NULL.  */
 	  sym = local_syms + r_symndx;
 	  sym_sec = local_sections[r_symndx];
-	  relocation = ((ELF_ST_TYPE (sym->st_info) == STT_SECTION
-			   ? 0 : sym->st_value)
-			 + sym_sec->output_offset
-			 + sym_sec->output_section->vma);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel);
 	}
       else
 	{
--- bfd/elf32-i370.c.jj	Tue Nov 13 18:25:56 2001
+++ bfd/elf32-i370.c	Thu Nov 22 11:19:32 2001
@@ -1367,9 +1367,8 @@ i370_elf_relocate_section (output_bfd, i
 	  sec = local_sections[r_symndx];
 	  sym_name = "<local symbol>";
 
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+	  addend = rel->r_addend;
 	}
       else
 	{
--- bfd/elf32-i860.c.jj	Fri Oct  5 13:02:09 2001
+++ bfd/elf32-i860.c	Thu Nov 22 11:19:32 2001
@@ -934,9 +934,7 @@ elf32_i860_relocate_section (output_bfd,
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections [r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 
 	  name = bfd_elf_string_from_elf_section
 	    (input_bfd, symtab_hdr->sh_link, sym->st_name);
--- bfd/elf32-m32r.c.jj	Thu Oct 11 12:38:15 2001
+++ bfd/elf32-m32r.c	Thu Nov 22 11:19:32 2001
@@ -1106,9 +1106,16 @@ m32r_elf_relocate_section (output_bfd, i
 	      sym = local_syms + r_symndx;
 	      sec = local_sections[r_symndx];
 	      sym_name = "<local symbol>";
+#ifndef USE_REL
+	      relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+	      addend = rel->r_addend;
+#else
+	      /* FIXME: This won't handle local relocations against SEC_MERGE
+		 symbols.  See elf32-i386.c for how to do this.  */
 	      relocation = (sec->output_section->vma
 			    + sec->output_offset
 			    + sym->st_value);
+#endif
 	    }
 	  else
 	    {
--- bfd/elf32-m68k.c.jj	Tue Nov 13 18:25:56 2001
+++ bfd/elf32-m68k.c	Thu Nov 22 11:19:32 2001
@@ -1389,9 +1389,7 @@ elf_m68k_relocate_section (output_bfd, i
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 	}
       else
 	{
--- bfd/elf32-mcore.c.jj	Fri Oct  5 13:02:09 2001
+++ bfd/elf32-mcore.c	Thu Nov 22 11:19:32 2001
@@ -410,7 +410,7 @@ mcore_elf_unsupported_reloc (abfd, reloc
 static boolean
 mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 			  contents, relocs, local_syms, local_sections)
-     bfd * output_bfd ATTRIBUTE_UNUSED;
+     bfd * output_bfd;
      struct bfd_link_info * info;
      bfd * input_bfd;
      asection * input_section;
@@ -510,9 +510,8 @@ mcore_elf_relocate_section (output_bfd, 
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections [r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+	  addend = rel->r_addend;
 	}
       else
 	{
--- bfd/elf32-openrisc.c.jj	Fri Oct  5 13:02:09 2001
+++ bfd/elf32-openrisc.c	Thu Nov 22 11:19:32 2001
@@ -324,7 +324,7 @@ openrisc_final_link_relocate (howto, inp
 static boolean
 openrisc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 			       contents, relocs, local_syms, local_sections)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
+     bfd *output_bfd;
      struct bfd_link_info *info;
      bfd *input_bfd;
      asection *input_section;
@@ -394,8 +394,7 @@ openrisc_elf_relocate_section (output_bf
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset + sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 
 	  name = bfd_elf_string_from_elf_section
 	    (input_bfd, symtab_hdr->sh_link, sym->st_name);
--- bfd/elf32-ppc.c.jj	Wed Nov 21 16:57:54 2001
+++ bfd/elf32-ppc.c	Thu Nov 22 11:19:32 2001
@@ -2998,9 +2998,8 @@ ppc_elf_relocate_section (output_bfd, in
 	  sec = local_sections[r_symndx];
 	  sym_name = "<local symbol>";
 
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+	  addend = rel->r_addend;
 	  /* Relocs to local symbols are always resolved.  */
 	  will_become_local = 1;
 	}
--- bfd/elf32-s390.c.jj	Fri Nov 16 21:49:43 2001
+++ bfd/elf32-s390.c	Thu Nov 22 11:19:32 2001
@@ -1664,9 +1664,7 @@ elf_s390_relocate_section (output_bfd, i
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 	}
       else
 	{
--- bfd/elf32-sh.c.jj	Tue Nov 13 18:25:59 2001
+++ bfd/elf32-sh.c	Thu Nov 22 11:19:32 2001
@@ -2960,7 +2960,7 @@ sh_elf_discard_copies (h, ignore)
 static boolean
 sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 			 contents, relocs, local_syms, local_sections)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
+     bfd *output_bfd;
      struct bfd_link_info *info;
      bfd *input_bfd;
      asection *input_section;
@@ -3041,7 +3041,6 @@ sh_elf_relocate_section (output_bfd, inf
 	  relocation = (sec->output_section->vma
 			+ sec->output_offset
 			+ sym->st_value);
-
 	  if (info->relocateable)
 	    {
 	      /* This is a relocateable link.  We don't have to change
@@ -3079,6 +3078,37 @@ sh_elf_relocate_section (output_bfd, inf
 
 	      continue;
 	    }
+	  else if (! howto->partial_inplace)
+	    {
+	      relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+	      addend = rel->r_addend;
+	    }
+	  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_merged_section_offset (output_bfd, &msec,
+					    elf_section_data (sec)->merge_info,
+					    sym->st_value + addend, (bfd_vma) 0)
+		- relocation;
+	      addend += msec->output_section->vma + msec->output_offset;
+	      bfd_put_32 (input_bfd, addend, contents + rel->r_offset);
+	      addend = 0;
+	    }
 	}
       else
 	{
--- bfd/elf32-sparc.c.jj	Wed Nov 21 16:57:54 2001
+++ bfd/elf32-sparc.c	Thu Nov 22 11:19:32 2001
@@ -1176,9 +1176,7 @@ elf32_sparc_relocate_section (output_bfd
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 	}
       else
 	{
--- bfd/elf32-v850.c.jj	Wed Nov 21 16:57:56 2001
+++ bfd/elf32-v850.c	Thu Nov 22 11:19:32 2001
@@ -1597,9 +1597,7 @@ v850_elf_relocate_section (output_bfd, i
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 #if 0
 	  {
 	    char * name;
--- bfd/elf64-alpha.c.jj	Wed Nov 21 16:57:57 2001
+++ bfd/elf64-alpha.c	Thu Nov 22 11:19:32 2001
@@ -3318,9 +3318,7 @@ elf64_alpha_relocate_section (output_bfd
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 	}
       else
 	{
--- bfd/elf64-mmix.c.jj	Wed Oct 31 04:07:48 2001
+++ bfd/elf64-mmix.c	Thu Nov 22 11:19:32 2001
@@ -1091,9 +1091,7 @@ mmix_elf_relocate_section (output_bfd, i
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections [r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 
 	  name = bfd_elf_string_from_elf_section
 	    (input_bfd, symtab_hdr->sh_link, sym->st_name);
--- bfd/elf64-ppc.c.jj	Tue Nov 13 18:25:59 2001
+++ bfd/elf64-ppc.c	Thu Nov 22 11:19:32 2001
@@ -3140,9 +3140,8 @@ ppc64_elf_relocate_section (output_bfd, 
 	  sec = local_sections[r_symndx];
 	  sym_name = "<local symbol>";
 
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+	  addend = rel->r_addend;
 	}
       else
 	{
--- bfd/elf64-s390.c.jj	Fri Nov 16 21:49:43 2001
+++ bfd/elf64-s390.c	Thu Nov 22 11:19:32 2001
@@ -1643,9 +1643,7 @@ elf_s390_relocate_section (output_bfd, i
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 	}
       else
 	{
--- bfd/elf64-sparc.c.jj	Wed Nov 21 16:57:58 2001
+++ bfd/elf64-sparc.c	Thu Nov 22 11:19:32 2001
@@ -1969,9 +1969,7 @@ sparc64_elf_relocate_section (output_bfd
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 	}
       else
 	{
--- bfd/elf64-x86-64.c.jj	Tue Nov 13 18:25:59 2001
+++ bfd/elf64-x86-64.c	Thu Nov 22 11:37:59 2001
@@ -1229,9 +1229,7 @@ elf64_x86_64_relocate_section (output_bf
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rela);
 	}
       else
 	{
--- bfd/elf-hppa.h.jj	Fri Oct  5 13:02:02 2001
+++ bfd/elf-hppa.h	Thu Nov 22 11:38:37 2001
@@ -1325,10 +1325,7 @@ elf_hppa_relocate_section (output_bfd, i
 	  /* This is a local symbol.  */
 	  sym = local_syms + r_symndx;
 	  sym_sec = local_sections[r_symndx];
-	  relocation = ((ELF_ST_TYPE (sym->st_info) == STT_SECTION
-			   ? 0 : sym->st_value)
-			 + sym_sec->output_offset
-			 + sym_sec->output_section->vma);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel);
 
 	  /* If this symbol has an entry in the PA64 dynamic hash
 	     table, then get it.  */
--- bfd/elf-m10200.c.jj	Fri Nov  2 10:58:29 2001
+++ bfd/elf-m10200.c	Thu Nov 22 11:19:32 2001
@@ -394,9 +394,7 @@ mn10200_elf_relocate_section (output_bfd
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 	}
       else
 	{
--- bfd/elf-m10300.c.jj	Fri Nov  2 10:58:29 2001
+++ bfd/elf-m10300.c	Thu Nov 22 11:19:32 2001
@@ -610,9 +610,7 @@ mn10300_elf_relocate_section (output_bfd
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
-	  relocation = (sec->output_section->vma
-			+ sec->output_offset
-			+ sym->st_value);
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 	}
       else
 	{
--- bfd/elfxx-ia64.c.jj	Thu Nov 22 11:05:04 2001
+++ bfd/elfxx-ia64.c	Thu Nov 22 11:19:32 2001
@@ -3481,9 +3481,7 @@ elfNN_ia64_relocate_section (output_bfd,
 	  /* Reloc against local symbol.  */
 	  sym = local_syms + r_symndx;
 	  sym_sec = local_sections[r_symndx];
-	  value  = (sym_sec->output_section->vma
-		    + sym_sec->output_offset
-		    + sym->st_value);
+	  value = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel);
 	}
       else
 	{
--- bfd/elf32-arm.h.jj	Tue Nov 13 18:25:56 2001
+++ bfd/elf32-arm.h	Thu Nov 22 11:19:32 2001
@@ -1858,9 +1858,51 @@ elf32_arm_relocate_section (output_bfd, 
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
+#ifdef USE_REL
 	  relocation = (sec->output_section->vma
 			+ sec->output_offset
 			+ sym->st_value);
+	  if ((sec->flags & SEC_MERGE)
+		   && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+	    {
+	      asection *msec;
+	      bfd_vma addend, value;
+
+	      if (howto->rightshift)
+		{
+		  (*_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;
+		}
+
+	      value = bfd_get_32 (input_bfd, contents + rel->r_offset);
+
+	      /* Get the (signed) value from the instruction.  */
+	      addend = value & howto->src_mask;
+	      if (addend & ((howto->src_mask + 1) >> 1))
+		{
+		  bfd_signed_vma mask;
+
+		  mask = -1;
+		  mask &= ~ howto->src_mask;
+		  addend |= mask;
+		}
+	      msec = sec;
+	      addend =
+		_bfd_merged_section_offset (output_bfd, &msec,
+					    elf_section_data (sec)->merge_info,
+					    sym->st_value + addend, (bfd_vma) 0)
+		- relocation;
+	      addend += msec->output_section->vma + msec->output_offset;
+	      value = (value & ~ howto->dst_mask) | (addend & howto->dst_mask);
+	      bfd_put_32 (input_bfd, value, contents + rel->r_offset);
+	    }
+#else
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+#endif
 	}
       else
 	{
--- gas/config/tc-alpha.c.jj	Thu Nov 22 00:08:06 2001
+++ gas/config/tc-alpha.c	Thu Nov 22 11:19:49 2001
@@ -1507,8 +1507,7 @@ tc_gen_reloc (sec, fixp)
        * at assembly time.  bfd_perform_reloc doesn't know about this sort
        * of thing, and as a result we need to fake it out here.
        */
-      if ((S_IS_EXTERN (fixp->fx_addsy) || S_IS_WEAK (fixp->fx_addsy)
-	   || (S_GET_SEGMENT (fixp->fx_addsy)->flags & SEC_MERGE))
+      if ((S_IS_EXTERN (fixp->fx_addsy) || S_IS_WEAK (fixp->fx_addsy))
 	  && !S_IS_COMMON (fixp->fx_addsy))
 	reloc->addend -= symbol_get_bfdsym (fixp->fx_addsy)->value;
 #endif
--- gas/write.c.jj	Thu Nov 22 00:08:05 2001
+++ gas/write.c	Thu Nov 22 11:19:49 2001
@@ -873,13 +873,6 @@ adjust_reloc_syms (abfd, sec, xxx)
 	    symbol_mark_used_in_reloc (fixp->fx_addsy);
 	    goto done;
 	  }
-
-	/* Never adjust a reloc against local symbol in a merge section.  */
-	if (symsec->flags & SEC_MERGE)
-	  {
-	    symbol_mark_used_in_reloc (fixp->fx_addsy);
-	    goto done;
-	  }
 #endif
 
 	/* Is there some other reason we can't adjust this one?  (E.g.,
@@ -2815,9 +2808,6 @@ fixup_segment (fixP, this_segment_type)
 	      else if (add_symbol_segment == undefined_section
 #ifdef BFD_ASSEMBLER
 		       || bfd_is_com_section (add_symbol_segment)
-		       || (bfd_get_section_flags (stdoutput,
-						  add_symbol_segment)
-			   & SEC_MERGE) != 0
 #endif
 		       )
 		{


	Jakub


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