public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* IA64 linker bug: Linker failed to relax long call
@ 2004-06-27  0:48 H. J. Lu
  2004-06-27  5:53 ` PATCH: IA64: Don't relax branch in .init/.fini sections H. J. Lu
  0 siblings, 1 reply; 5+ messages in thread
From: H. J. Lu @ 2004-06-27  0:48 UTC (permalink / raw)
  To: binutils

See

http://sources.redhat.com/bugzilla/show_bug.cgi?id=240


H.J.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* PATCH: IA64: Don't relax branch in .init/.fini sections.
  2004-06-27  0:48 IA64 linker bug: Linker failed to relax long call H. J. Lu
@ 2004-06-27  5:53 ` H. J. Lu
  2004-06-29 23:49   ` Jim Wilson
  0 siblings, 1 reply; 5+ messages in thread
From: H. J. Lu @ 2004-06-27  5:53 UTC (permalink / raw)
  To: binutils

On Sat, Jun 26, 2004 at 05:48:11PM -0700, H. J. Lu wrote:
> See
> 
> http://sources.redhat.com/bugzilla/show_bug.cgi?id=240
> 

Here is a patch.


H.J.
----
2004-06-26  H.J. Lu  <hongjiu.lu@intel.com>

	* elfxx-ia64.c (elfNN_ia64_relax_section): Don't relax branch
	in .init/.fini sections.

--- bfd/elfxx-ia64.c.brl	2004-06-24 08:49:54.000000000 -0700
+++ bfd/elfxx-ia64.c	2004-06-26 21:50:27.637103414 -0700
@@ -953,6 +953,18 @@ elfNN_ia64_relax_section (abfd, sec, lin
 	{
 	  bfd_signed_vma offset;
 
+	  /* We can't put a trampoline in a .init/.fini section. Issue
+	     an error.  */
+	  if (strcmp (sec->output_section->name, ".init") == 0
+	      || strcmp (sec->output_section->name, ".fini") == 0)
+	    {
+	      (*_bfd_error_handler)
+		(_("%s: Can't relax br in section `%s'. Please use brl."),
+		 bfd_archive_filename (sec->owner), sec->name);
+	      bfd_set_error (bfd_error_bad_value);
+	      goto error_return;
+	    }
+
 	  reladdr = (sec->output_section->vma
 		     + sec->output_offset
 		     + roff) & (bfd_vma) -4;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: IA64: Don't relax branch in .init/.fini sections.
  2004-06-27  5:53 ` PATCH: IA64: Don't relax branch in .init/.fini sections H. J. Lu
@ 2004-06-29 23:49   ` Jim Wilson
  2004-06-30  0:05     ` H. J. Lu
  2004-06-30  1:16     ` H. J. Lu
  0 siblings, 2 replies; 5+ messages in thread
From: Jim Wilson @ 2004-06-29 23:49 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

On Sat, 2004-06-26 at 22:53, H. J. Lu wrote:
> 	* elfxx-ia64.c (elfNN_ia64_relax_section): Don't relax branch
> 	in .init/.fini sections.

This looks OK to me.

You suggest using brl.  The gcc startup files deliberately use indirect
branches to avoid this problem.  We load the function address into a
register, and then branch on the register.  This also avoids use of brl
which is a slow on an Itanium1.  If we can ignore Itanium1, then we can
simplify the gcc startup code a little bit.

