public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix tst-addr1 on ppc64 and ia64
@ 2006-08-31 15:38 Jakub Jelinek
  2006-08-31 15:56 ` Steve Munroe
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2006-08-31 15:38 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers

Hi!

On ppc64 and ia64 &printf is put into GOT, so the SHN_UNDEF printf
symbol has zero st_value and thus dladdr (&printf, ...) returns
a symbol in libc.so.  But, unfortunately, in libc.so _IO_printf
is an alias to printf, both are global symbols and have the same
address and size.  Which one comes first in the hash table depends
on the linker.

2006-08-31  Jakub Jelinek  <jakub@redhat.com>

	* elf/tst-addr1.c (do_test): Allow i.dli_sname "_IO_printf".

--- libc/elf/tst-addr1.c.jj	2006-08-24 22:18:59.000000000 +0200
+++ libc/elf/tst-addr1.c	2006-08-31 17:27:20.000000000 +0200
@@ -12,7 +12,14 @@ do_test (void)
       return 1;
     }
   printf ("found symbol %s in %s\n", i.dli_sname, i.dli_fname);
-  return i.dli_sname == NULL || strcmp (i.dli_sname, "printf") != 0;
+  return i.dli_sname == NULL
+	 || (strcmp (i.dli_sname, "printf") != 0
+	     /* On architectures which create PIC code by default
+		&printf may resolve to an address in libc.so
+		rather than in the binary.  printf and _IO_printf
+		are aliased and which one comes first in the
+		hash table is up to the linker.  */
+	     && strcmp (i.dli_sname, "_IO_printf") != 0);
 }
 
 #define TEST_FUNCTION do_test ()

	Jakub

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

* Re: [PATCH] Fix tst-addr1 on ppc64 and ia64
  2006-08-31 15:38 [PATCH] Fix tst-addr1 on ppc64 and ia64 Jakub Jelinek
@ 2006-08-31 15:56 ` Steve Munroe
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Munroe @ 2006-08-31 15:56 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Ulrich Drepper, Glibc hackers, libc-hacker-owner



Jakub Jelinek <jakub@redhat.com> wrote on 08/31/2006 10:38:00 AM:

> Hi!
>
> On ppc64 and ia64 &printf is put into GOT, so the SHN_UNDEF printf
> symbol has zero st_value and thus dladdr (&printf, ...) returns
> a symbol in libc.so.  But, unfortunately, in libc.so _IO_printf
> is an alias to printf, both are global symbols and have the same
> address and size.  Which one comes first in the hash table depends
> on the linker.
>

Thanks I have been scratching my head over that one :)

Steven J. Munroe

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

end of thread, other threads:[~2006-08-31 15:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-31 15:38 [PATCH] Fix tst-addr1 on ppc64 and ia64 Jakub Jelinek
2006-08-31 15:56 ` Steve Munroe

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