public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix sparcv9 statically linked dlopen
@ 2003-08-15 22:58 Jakub Jelinek
  2003-08-17  0:23 ` Ulrich Drepper
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2003-08-15 22:58 UTC (permalink / raw)
  To: Ulrich Drepper, Roland McGrath; +Cc: Glibc hackers

Hi!

_dl_hwcap is now in dl-support.c, so doesn't have to be weak.
Bu _dl_hwcap_mask is not, so needs to be guarded ifdef SHARED.

2003-08-15  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/sparc/sparc32/dl-machine.h (WEAKADDR): Remove.
	(elf_machine_matches_host): Remove weak extern stuff.
	Use GL(dl_hwcap) unconditionally and GL(dl_hwcap_mask) if SHARED.
	(elf_machine_runtime_setup, sparc_fixup_plt): Remove weak extern
	stuff.  Use GL(dl_hwcap) unconditionally.

--- libc/sysdeps/sparc/sparc32/dl-machine.h.jj	2003-07-31 04:36:01.000000000 -0400
+++ libc/sysdeps/sparc/sparc32/dl-machine.h	2003-08-15 16:36:36.000000000 -0400
@@ -40,12 +40,6 @@
 #define OPCODE_SAVE_SP	0x9de3bfa8 /* save %sp, -(16+6)*4, %sp */
 #define OPCODE_BA	0x30800000 /* b,a ?; add PC-rel word address */
 
-/* Protect some broken versions of gcc from misinterpreting weak addresses.  */
-#define WEAKADDR(x)	({ __typeof(x) *_px = &x;			\
-			   __asm ("" : "=r" (_px) : "0" (_px));		\
-			   _px; })
-
-
 /* Use a different preload file when running in 32-bit emulation mode
    on a 64-bit host.  */
 #define LD_SO_PRELOAD ((GL(dl_hwcap) & HWCAP_SPARC_V9) \
@@ -61,16 +55,13 @@ elf_machine_matches_host (const Elf32_Eh
     return 1;
   else if (ehdr->e_machine == EM_SPARC32PLUS)
     {
-      unsigned long *hwcap;
-#ifndef SHARED
-      weak_extern (_dl_hwcap);
-      weak_extern (_dl_hwcap_mask);
-#endif
-
-      hwcap = WEAKADDR (GL(dl_hwcap));
       /* XXX The following is wrong!  Dave Miller rejected to implement it
 	 correctly.  If this causes problems shoot *him*!  */
-      return hwcap == NULL || (*hwcap & GL(dl_hwcap_mask) & HWCAP_SPARC_V9);
+#ifdef SHARED
+      return GL(dl_hwcap) & GL(dl_hwcap_mask) & HWCAP_SPARC_V9;
+#else
+      return GL(dl_hwcap) & HWCAP_SPARC_V9;
+#endif
     }
   else
     return 0;
@@ -170,17 +161,12 @@ elf_machine_runtime_setup (struct link_m
 	  || __builtin_expect (l->l_info [VALIDX (DT_GNU_LIBLISTSZ)] != NULL, 0))
 	{
 	  /* Need to reinitialize .plt to undo prelinking.  */
-	  unsigned long *hwcap;
 	  int do_flush;
 	  Elf32_Rela *rela = (Elf32_Rela *) D_PTR (l, l_info[DT_JMPREL]);
 	  Elf32_Rela *relaend
 	    = (Elf32_Rela *) ((char *) rela
 			      + l->l_info[DT_PLTRELSZ]->d_un.d_val);
-#ifndef SHARED
-	  weak_extern (_dl_hwcap);
-#endif
-	  hwcap = WEAKADDR (GL(dl_hwcap));
-	  do_flush = (!hwcap || (*hwcap & HWCAP_SPARC_FLUSH));
+	  do_flush = GL(dl_hwcap) & HWCAP_SPARC_FLUSH;
 
 	  /* prelink must ensure there are no R_SPARC_NONE relocs left
 	     in .rela.plt.  */
@@ -367,13 +353,7 @@ sparc_fixup_plt (const Elf32_Rela *reloc
 #ifndef RTLD_BOOTSTRAP
   /* Note that we don't mask the hwcap here, as the flush is essential to
      functionality on those cpu's that implement it.  */
-  unsigned long *hwcap;
-  int do_flush;
-# ifndef SHARED
-  weak_extern (_dl_hwcap);
-# endif
-  hwcap = WEAKADDR (GL(dl_hwcap));
-  do_flush = (!hwcap || (*hwcap & HWCAP_SPARC_FLUSH));
+  int do_flush = GL(dl_hwcap) & HWCAP_SPARC_FLUSH;
 #else
   /* Unfortunately, this is necessary, so that we can ensure
      ld.so will not execute corrupt PLT entry instructions. */

	Jakub

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

* Re: [PATCH] Fix sparcv9 statically linked dlopen
  2003-08-15 22:58 [PATCH] Fix sparcv9 statically linked dlopen Jakub Jelinek
@ 2003-08-17  0:23 ` Ulrich Drepper
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2003-08-17  0:23 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers

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

Jakub Jelinek wrote:

> 2003-08-15  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* sysdeps/sparc/sparc32/dl-machine.h (WEAKADDR): Remove.
> 	(elf_machine_matches_host): Remove weak extern stuff.
> 	Use GL(dl_hwcap) unconditionally and GL(dl_hwcap_mask) if SHARED.
> 	(elf_machine_runtime_setup, sparc_fixup_plt): Remove weak extern
> 	stuff.  Use GL(dl_hwcap) unconditionally.

I applied this patch.

- -- 
- --------------.                        ,-.            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/Psq72ijCOnn/RHQRAtokAJ0aLujzoGHSIaoX6dAedgZQR617qACdHnBq
FsrKfqF4lkTeThRfrbP34FU=
=P3JA
-----END PGP SIGNATURE-----

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-15 22:58 [PATCH] Fix sparcv9 statically linked dlopen Jakub Jelinek
2003-08-17  0:23 ` Ulrich Drepper

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