The error message doesn't give any hint about which instruction can't be
relocated.  Which means if you have lots of them you are screwed.  This
might be rare enough that we don't have to worry about it.  You didn't
give any info on how the problem was detected, so I can't tell if this
matters.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: IA64: Don't relax branch in .init/.fini sections.
  2004-06-29 23:49   ` Jim Wilson
@ 2004-06-30  0:05     ` H. J. Lu
  2004-06-30  1:16     ` H. J. Lu
  1 sibling, 0 replies; 5+ messages in thread
From: H. J. Lu @ 2004-06-30  0:05 UTC (permalink / raw)
  To: Jim Wilson; +Cc: binutils

On Tue, Jun 29, 2004 at 04:49:05PM -0700, Jim Wilson wrote:
> On Sat, 2004-06-26 at 22:53, H. J. Lu wrote:
> > 	* elfxx-ia64.c (elfNN_ia64_relax_section): Don't relax branch
> > 	in .init/.fini sections.
> 
> This looks OK to me.
> 
> You suggest using brl.  The gcc startup files deliberately use indirect

I will change that.

> branches to avoid this problem.  We load the function address into a
> register, and then branch on the register.  This also avoids use of brl
> which is a slow on an Itanium1.  If we can ignore Itanium1, then we can
> simplify the gcc startup code a little bit.

I think we can do it for gcc 3.4 and above.

> 
> The error message doesn't give any hint about which instruction can't be
> relocated.  Which means if you have lots of them you are screwed.  This

I will see what I can do.

> might be rare enough that we don't have to worry about it.  You didn't
> give any info on how the problem was detected, so I can't tell if this
> matters.


It came from icc. When I used icc to build a big application, linker
failed to issue an error. I got run-time failure instead.

Thanks.


H.J.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: IA64: Don't relax branch in .init/.fini sections.
  2004-06-29 23:49   ` Jim Wilson
  2004-06-30  0:05     ` H. J. Lu
@ 2004-06-30  1:16     ` H. J. Lu
  1 sibling, 0 replies; 5+ messages in thread
From: H. J. Lu @ 2004-06-30  1:16 UTC (permalink / raw)
  To: Jim Wilson; +Cc: binutils

[-- Attachment #1: Type: text/plain, Size: 919 bytes --]

On Tue, Jun 29, 2004 at 04:49:05PM -0700, Jim Wilson wrote:
> On Sat, 2004-06-26 at 22:53, H. J. Lu wrote:
> > 	* elfxx-ia64.c (elfNN_ia64_relax_section): Don't relax branch
> > 	in .init/.fini sections.
> 
> This looks OK to me.
> 
> You suggest using brl.  The gcc startup files deliberately use indirect
> branches to avoid this problem.  We load the function address into a
> register, and then branch on the register.  This also avoids use of brl
> which is a slow on an Itanium1.  If we can ignore Itanium1, then we can
> simplify the gcc startup code a little bit.
> 
> The error message doesn't give any hint about which instruction can't be
> relocated.  Which means if you have lots of them you are screwed.  This
> might be rare enough that we don't have to worry about it.  You didn't
> give any info on how the problem was detected, so I can't tell if this
> matters.

I will check in this shortly.


H.J.

[-- Attachment #2: bfd-ia64-brl-2.patch --]
[-- Type: text/plain, Size: 948 bytes --]

2004-06-29  H.J. Lu  <hongjiu.lu@intel.com>

	PR 240
	* elfxx-ia64.c (elfNN_ia64_relax_section): Don't relax branch
	in .init/.fini sections.

--- bfd/elfxx-ia64.c.brl	2004-06-29 14:41:42.833932627 -0700
+++ bfd/elfxx-ia64.c	2004-06-29 18:10:44.212915584 -0700
@@ -953,6 +953,19 @@ elfNN_ia64_relax_section (abfd, sec, lin
 	{
 	  bfd_signed_vma offset;
 
+	  /* We can't put a trampoline in a .init/.fini section. Issue
+	     an error.  */
+	  if (strcmp (sec->output_section->name, ".init") == 0
+	      || strcmp (sec->output_section->name, ".fini") == 0)
+	    {
+	      (*_bfd_error_handler)
+		(_("%s: Can't relax br at 0x%lx in section `%s'. Please use brl or indirect branch."),
+		 bfd_archive_filename (sec->owner),
+		 (unsigned long) roff, sec->name);
+	      bfd_set_error (bfd_error_bad_value);
+	      goto error_return;
+	    }
+
 	  reladdr = (sec->output_section->vma
 		     + sec->output_offset
 		     + roff) & (bfd_vma) -4;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-06-30  1:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-27  0:48 IA64 linker bug: Linker failed to relax long call H. J. Lu
2004-06-27  5:53 ` PATCH: IA64: Don't relax branch in .init/.fini sections H. J. Lu
2004-06-29 23:49   ` Jim Wilson
2004-06-30  0:05     ` H. J. Lu
2004-06-30  1:16     ` H. J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).