Subject: Re: cross-compile on SGI & SUN generate bad cygwin.dll
From: [email-masked]

24 Jul 1997 12:55:55 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
References: <[email-masked]>
Original-To: [email-masked]
Original-CC: [email-masked]
Original-Sender: [email-masked]

>Anyway, I always have a problem with cross on SGI. It seems that cross dlltool
>is unable to generate a valid .reloc section in export files ...
>( I can generate a good cygwin.dll using .exp generated on PC )

I ran into this problem as well.  As I recall, the problem was that
int and bfd_vma tend to be different sizes on Irix 6, but dlltool
and/or ld confused them.  I think the appended patch was what fixed
the problem, but I'm not sure.

In any case, I'm routinely doing crosses on Irix 6, so this will be
fixed in the next release.

Ian

Index: cofflink.c
===================================================================
RCS file: /cvs/cvsfiles/devo/bfd/cofflink.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- cofflink.c	1997/05/30 16:47:54	1.79
+++ cofflink.c	1997/06/05 19:53:48	1.80
@@ -2636,19 +2636,26 @@
       if (info->base_file)
 	{
 	  /* Emit a reloc if the backend thinks it needs it. */
-	  if (sym && pe_data(output_bfd)->in_reloc_p(output_bfd, howto))
+	  if (sym && pe_data (output_bfd)->in_reloc_p (output_bfd, howto))
 	    {
-	      /* relocation to a symbol in a section which
-		 isn't absolute - we output the address here 
-		 to a file */
-	      bfd_vma addr = rel->r_vaddr 
-		- input_section->vma 
-		+ input_section->output_offset 
-		  + input_section->output_section->vma;
-	      if (coff_data(output_bfd)->pe)
+	      /* Relocation to a symbol in a section which isn't
+		 absolute.  We output the address here to a file.
+		 This file is then read by dlltool when generating the
+		 reloc section.  Note that the base file is not
+		 portable between systems.  We write out a long here,
+		 and dlltool reads in a long.  */
+	      long addr = (rel->r_vaddr 
+			   - input_section->vma 
+			   + input_section->output_offset 
+			   + input_section->output_section->vma);
+	      if (coff_data (output_bfd)->pe)
 		addr -= pe_data(output_bfd)->pe_opthdr.ImageBase;
-	      /* FIXME: Shouldn't 4 be sizeof (addr)?  */
-	      fwrite (&addr, 1,4, (FILE *) info->base_file);
+	      if (fwrite (&addr, 1, sizeof (long), (FILE *) info->base_file)
+		  != sizeof (long))
+		{
+		  bfd_set_error (bfd_error_system_call);
+		  return false;
+		}
 	    }
 	}
   
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".