public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* powerpc64-linux hack
@ 2003-08-11 11:29 Alan Modra
  2003-08-11 18:11 ` Ulrich Drepper
  2003-08-11 18:57 ` Richard Henderson
  0 siblings, 2 replies; 5+ messages in thread
From: Alan Modra @ 2003-08-11 11:29 UTC (permalink / raw)
  To: binutils; +Cc: mostrows

We won't ever be returning to anything in crt1.o, so a toc adjustment is
fine.

	* elf64-ppc.c (ppc64_elf_relocate_section): Add special case for crt1.o
	branch to __libc_start_main.

Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.125
diff -u -p -r1.125 elf64-ppc.c
--- bfd/elf64-ppc.c	7 Aug 2003 08:38:08 -0000	1.125
+++ bfd/elf64-ppc.c	11 Aug 2003 11:25:15 -0000
@@ -7788,6 +7788,13 @@ ppc64_elf_relocate_section (bfd *output_
 		      if ((insn & 1) == 0)
 			can_plt_call = 1;
 		    }
+		  else if (h != NULL
+			   && strcmp (h->root.root.string,
+				      ".__libc_start_main") == 0)
+		    {
+		      /* Allow crt1 branch to go via a toc adjusting stub.  */
+		      can_plt_call = 1;
+		    }
 		  else
 		    {
 		      if (strcmp (input_section->output_section->name,

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: powerpc64-linux hack
  2003-08-11 11:29 powerpc64-linux hack Alan Modra
@ 2003-08-11 18:11 ` Ulrich Drepper
  2003-08-12  0:25   ` Alan Modra
  2003-08-11 18:57 ` Richard Henderson
  1 sibling, 1 reply; 5+ messages in thread
From: Ulrich Drepper @ 2003-08-11 18:11 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils, mostrows

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alan Modra wrote:
> We won't ever be returning to anything in crt1.o, so a toc adjustment is
> fine.
> 
> 	* elf64-ppc.c (ppc64_elf_relocate_section): Add special case for crt1.o
> 	branch to __libc_start_main.

That's a stupid change.  There is no guarantee that future glibc
versions won't have different libc entry point names.  I would never
accept hardcoding a name like this.  If you need new functionality
design and implement it and use it for the __libc_start_main call.  But
don't add a hack like this.

- -- 
- --------------.                        ,-.            444 Castro Street
Ulrich Drepper \    ,-----------------'   \ Mountain View, CA 94041 USA
Red Hat         `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE/N9xB2ijCOnn/RHQRAgPUAKCkIGD86/Tw8/lL49N0e8twRj8lTACfeN6w
M3CcW8Cp6Xfy4Y6OVkq/NMg=
=Y5lH
-----END PGP SIGNATURE-----

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

* Re: powerpc64-linux hack
  2003-08-11 11:29 powerpc64-linux hack Alan Modra
  2003-08-11 18:11 ` Ulrich Drepper
@ 2003-08-11 18:57 ` Richard Henderson
  2003-08-12  0:27   ` Alan Modra
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2003-08-11 18:57 UTC (permalink / raw)
  To: binutils, mostrows

On Mon, Aug 11, 2003 at 08:59:52PM +0930, Alan Modra wrote:
> +			   && strcmp (h->root.root.string,
> +				      ".__libc_start_main") == 0)

You really should use a special branch relocation instead.
This could be used elsewhere as well, no doubt.


r~

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

* Re: powerpc64-linux hack
  2003-08-11 18:11 ` Ulrich Drepper
@ 2003-08-12  0:25   ` Alan Modra
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Modra @ 2003-08-12  0:25 UTC (permalink / raw)
  To: Ulrich Drepper, libc-alpha; +Cc: binutils, mostrows

On Mon, Aug 11, 2003 at 11:11:13AM -0700, Ulrich Drepper wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Alan Modra wrote:
> > We won't ever be returning to anything in crt1.o, so a toc adjustment is
> > fine.
> > 
> > 	* elf64-ppc.c (ppc64_elf_relocate_section): Add special case for crt1.o
> > 	branch to __libc_start_main.
> 
> That's a stupid change.  There is no guarantee that future glibc
> versions won't have different libc entry point names.  I would never
> accept hardcoding a name like this.  If you need new functionality
> design and implement it and use it for the __libc_start_main call.  But
> don't add a hack like this.

Calm down.  I did say it was a hack.  Please apply the following.

	* sysdeps/powerpc/powerpc64/elf/start.S: Add a nop after
	__libc_start_main branch.

Index: sysdeps/powerpc/powerpc64/elf/start.S
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/powerpc/powerpc64/elf/start.S,v
retrieving revision 1.4
diff -u -p -r1.4 start.S
--- sysdeps/powerpc/powerpc64/elf/start.S	10 Jul 2003 17:06:24 -0000	1.4
+++ sysdeps/powerpc/powerpc64/elf/start.S	12 Aug 2003 00:10:36 -0000
@@ -56,6 +56,9 @@ ENTRY(_start)
 
  /* and continue in libc-start, in glibc.  */
 	b	JUMPTARGET(BP_SYM(__libc_start_main))
+/* The linker needs this nop to recognize that it's OK to call via a
+   TOC adjusting stub.  */
+	nop
 
 END(_start)
 
-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: powerpc64-linux hack
  2003-08-11 18:57 ` Richard Henderson
@ 2003-08-12  0:27   ` Alan Modra
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Modra @ 2003-08-12  0:27 UTC (permalink / raw)
  To: Richard Henderson; +Cc: binutils, mostrows

On Mon, Aug 11, 2003 at 11:57:34AM -0700, Richard Henderson wrote:
> On Mon, Aug 11, 2003 at 08:59:52PM +0930, Alan Modra wrote:
> > +			   && strcmp (h->root.root.string,
> > +				      ".__libc_start_main") == 0)
> 
> You really should use a special branch relocation instead.
> This could be used elsewhere as well, no doubt.

Yeah, well, it didn't seem worth it.  The "right" fix in this instance
is to simply add a nop after the "bl .__libc_start_main" call in crt1.o.
It's not that the nop is needed as a placeholder to restore r2 because
we never return, but that the bl,nop sequence is used for extern calls
and is recognized by the linker.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

end of thread, other threads:[~2003-08-12  0:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-11 11:29 powerpc64-linux hack Alan Modra
2003-08-11 18:11 ` Ulrich Drepper
2003-08-12  0:25   ` Alan Modra
2003-08-11 18:57 ` Richard Henderson
2003-08-12  0:27   ` Alan Modra

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).