]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix profiling on powerpc32 secure-plt shared libs and PIEs
authorAlan Modra <amodra@gmail.com>
Fri, 19 Aug 2011 16:39:38 +0000 (11:39 -0500)
committerRyan S. Arnold <rsa@us.ibm.com>
Mon, 12 Sep 2011 21:33:41 +0000 (16:33 -0500)
This patch moves the ppc32 _mcount to libc_shared.a, fixing a
long-standing bug with profiling of secure-plt shared libraries and
PIEs.  The problem is that a ppc32 PIC PLT call stub uses r30 (GOT
pointer) to load the function address from the PLT, r30 being set up
in the function prologue, but _mcount is called before the function
prologue.  So chances are good that r30 will be pointing to the
executable GOT when trying to call _mcount in a shared lib function.
A similar problem can occur in a PIE if a shared lib calls a function
in the executable.

ChangeLog
sysdeps/powerpc/Makefile
sysdeps/powerpc/powerpc32/Makefile
sysdeps/powerpc/powerpc32/Versions
sysdeps/powerpc/powerpc32/ppc-mcount.S
sysdeps/powerpc/powerpc64/Makefile

index f77f1714a0d096d8422a97d28c1d99c5b0e1587e..ee2ccdc4f42c5743aa70778fa37f79f3a0b7603e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,18 @@
        * sysdeps/ieee754/ldbl-128ibm/s_fmal.c: New file which checks
        for finite and infinity parameters.
 
+2011-08-15  Alan Modra  <amodra@gmail.com>
+
+       PR 13092
+       * sysdeps/powerpc/Makefile (gmon): Move sysdep_routines to..
+       * sysdeps/powerpc/powerpc64/Makefile (gmon): ..here..
+       * sysdeps/powerpc/powerpc32/Makefile (gmon): ..and here.  Add
+       ppc_mcount to static-only-routines.
+       * sysdeps/powerpc/powerpc32/Versions: Export GLIBC_PRIVATE
+       __mcount_internal.
+       * sysdeps/powerpc/powerpc32/ppc-mcount.S (_mcount): Call
+       __mcount_internal with usual JUMPTARGET.  Remove useless nop.
+
 2011-08-04  Will Schmidt  <will_schmidt@vnet.ibm.com>
 
        * sysdeps/powerpc/powerpc32/power7/strncmp.S: Adjust the alignment
index 616458f13669103b6ecf2dee423eb5d4c7dc550b..e43ca704f051615a83f45ad6dec9f7b04b02e272 100644 (file)
@@ -2,10 +2,6 @@
 # machine.
 +cflags += -mnew-mnemonics
 
-ifeq ($(subdir),gmon)
-sysdep_routines += ppc-mcount
-endif
-
 ifeq ($(subdir),string)
 CFLAGS-memcmp.c += -Wno-uninitialized
 endif
index 1d58a063d672deb98fc29e6ab9c34b83f20c4d3d..ed24484c2e9d5229fe0591400e7e4383cbd39edd 100644 (file)
@@ -5,6 +5,11 @@ ifeq ($(with-fp),no)
 sysdep-LDFLAGS += -msoft-float
 endif
 
+ifeq ($(subdir),gmon)
+sysdep_routines += ppc-mcount
+static-only-routines += ppc-mcount
+endif
+
 ifeq ($(subdir),misc)
 sysdep_routines += gprsave0 gprrest0 gprsave1 gprrest1
 endif
index 3635c4a4a1f71528157742381cbc1b69f5fdd311..ad4972e4ddc5cb013c0bf371932152157c807535 100644 (file)
@@ -8,6 +8,9 @@ libc {
     __fixsfdi; __fixunssfdi;
     __floatdidf; __floatdisf;
   }
+  GLIBC_PRIVATE {
+    __mcount_internal;
+  }
 }
 
 libm {
index 7e39acb55b5460c70ac16e78af66ae68b203f9a7..0460ef18d8f75b802fbb35aa5a613e4ae9fd769b 100644 (file)
@@ -58,8 +58,7 @@ ENTRY(_mcount)
        stw     r4, 44(r1)
        cfi_offset (lr, -4)
        stw     r5,  8(r1)
-       bl      __mcount_internal@local
-       nop
+       bl      JUMPTARGET(__mcount_internal)
  /* Restore the registers...  */
        lwz     r6,  8(r1)
        lwz     r0, 44(r1)
index 78d4f07e575fab67e985ae9998deacb6301bcf7a..c7cc601ec4c9780dc9df946dd89c5e4347ed70f4 100644 (file)
@@ -42,4 +42,5 @@ ifeq ($(subdir),gmon)
 # Compiling with -msoft-float ensures that fp regs are not used
 # for moving memory around.
 CFLAGS-mcount.c += $(no-special-regs)
+sysdep_routines += ppc-mcount
 endif