This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PowerPC: Use correct PLT relocations for elf_machine_type_class.


On Thu, Feb 21, 2008 at 10:51:04AM +1030, Alan Modra wrote:
> On Wed, Feb 20, 2008 at 03:41:47PM -0600, Ryan S. Arnold wrote:
> > On Wed, 2008-02-20 at 12:08 -0800, Ulrich Drepper wrote:
> > > And what is it supposed to fix?
> 
> It was posted too soon, sorry.  It doesn't fix anything.  On the face
> of it, the patch is obviously correct in that R_PPC64_ADDR24 has
> nothing to do with PLT relocations while R_PPC64_JMP_SLOT does.
> However, when you look at what is going on in detail, PowerPC64
> doesn't need to distinguish between PLT relocs and other relocs.
> 
> See the comment in the following patch.  This should speed ld.so by
> simplifying evaluation of elf_machine_type_class, save symbol lookup
> cache by not storing two classes of symbol values, and considerably
> speed lookup of protected symbols.
> 
> Regression testing has *not* finished yet, so please don't apply the
> patch just yet.  Yes, posting too soon again, but I wanted to get this
> out in case Ryan forwards the private email I sent him last night
> which wasn't quite as clear.  Comments welcome.  Feel free to take my
> description of ELF_RTYPE_CLASS_PLT's purpose and put it in the comment
> in ldsodefs.h.
>
>
> 2008-02-21  Alan Modra  <amodra@bigpond.net.au>
> 
> 	* sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_type_class):
> 	Always set ELF_RTYPE_CLASS_PLT.
> 	(elf_machine_lookup_noexec_p, elf_machine_lookup_noplt_p): Delete.

Unfortunately this change completely broke prelink on ppc64 (and as we
haven't rebuilt prelink in Fedora between that time and now it wasn't
noticed during make check, wonder why it hasn't been reported by users
though).  The following very ugly hack gets back at least most of the tests
into a working state, hopefully still compatible with the older glibc
LD_TRACE_PRELINKING=1 output, but the lost distinction between PLT and
non-PLT lookups still breaks the C++ vtable optimizations.  I'll see if
something can be easily done for them, but worst case the above change will
have to be reverted.

