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]

elf64-ia64 broken + patch



Compiling binutils with 
configure --prefix=/opt/binutils --enable-shared \
--disable-nls \
--enable-build-warnings --enable-targets=all --enable-64-bit-bfd

gives the following error for elf64-ia64:
gcc -DHAVE_CONFIG_H -I. -I/cvs/binutils-gdb-ln/bfd -I. -D_GNU_SOURCE -DTRAD_CORE -I. -I/cvs/binutils-gdb-ln/bfd -I/cvs/binutils-gdb-ln/bfd/../include -I/cvs/binutils-gdb-ln/bfd/../intl -I../intl -W -Wall -g -O2 -c /cvs/binutils-gdb-ln/bfd/elf64-ia64.c  -fPIC -DPIC -o .libs/elf64-ia64.o
/cvs/binutils-gdb-ln/bfd/elf64-ia64.c: In function `elf64_ia64_reloc':
/cvs/binutils-gdb-ln/bfd/elf64-ia64.c:286: warning: unused parameter `abfd'
/cvs/binutils-gdb-ln/bfd/elf64-ia64.c:288: warning: unused parameter `sym'
/cvs/binutils-gdb-ln/bfd/elf64-ia64.c:289: warning: unused parameter `data'
/cvs/binutils-gdb-ln/bfd/elf64-ia64.c: At top level:
/cvs/binutils-gdb-ln/bfd/elf64-ia64.c:356: `R_IA64_SEGBASE' undeclared here (not in a function)
/cvs/binutils-gdb-ln/bfd/elf64-ia64.c:356: initializer element is not constant
/cvs/binutils-gdb-ln/bfd/elf64-ia64.c:356: (near initialization for `ia64_howto_table[37].type')
/cvs/binutils-gdb-ln/bfd/elf64-ia64.c:383: `R_IA64_EPLTMSB' undeclared here (not in a function)
[...]

Richard has fixed elfxx-ia64 with a patch on 2000-11-16 that needed
porting to elf64-ia64.c.  Due to different names I applied the patch
per hand cleanly but I ask that somebody double checks it with
Richard's original patch (subject "ia64 psABI update").  With this
patch, the file can be compiled.  I don't have the possibility to
check that it works actualy.

Btw. why do we have elfNN-ia64 and elf64-ia64?  It seems that they
share lots of code.

Andreas

2000-12-01  Andreas Jaeger  <aj@suse.de>

	* elf64-ia64.c (elf64_ia64_check_relocs): Handle IPLT relocs.
        (allocate_dynrel_entries): Likewise.
        (elf64_ia64_relocate_section): Likewise.  Set REL addends correctly.
        (set_pltoff_entry): Likewise.
        (ia64_howto_table): Remove R_IA64_SEGBASE, and R_IA64_EPLT[ML]SB
        (elf64_ia64_reloc_type_lookup): Likewise.
        (elf64_ia64_install_value): Likewise.
        (elf64_ia64_relocate_section): Likewise.
	Apply patch from Richard Henderson of 2000-11-16 for elfxx-ia64.c.

Index: bfd/elf64-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/Attic/elf64-ia64.c,v
retrieving revision 1.11
diff -u -r1.11 elf64-ia64.c
--- elf64-ia64.c	2000/11/30 19:16:54	1.11
+++ elf64-ia64.c	2000/12/01 07:01:37
@@ -353,7 +353,6 @@
     IA64_HOWTO (R_IA64_LTOFF_FPTR64MSB, "LTOFF_FPTR64MSB", 4, false, true),
     IA64_HOWTO (R_IA64_LTOFF_FPTR64LSB, "LTOFF_FPTR64LSB", 4, false, true),
 
-    IA64_HOWTO (R_IA64_SEGBASE,	    "SEGBASE",	   4, false, true),
     IA64_HOWTO (R_IA64_SEGREL32MSB, "SEGREL32MSB", 2, false, true),
     IA64_HOWTO (R_IA64_SEGREL32LSB, "SEGREL32LSB", 2, false, true),
     IA64_HOWTO (R_IA64_SEGREL64MSB, "SEGREL64MSB", 4, false, true),
@@ -380,8 +379,6 @@
 
     IA64_HOWTO (R_IA64_IPLTMSB,	    "IPLTMSB",	   4, false, true),
     IA64_HOWTO (R_IA64_IPLTLSB,	    "IPLTLSB",	   4, false, true),
-    IA64_HOWTO (R_IA64_EPLTMSB,	    "EPLTMSB",	   4, false, true),
-    IA64_HOWTO (R_IA64_EPLTLSB,	    "EPLTLSB",	   4, false, true),
     IA64_HOWTO (R_IA64_COPY,	    "COPY",	   4, false, true),
     IA64_HOWTO (R_IA64_LTOFF22X,    "LTOFF22X",	   0, false, true),
     IA64_HOWTO (R_IA64_LDXMOV,	    "LDXMOV",	   0, false, true),
@@ -476,7 +473,6 @@
     case BFD_RELOC_IA64_LTOFF_FPTR64MSB: rtype = R_IA64_LTOFF_FPTR64MSB; break;
     case BFD_RELOC_IA64_LTOFF_FPTR64LSB: rtype = R_IA64_LTOFF_FPTR64LSB; break;
 
-    case BFD_RELOC_IA64_SEGBASE:	rtype = R_IA64_SEGBASE; break;
     case BFD_RELOC_IA64_SEGREL32MSB:	rtype = R_IA64_SEGREL32MSB; break;
     case BFD_RELOC_IA64_SEGREL32LSB:	rtype = R_IA64_SEGREL32LSB; break;
     case BFD_RELOC_IA64_SEGREL64MSB:	rtype = R_IA64_SEGREL64MSB; break;
@@ -499,8 +495,6 @@
 
     case BFD_RELOC_IA64_IPLTMSB:	rtype = R_IA64_IPLTMSB; break;
     case BFD_RELOC_IA64_IPLTLSB:	rtype = R_IA64_IPLTLSB; break;
-    case BFD_RELOC_IA64_EPLTMSB:	rtype = R_IA64_EPLTMSB; break;
-    case BFD_RELOC_IA64_EPLTLSB:	rtype = R_IA64_EPLTLSB; break;
     case BFD_RELOC_IA64_COPY:		rtype = R_IA64_COPY; break;
     case BFD_RELOC_IA64_LTOFF22X:	rtype = R_IA64_LTOFF22X; break;
     case BFD_RELOC_IA64_LDXMOV:		rtype = R_IA64_LDXMOV; break;
@@ -1864,6 +1858,14 @@
 	  dynrel_type = R_IA64_DIR64LSB;
 	  break;
 
+	case R_IA64_IPLTMSB:
+	case R_IA64_IPLTLSB:
+	  /* Shared objects will always need at least a REL relocation.  */
+	  if (info->shared || maybe_dynamic)
+	    need_entry = NEED_DYNREL;
+	  dynrel_type = R_IA64_IPLTLSB;
+	  break;
+
 	case R_IA64_PCREL22:
 	case R_IA64_PCREL64I:
 	case R_IA64_PCREL32MSB:
@@ -2189,6 +2191,8 @@
 
   for (rent = dyn_i->reloc_entries; rent; rent = rent->next)
     {
+      int count = rent->count;
+
       switch (rent->type)
 	{
 	case R_IA64_FPTR64LSB:
@@ -2208,6 +2212,16 @@
 	      && !shared)
 	    continue;
 	  break;
+	case R_IA64_IPLTLSB:
+	  if (!dynamic_symbol && !shared)
+	    continue;
+	  /* Use two REL relocations for IPLT relocations
+	     against local symbols.  */
+	  if (!dynamic_symbol)
+	    count *= 2;
+	  break;
+	default:
+	  abort ();
 	}
       rent->srel->_raw_size += sizeof (Elf64_External_Rela) * rent->count;
     }
@@ -2648,26 +2662,7 @@
       size = 8; bigendian = 0;
       break;
 
-      /* Unsupported / Dynamic relocations.  */
 
-    case R_IA64_REL32MSB:
-    case R_IA64_REL32LSB:
-    case R_IA64_REL64MSB:
-    case R_IA64_REL64LSB:
-
-    case R_IA64_IPLTMSB:
-    case R_IA64_IPLTLSB:
-    case R_IA64_EPLTMSB:
-    case R_IA64_EPLTLSB:
-    case R_IA64_COPY:
-
-    case R_IA64_SEGBASE:
-
-    case R_IA64_TPREL22:
-    case R_IA64_TPREL64MSB:
-    case R_IA64_TPREL64LSB:
-    case R_IA64_LTOFF_TP22:
-
     default:
       return bfd_reloc_notsupported;
     }
@@ -2947,11 +2942,13 @@
   if ((! dyn_i->want_plt || is_plt)
       && !dyn_i->pltoff_done)
     {
+      bfd_vma gp = _bfd_get_gp_value (abfd);
+
       /* Fill in the function descriptor.  */
       bfd_put_64 (abfd, value, pltoff_sec->contents + dyn_i->pltoff_offset);
-      bfd_put_64 (abfd, _bfd_get_gp_value (abfd),
-		  pltoff_sec->contents + dyn_i->pltoff_offset + 8);
+      bfd_put_64 (abfd, gp, pltoff_sec->contents + dyn_i->pltoff_offset + 8);
 
+
       /* Install dynamic relocations if needed.  */
       if (!is_plt && info->shared)
 	{
@@ -2965,11 +2962,11 @@
 	  elf64_ia64_install_dyn_reloc (abfd, NULL, pltoff_sec,
 					ia64_info->rel_pltoff_sec,
 					dyn_i->pltoff_offset,
-					dyn_r_type, 0, 0);
+					dyn_r_type, 0, value);
 	  elf64_ia64_install_dyn_reloc (abfd, NULL, pltoff_sec,
 					ia64_info->rel_pltoff_sec,
 					dyn_i->pltoff_offset + 8,
-					dyn_r_type, 0, 0);
+					dyn_r_type, 0, value);
 	}
 
       dyn_i->pltoff_done = 1;
@@ -3371,6 +3368,7 @@
 	    {
 	      unsigned int dyn_r_type;
 	      long dynindx;
+	      bfd_vma addend;
 
 	      BFD_ASSERT (srel != NULL);
 
@@ -3378,7 +3376,11 @@
 		 matching RELATIVE relocation.  */
 	      dyn_r_type = r_type;
 	      if (dynamic_symbol_p)
-		dynindx = h->dynindx;
+		{
+		  dynindx = h->dynindx;
+		  addend = rel->r_addend;
+		  value = 0;
+		}
 	      else
 		{
 		  switch (r_type)
@@ -3410,11 +3412,12 @@
 		      continue;
 		    }
 		  dynindx = 0;
+		  addend = value;
 		}
 
 	      elf64_ia64_install_dyn_reloc (output_bfd, info, input_section,
 					    srel, rel->r_offset, dyn_r_type,
-					    dynindx, rel->r_addend);
+					    dynindx, addend);
 	    }
 	  /* FALLTHRU */
 
@@ -3684,23 +3687,51 @@
 	  r = elf64_ia64_install_value (output_bfd, hit_addr, value, r_type);
 	  break;
 
-	case R_IA64_SEGBASE:
-
-	case R_IA64_REL32MSB:
-	case R_IA64_REL32LSB:
-	case R_IA64_REL64MSB:
-	case R_IA64_REL64LSB:
-
 	case R_IA64_IPLTMSB:
 	case R_IA64_IPLTLSB:
-	case R_IA64_EPLTMSB:
-	case R_IA64_EPLTLSB:
-	case R_IA64_COPY:
+	  /* Install a dynamic relocation for this reloc.  */
+	  if ((dynamic_symbol_p || info->shared)
+	      && (input_section->flags & SEC_ALLOC) != 0)
+	    {
+	      long dynindx;
 
-	case R_IA64_TPREL22:
-	case R_IA64_TPREL64MSB:
-	case R_IA64_TPREL64LSB:
-	case R_IA64_LTOFF_TP22:
+	      BFD_ASSERT (srel != NULL);
+
+	      /* If we don't need dynamic symbol lookup, install two
+		 RELATIVE relocations.  */
+	      if (! dynamic_symbol_p)
+		{
+		  unsigned int dyn_r_type;
+		
+		  if (r_type == R_IA64_IPLTMSB)
+		    dyn_r_type = R_IA64_REL64MSB;
+		  else
+		    dyn_r_type = R_IA64_REL64LSB;
+
+		  elfNN_ia64_install_dyn_reloc (output_bfd, info,
+						input_section,
+						srel, rel->r_offset,
+						dyn_r_type, 0, value);
+		  elfNN_ia64_install_dyn_reloc (output_bfd, info,
+						input_section,
+						srel, rel->r_offset + 8,
+						dyn_r_type, 0, gp_val);
+		}
+	      else
+		elfNN_ia64_install_dyn_reloc (output_bfd, info, input_section,
+					      srel, rel->r_offset, r_type,
+					      h->dynindx, rel->r_addend);
+	    }
+
+	  if (r_type == R_IA64_IPLTMSB)
+	    r_type = R_IA64_DIR64MSB;
+	  else
+	    r_type = R_IA64_DIR64LSB;
+	  elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type);
+	  r = elfNN_ia64_install_value (output_bfd, hit_addr + 8, gp_val,
+					r_type);
+	  break;
+
 	default:
 	  r = bfd_reloc_notsupported;
 	  break;

-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj

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