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] R_390_RELATIVE bug fix for s390*.


Hi,
I added a bug fix for the s390 bfds. Relocations against local symbols
of type R_390_8, R_390_16 and R_390_32 (elf64-s390 only) have been
converted to R_390_RELATIVE. Relocations that are to short for
R_390_RELATIVE are now converted to relocations against the start
of the section of the target symbol. 

blue skies,
  Martin.

2003-11-13  Martin Schwidefsky  <schwidefsky@de.ibm.com>

	* elf32-s390.c (elf_s390_relocate_section): Only convert R_390_32
	to R_390_RELAVITE. Convert the other relocations against local
	symbols to relocations against the start of the section.
	* elf64-s390.c (elf_s390_relocate_section): Only convert R_390_64
	to R_390_RELAVITE. Convert the other relocations against local
	symbols to relocations against the start of the section.

diff -urN src/bfd/elf32-s390.c src-s390/bfd/elf32-s390.c
--- src/bfd/elf32-s390.c	2003-11-11 17:56:57.000000000 +0100
+++ src-s390/bfd/elf32-s390.c	2003-11-13 16:38:55.000000000 +0100
@@ -2626,9 +2626,43 @@
 	      else
 		{
 		  /* This symbol is local, or marked to become local.  */
-		  relocate = TRUE;
-		  outrel.r_info = ELF32_R_INFO (0, R_390_RELATIVE);
-		  outrel.r_addend = relocation + rel->r_addend;
+		  if (r_type == R_390_32)
+		    {
+		      relocate = TRUE;
+		      outrel.r_info = ELF32_R_INFO (0, R_390_RELATIVE);
+		      outrel.r_addend = relocation + rel->r_addend;
+		    }
+		  else
+		    {
+		      long sindx;
+
+		      if (h == NULL)
+			sec = local_sections[r_symndx];
+		      else
+			{
+			  BFD_ASSERT (h->root.type == bfd_link_hash_defined
+				      || (h->root.type
+					  == bfd_link_hash_defweak));
+			  sec = h->root.u.def.section;
+			}
+		      if (sec != NULL && bfd_is_abs_section (sec))
+			sindx = 0;
+		      else if (sec == NULL || sec->owner == NULL)
+			{
+			  bfd_set_error(bfd_error_bad_value);
+			  return FALSE;
+			}
+		      else
+			{
+			  asection *osec;
+
+			  osec = sec->output_section;
+			  sindx = elf_section_data (osec)->dynindx;
+			  BFD_ASSERT (sindx > 0);
+			}
+		      outrel.r_info = ELF32_R_INFO (sindx, r_type);
+		      outrel.r_addend = relocation + rel->r_addend;
+		    }
 		}
 
 	      sreloc = elf_section_data (input_section)->sreloc;
diff -urN src/bfd/elf64-s390.c src-s390/bfd/elf64-s390.c
--- src/bfd/elf64-s390.c	2003-11-11 17:56:57.000000000 +0100
+++ src-s390/bfd/elf64-s390.c	2003-11-13 16:38:55.000000000 +0100
@@ -2605,9 +2605,43 @@
 	      else
 		{
 		  /* This symbol is local, or marked to become local.  */
-		  relocate = TRUE;
-		  outrel.r_info = ELF64_R_INFO (0, R_390_RELATIVE);
-		  outrel.r_addend = relocation + rel->r_addend;
+		  if (r_type == R_390_64)
+		    {
+		      relocate = TRUE;
+		      outrel.r_info = ELF64_R_INFO (0, R_390_RELATIVE);
+		      outrel.r_addend = relocation + rel->r_addend;
+		    }
+		  else
+		    {
+		      long sindx;
+
+		      if (h == NULL)
+			sec = local_sections[r_symndx];
+		      else
+			{
+			  BFD_ASSERT (h->root.type == bfd_link_hash_defined
+				      || (h->root.type
+					  == bfd_link_hash_defweak));
+			  sec = h->root.u.def.section;
+			}
+		      if (sec != NULL && bfd_is_abs_section (sec))
+			sindx = 0;
+		      else if (sec == NULL || sec->owner == NULL)
+			{
+			  bfd_set_error(bfd_error_bad_value);
+			  return FALSE;
+			}
+		      else
+			{
+			  asection *osec;
+
+			  osec = sec->output_section;
+			  sindx = elf_section_data (osec)->dynindx;
+			  BFD_ASSERT (sindx > 0);
+			}
+		      outrel.r_info = ELF64_R_INFO (sindx, r_type);
+		      outrel.r_addend = relocation + rel->r_addend;
+		    }
 		}
 
 	      sreloc = elf_section_data (input_section)->sreloc;


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