--- prelink/src/arch-ppc.c.jj	2006-12-01 19:21:24.000000000 +0100
+++ prelink/src/arch-ppc.c	2009-03-10 18:56:18.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009 Red Hat, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -1122,6 +1122,7 @@ PL_ARCH = {
   .R_JMP_SLOT = R_PPC_JMP_SLOT,
   .R_COPY = R_PPC_COPY,
   .R_RELATIVE = R_PPC_RELATIVE,
+  .rtype_class_valid = RTYPE_CLASS_VALID,
   .dynamic_linker = "/lib/ld.so.1",
   .adjust_dyn = ppc_adjust_dyn,
   .adjust_rel = ppc_adjust_rel,
--- prelink/src/arch-arm.c.jj	2009-03-10 15:36:55.000000000 +0100
+++ prelink/src/arch-arm.c	2009-03-10 18:53:58.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2004 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2004, 2009 Red Hat, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -817,6 +817,7 @@ PL_ARCH = {
   .R_JMP_SLOT = R_ARM_JUMP_SLOT,
   .R_COPY = R_ARM_COPY,
   .R_RELATIVE = R_ARM_RELATIVE,
+  .rtype_class_valid = RTYPE_CLASS_VALID,
   .dynamic_linker = "/lib/ld-linux.so.2",
   .adjust_dyn = arm_adjust_dyn,
   .adjust_rel = arm_adjust_rel,
--- prelink/src/arch-sparc64.c.jj	2008-10-09 22:36:07.000000000 +0200
+++ prelink/src/arch-sparc64.c	2009-03-10 18:56:52.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2004 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2004, 2009 Red Hat, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -807,6 +807,7 @@ PL_ARCH = {
   .R_JMP_SLOT = R_SPARC_JMP_SLOT,
   .R_COPY = R_SPARC_COPY,
   .R_RELATIVE = R_SPARC_RELATIVE,
+  .rtype_class_valid = RTYPE_CLASS_VALID,
   .dynamic_linker = "/lib64/ld-linux.so.2",
   .adjust_dyn = sparc64_adjust_dyn,
   .adjust_rel = sparc64_adjust_rel,
--- prelink/src/arch-alpha.c.jj	2006-12-01 19:21:24.000000000 +0100
+++ prelink/src/arch-alpha.c	2009-03-10 18:53:47.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2003, 2004 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2004, 2009 Red Hat, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -467,6 +467,7 @@ PL_ARCH = {
   .R_JMP_SLOT = R_ALPHA_JMP_SLOT,
   .R_COPY = -1,
   .R_RELATIVE = R_ALPHA_RELATIVE,
+  .rtype_class_valid = RTYPE_CLASS_VALID,
   .dynamic_linker = "/lib/ld-linux.so.2",
   .adjust_dyn = alpha_adjust_dyn,
   .adjust_rel = alpha_adjust_rel,
--- prelink/src/arch-cris.c.jj	2006-12-01 19:21:24.000000000 +0100
+++ prelink/src/arch-cris.c	2009-03-10 18:54:08.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2004 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2004, 2009 Red Hat, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -375,6 +375,7 @@ PL_ARCH = {
   .R_JUMP_SLOT = R_CRIS_JUMP_SLOT,
   .R_COPY = R_CRIS_COPY,
   .R_RELATIVE = R_CRIS_RELATIVE,
+  .rtype_class_valid = RTYPE_CLASS_VALID,
   .dynamic_linker = "/lib/ld.so.1",
   .adjust_dyn = cris_adjust_dyn,
   .adjust_rel = cris_adjust_rel,
--- prelink/src/arch-s390x.c.jj	2006-12-01 19:21:24.000000000 +0100
+++ prelink/src/arch-s390x.c	2009-03-10 18:56:34.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2003, 2004 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2004, 2009 Red Hat, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -598,6 +598,7 @@ PL_ARCH = {
   .R_JMP_SLOT = R_390_JMP_SLOT,
   .R_COPY = R_390_COPY,
   .R_RELATIVE = R_390_RELATIVE,
+  .rtype_class_valid = RTYPE_CLASS_VALID,
   .dynamic_linker = "/lib/ld64.so.1",
   .adjust_dyn = s390x_adjust_dyn,
   .adjust_rel = s390x_adjust_rel,
--- prelink/src/arch-ia64.c.jj	2006-12-01 19:21:24.000000000 +0100
+++ prelink/src/arch-ia64.c	2009-03-10 18:54:25.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2003, 2004 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2004, 2009 Red Hat, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -493,6 +493,7 @@ PL_ARCH = {
   .R_JMP_SLOT = R_IA64_IPLTLSB,
   .R_COPY = -1,
   .R_RELATIVE = R_IA64_REL64LSB,
+  .rtype_class_valid = RTYPE_CLASS_VALID,
   .dynamic_linker = "/lib/ld-linux-ia64.so.2",
   .adjust_dyn = ia64_adjust_dyn,
   .adjust_rel = ia64_adjust_rel,
--- prelink/src/arch-ppc64.c.jj	2006-08-13 17:18:17.000000000 +0200
+++ prelink/src/arch-ppc64.c	2009-03-10 18:55:48.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Red Hat, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2009 Red Hat, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>, 2002.
 
    This program is free software; you can redistribute it and/or modify
@@ -771,13 +771,12 @@ ppc64_reloc_class (int reloc_type)
 {
   switch (reloc_type)
     {
-    case R_PPC64_COPY: return RTYPE_CLASS_COPY;
-    case R_PPC64_ADDR24: return RTYPE_CLASS_PLT;
+    case R_PPC64_COPY: return RTYPE_CLASS_COPY | RTYPE_CLASS_PLT;
     default:
       if (reloc_type >= R_PPC64_DTPMOD64
 	  && reloc_type <= R_PPC64_TPREL16_HIGHESTA)
 	return RTYPE_CLASS_TLS;
-      return RTYPE_CLASS_VALID;
+      return RTYPE_CLASS_PLT;
     }
 }
 
@@ -824,6 +823,7 @@ PL_ARCH = {
   .R_JMP_SLOT = R_PPC64_JMP_SLOT,
   .R_COPY = R_PPC64_COPY,
   .R_RELATIVE = R_PPC64_RELATIVE,
+  .rtype_class_valid = RTYPE_CLASS_PLT,
   .dynamic_linker = "/lib64/ld64.so.1",
   .adjust_section = ppc64_adjust_section,
   .adjust_dyn = ppc64_adjust_dyn,
--- prelink/src/get.c.jj	2007-10-09 15:43:19.000000000 +0200
+++ prelink/src/get.c	2009-03-10 19:16:44.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2009 Red Hat, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -275,7 +275,12 @@ prelink_record_relocations (struct preli
 	  if (type)
 	    reloc_class = dso->arch->reloc_class (reloc_class);
 	  else
-	    reloc_class |= RTYPE_CLASS_VALID;
+	    {
+	      if ((reloc_class | RTYPE_CLASS_VALID) == RTYPE_CLASS_TLS)
+		reloc_class |= RTYPE_CLASS_VALID;
+	      else
+		reloc_class |= dso->arch->rtype_class_valid;
+	    }
 
 	  while (*symname == ' ' || *symname == '\t') ++symname;
 
@@ -452,7 +457,12 @@ prelink_record_relocations (struct preli
 	  if (type)
 	    reloc_class = dso->arch->reloc_class (reloc_class);
 	  else
-	    reloc_class |= RTYPE_CLASS_VALID;
+	    {
+	      if ((reloc_class | RTYPE_CLASS_VALID) == RTYPE_CLASS_TLS)
+		reloc_class |= RTYPE_CLASS_VALID;
+	      else
+		reloc_class |= dso->arch->rtype_class_valid;
+	    }
 
 	  while (*symname == ' ' || *symname == '\t') ++symname;
 
--- prelink/src/arch-s390.c.jj	2006-12-01 19:21:24.000000000 +0100
+++ prelink/src/arch-s390.c	2009-03-10 18:56:26.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2003, 2004 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2004, 2009 Red Hat, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -482,6 +482,7 @@ PL_ARCH = {
   .R_JMP_SLOT = R_390_JMP_SLOT,
   .R_COPY = R_390_COPY,
   .R_RELATIVE = R_390_RELATIVE,
+  .rtype_class_valid = RTYPE_CLASS_VALID,
   .dynamic_linker = "/lib/ld.so.1",
   .adjust_dyn = s390_adjust_dyn,
   .adjust_rel = s390_adjust_rel,
--- prelink/src/arch-i386.c.jj	2006-12-01 19:21:24.000000000 +0100
+++ prelink/src/arch-i386.c	2009-03-10 18:54:17.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2003, 2004 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2004, 2009 Red Hat, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -1052,6 +1052,7 @@ PL_ARCH = {
   .R_JMP_SLOT = R_386_JMP_SLOT,
   .R_COPY = R_386_COPY,
   .R_RELATIVE = R_386_RELATIVE,
+  .rtype_class_valid = RTYPE_CLASS_VALID,
   .dynamic_linker = "/lib/ld-linux.so.2",
   .adjust_dyn = i386_adjust_dyn,
   .adjust_rel = i386_adjust_rel,
--- prelink/src/prelink.h.jj	2009-03-10 15:36:21.000000000 +0100
+++ prelink/src/prelink.h	2009-03-10 18:48:19.000000000 +0100
@@ -1,4 +1,5 @@
-/* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
+   Red Hat, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -159,6 +160,7 @@ struct PLArch
   int R_COPY;
   int R_JMP_SLOT;
   int R_RELATIVE;
+  int rtype_class_valid;
   int (*arch_adjust) (DSO *dso, GElf_Addr start, GElf_Addr adjust);
   int (*adjust_section) (DSO *dso, int n, GElf_Addr start, GElf_Addr adjust);
   int (*adjust_dyn) (DSO *dso, int n, GElf_Dyn *dyn, GElf_Addr start,
--- prelink/src/arch-sparc.c.jj	2006-12-01 19:21:24.000000000 +0100
+++ prelink/src/arch-sparc.c	2009-03-10 18:57:01.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2004 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2004, 2009 Red Hat, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -607,6 +607,7 @@ PL_ARCH = {
   .R_JMP_SLOT = R_SPARC_JMP_SLOT,
   .R_COPY = R_SPARC_COPY,
   .R_RELATIVE = R_SPARC_RELATIVE,
+  .rtype_class_valid = RTYPE_CLASS_VALID,
   .dynamic_linker = "/lib/ld-linux.so.2",
   .adjust_dyn = sparc_adjust_dyn,
   .adjust_rel = sparc_adjust_rel,
--- prelink/src/arch-x86_64.c.jj	2006-12-01 19:21:24.000000000 +0100
+++ prelink/src/arch-x86_64.c	2009-03-10 18:57:09.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2003, 2004, 2006 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2004, 2006, 2009 Red Hat, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -505,6 +505,7 @@ PL_ARCH = {
   .R_JMP_SLOT = R_X86_64_JUMP_SLOT,
   .R_COPY = R_X86_64_COPY,
   .R_RELATIVE = R_X86_64_RELATIVE,
+  .rtype_class_valid = RTYPE_CLASS_VALID,
   .dynamic_linker = "/lib64/ld-linux-x86-64.so.2",
   .adjust_dyn = x86_64_adjust_dyn,
   .adjust_rel = x86_64_adjust_rel,
--- prelink/src/arch-mips.c.jj	2006-12-01 19:21:24.000000000 +0100
+++ prelink/src/arch-mips.c	2009-03-10 18:54:45.000000000 +0100
@@ -999,6 +999,7 @@ PL_ARCH = {
   /* R_MIPS_REL32 relocations against symbol 0 do act as relative relocs,
      but those against other symbols don't.  */
   .R_RELATIVE = ~0U,
+  .rtype_class_valid = RTYPE_CLASS_VALID,
   .arch_adjust = mips_arch_adjust,
   .adjust_dyn = mips_adjust_dyn,
   .adjust_rel = mips_adjust_rel,
--- prelink/src/arch-sh.c.jj	2006-12-01 19:21:24.000000000 +0100
+++ prelink/src/arch-sh.c	2009-03-10 18:56:42.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2003, 2004 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2004, 2009 Red Hat, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -414,6 +414,7 @@ PL_ARCH = {
   .R_JMP_SLOT = R_SH_JMP_SLOT,
   .R_COPY = R_SH_COPY,
   .R_RELATIVE = R_SH_RELATIVE,
+  .rtype_class_valid = RTYPE_CLASS_VALID,
   .dynamic_linker = "/lib/ld-linux.so.2",
   .adjust_dyn = sh_adjust_dyn,
   .adjust_rel = sh_adjust_rel,


	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]