]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
elf: Remove LD_PROFILE for static binaries
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 6 Nov 2023 20:25:46 +0000 (17:25 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 21 Nov 2023 19:15:42 +0000 (16:15 -0300)
The _dl_non_dynamic_init does not parse LD_PROFILE, which does not
enable profile for dlopen objects.  Since dlopen is deprecated for
static objects, it is better to remove the support.

It also allows to trim down libc.a of profile support.

Checked on x86_64-linux-gnu.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
39 files changed:
elf/Makefile
elf/dl-load.c
elf/dl-runtime.c
elf/dl-support.c
elf/libc-dl-profstub.c [moved from elf/dl-profstub.c with 100% similarity]
include/dlfcn.h
sysdeps/aarch64/dl-machine.h
sysdeps/aarch64/dl-trampoline.S
sysdeps/alpha/dl-machine.h
sysdeps/alpha/dl-trampoline.S
sysdeps/arm/dl-machine.h
sysdeps/arm/dl-trampoline.S
sysdeps/hppa/dl-machine.h
sysdeps/hppa/dl-trampoline.S
sysdeps/i386/dl-machine.h
sysdeps/i386/dl-trampoline.S
sysdeps/ia64/dl-machine.h
sysdeps/ia64/dl-trampoline.S
sysdeps/loongarch/dl-machine.h
sysdeps/loongarch/dl-trampoline.h
sysdeps/m68k/dl-machine.h
sysdeps/m68k/dl-trampoline.S
sysdeps/powerpc/powerpc32/dl-machine.c
sysdeps/powerpc/powerpc32/dl-machine.h
sysdeps/powerpc/powerpc32/dl-trampoline.S
sysdeps/powerpc/powerpc64/dl-machine.h
sysdeps/powerpc/powerpc64/dl-trampoline.S
sysdeps/s390/s390-32/dl-machine.h
sysdeps/s390/s390-32/dl-trampoline.h
sysdeps/s390/s390-64/dl-machine.h
sysdeps/s390/s390-64/dl-trampoline.h
sysdeps/sh/dl-machine.h
sysdeps/sh/dl-trampoline.S
sysdeps/sparc/sparc32/dl-machine.h
sysdeps/sparc/sparc32/dl-trampoline.S
sysdeps/sparc/sparc64/dl-machine.h
sysdeps/sparc/sparc64/dl-trampoline.S
sysdeps/x86_64/dl-machine.h
sysdeps/x86_64/dl-trampoline.S

index 414fdbdec8b557f3711b670ec0df2989fd5afdcc..3f7f89508e8aa1eea29ceb0d633bcf134712ba49 100644 (file)
@@ -37,12 +37,12 @@ routines = \
   dl-iteratephdr \
   dl-libc \
   dl-origin \
-  dl-profstub \
   dl-reloc-static-pie \
   dl-support \
   dl-sym \
   dl-sysdep \
   enbl-secure \
+  libc-dl-profstub  \
   libc-dl_find_object \
   libc_early_init \
   rtld_static_init \
@@ -72,7 +72,6 @@ dl-routines = \
   dl-open \
   dl-origin \
   dl-printf \
-  dl-profile \
   dl-reloc \
   dl-runtime \
   dl-scope \
@@ -117,7 +116,11 @@ elide-routines.os = \
   # elide-routines.os
 
 # These object files are only included in the dynamically-linked libc.
-shared-only-routines = libc-dl_find_object
+shared-only-routines = \
+  libc-dl-profile \
+  libc-dl-profstub \
+  libc-dl_find_object \
+  # shared-only-routines
 
 # ld.so uses those routines, plus some special stuff for being the program
 # interpreter and operating independent of libc.
@@ -135,6 +138,7 @@ rtld-routines = \
   dl-libc_freeres \
   dl-minimal \
   dl-mutex \
+  dl-profile \
   dl-sysdep \
   dl-usage \
   rtld \
index 8d351153c80b10f5d6304f8818a740eb5f3cf085..25ea4f7a4e39f6e5e8f26d0df60b2dba9d14048b 100644 (file)
@@ -1443,11 +1443,6 @@ cannot enable executable stack as shared object requires");
      name by which the DSO is actually known.  Add that as well.  */
   if (__glibc_unlikely (origname != NULL))
     add_name_to_object (l, origname);
-#else
-  /* Audit modules only exist when linking is dynamic so ORIGNAME
-     cannot be non-NULL.  */
-  assert (origname == NULL);
-#endif
 
   /* When we profile the SONAME might be needed for something else but
      loading.  Add it right away.  */
@@ -1455,6 +1450,11 @@ cannot enable executable stack as shared object requires");
       && l->l_info[DT_SONAME] != NULL)
     add_name_to_object (l, ((const char *) D_PTR (l, l_info[DT_STRTAB])
                            + l->l_info[DT_SONAME]->d_un.d_val));
+#else
+  /* Audit modules only exist when linking is dynamic so ORIGNAME
+     cannot be non-NULL.  */
+  assert (origname == NULL);
+#endif
 
   /* If we have newly loaded libc.so, update the namespace
      description.  */
index 32a8bfcf7419394fb7bc80cd4c3489d0b42ab5ae..fe7deda32a9c86592bb3387bc510b3957516522d 100644 (file)
@@ -162,14 +162,14 @@ _dl_fixup (
   return elf_machine_fixup_plt (l, result, refsym, sym, reloc, rel_addr, value);
 }
 
-#ifndef PROF
+#if !defined PROF && defined SHARED
 DL_FIXUP_VALUE_TYPE
 __attribute ((noinline))
 DL_ARCH_FIXUP_ATTRIBUTE
 _dl_profile_fixup (
-#ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
+# ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
                   ELF_MACHINE_RUNTIME_FIXUP_ARGS,
-#endif
+# endif
                   struct link_map *l, ElfW(Word) reloc_arg,
                   ElfW(Addr) retaddr, void *regs, long int *framesizep)
 {
@@ -309,14 +309,12 @@ _dl_profile_fixup (
       /* And now perhaps the relocation addend.  */
       value = elf_machine_plt_value (l, reloc, value);
 
-#ifdef SHARED
       /* Auditing checkpoint: we have a new binding.  Provide the
         auditing libraries the possibility to change the value and
         tell us whether further auditing is wanted.  */
       if (defsym != NULL && GLRO(dl_naudit) > 0)
        _dl_audit_symbind (l, reloc_result, reloc, defsym, &value, result,
                           true);
-#endif
 
       /* Store the result for later runs.  */
       if (__glibc_likely (! GLRO(dl_bind_not)))
@@ -335,11 +333,9 @@ _dl_profile_fixup (
   long int framesize = -1;
 
 
-#ifdef SHARED
   /* Auditing checkpoint: report the PLT entering and allow the
      auditors to change the value.  */
   _dl_audit_pltenter (l, reloc_result, &value, regs, &framesize);
-#endif
 
   /* Store the frame size information.  */
   *framesizep = framesize;
@@ -349,4 +345,4 @@ _dl_profile_fixup (
   return value;
 }
 
-#endif /* PROF */
+#endif /* !defined PROF && defined SHARED */
index 44a54dea0743c633e2d844841c632ac252c46aea..31a608df87f6693bdab4cd61596174f72d977e43 100644 (file)
@@ -60,10 +60,6 @@ int _dl_dynamic_weak;
 /* If nonzero print warnings about problematic situations.  */
 int _dl_verbose;
 
-/* We never do profiling.  */
-const char *_dl_profile;
-const char *_dl_profile_output;
-
 /* Names of shared object for which the RUNPATHs and RPATHs should be
    ignored.  */
 const char *_dl_inhibit_rpath;
@@ -301,11 +297,6 @@ _dl_non_dynamic_init (void)
 
   _dl_dynamic_weak = *(getenv ("LD_DYNAMIC_WEAK") ?: "") == '\0';
 
-  _dl_profile_output = getenv ("LD_PROFILE_OUTPUT");
-  if (_dl_profile_output == NULL || _dl_profile_output[0] == '\0')
-    _dl_profile_output
-      = &"/var/tmp\0/var/profile"[__libc_enable_secure ? 9 : 0];
-
   if (__libc_enable_secure)
     {
       static const char unsecure_envvars[] =
similarity index 100%
rename from elf/dl-profstub.c
rename to elf/libc-dl-profstub.c
index ae25f05303b18044b222a255677be24bfe0e72f3..a44420fa37439a8565fa60cec9574dbfd05ce082 100644 (file)
@@ -135,5 +135,10 @@ extern int __dladdr1 (const void *address, Dl_info *info,
 extern int __dlinfo (void *handle, int request, void *arg);
 extern char *__dlerror (void);
 
+#ifndef SHARED
+# undef DL_CALL_FCT
+# define DL_CALL_FCT(fctp, args) ((fctp) args)
+#endif
+
 #endif
 #endif
index 4170b9269f7a79590091820201ed85e7a1e1f399..a56eb96a7956825373507c3141c53a9961bca0a3 100644 (file)
@@ -68,7 +68,6 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
     {
       ElfW(Addr) *got;
       extern void _dl_runtime_resolve (ElfW(Word));
-      extern void _dl_runtime_profile (ElfW(Word));
 
       got = (ElfW(Addr) *) D_PTR (l, l_info[DT_PLTGOT]);
       if (got[1])
@@ -83,6 +82,8 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
         to intercept the calls to collect information.  In this case we
         don't store the address in the GOT so that all future calls also
         end in this function.  */
+#ifdef SHARED
+      extern void _dl_runtime_profile (ElfW(Word));
       if ( profile)
        {
           got[2] = (ElfW(Addr)) &_dl_runtime_profile;
@@ -94,6 +95,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
            GL(dl_profile_map) = l;
        }
       else
+#endif
        {
          /* This function will get called to fix up the GOT entry
             indicated by the offset on the stack, and then jump to
index a3474ba741a8d2c5679e4e86ff81a4c62a448e38..fc82151ba2110317cef2f497a7a3343adfc08493 100644 (file)
@@ -122,7 +122,7 @@ _dl_runtime_resolve:
 
        cfi_endproc
        .size _dl_runtime_resolve, .-_dl_runtime_resolve
-#ifndef PROF
+#if !defined PROF && defined SHARED
        .globl _dl_runtime_profile
        .type _dl_runtime_profile, #function
        cfi_startproc
index ed5389e3c56994efe055a13fa519c11b23a715e8..7fe2afca93029e86bd0526419167c4fbda0ffb5b 100644 (file)
@@ -75,9 +75,7 @@ elf_machine_runtime_setup (struct link_map *map, struct r_scope_elem *scope[],
                           int lazy, int profile)
 {
   extern char _dl_runtime_resolve_new[] attribute_hidden;
-  extern char _dl_runtime_profile_new[] attribute_hidden;
   extern char _dl_runtime_resolve_old[] attribute_hidden;
-  extern char _dl_runtime_profile_old[] attribute_hidden;
 
   struct pltgot {
     char *resolve;
@@ -109,6 +107,9 @@ elf_machine_runtime_setup (struct link_map *map, struct r_scope_elem *scope[],
   else
     resolve = _dl_runtime_resolve_old;
 
+#ifdef SHARED
+  extern char _dl_runtime_profile_new[] attribute_hidden;
+  extern char _dl_runtime_profile_old[] attribute_hidden;
   if (__builtin_expect (profile, 0))
     {
       if (secureplt)
@@ -123,6 +124,7 @@ elf_machine_runtime_setup (struct link_map *map, struct r_scope_elem *scope[],
          GL(dl_profile_map) = map;
        }
     }
+#endif
 
   pg->resolve = resolve;
   pg->link = map;
index f8c3d33906b4cb853b60f98e6346efb96e37a6a5..5dffa62587bfe2e8f221966c25fb7889e765631f 100644 (file)
@@ -89,6 +89,7 @@ _dl_runtime_resolve_new:
        .globl  _dl_runtime_profile_new
        .type   _dl_runtime_profile_new, @function
 
+#ifdef SHARED
 #undef FRAMESIZE
 #define FRAMESIZE      20*8
 
@@ -207,6 +208,7 @@ _dl_runtime_profile_new:
 
        cfi_endproc
        .size   _dl_runtime_profile_new, .-_dl_runtime_profile_new
+#endif /* SHARED */
 
        .align  4
        .globl  _dl_runtime_resolve_old
@@ -340,6 +342,7 @@ _dl_runtime_resolve_old:
        .usepv  _dl_runtime_profile_old, no
        .type   _dl_runtime_profile_old, @function
 
+#ifdef SHARED
        /* We save the registers in a different order than desired by
           .mask/.fmask, so we have to use explicit cfi directives.  */
        cfi_startproc
@@ -538,3 +541,4 @@ _dl_runtime_profile_old:
 
        cfi_endproc
        .size   _dl_runtime_profile_old, .-_dl_runtime_profile_old
+#endif /* SHARED */
index d720c02c96b8f51c3464c2e5656f70fcf03e9cc2..a68679e6533afb6cd833d1af6df3f72260227904 100644 (file)
@@ -65,7 +65,6 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
 {
   Elf32_Addr *got;
   extern void _dl_runtime_resolve (Elf32_Word);
-  extern void _dl_runtime_profile (Elf32_Word);
 
   if (l->l_info[DT_JMPREL] && lazy)
     {
@@ -88,6 +87,8 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
         to intercept the calls to collect information.  In this case we
         don't store the address in the GOT so that all future calls also
         end in this function.  */
+#ifdef SHARED
+      extern void _dl_runtime_profile (Elf32_Word);
       if (profile)
        {
          got[2] = (Elf32_Addr) &_dl_runtime_profile;
@@ -99,6 +100,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
            GL(dl_profile_map) = l;
        }
       else
+#endif
        /* This function will get called to fix up the GOT entry indicated by
           the offset on the stack, and then jump to the resolved address.  */
        got[2] = (Elf32_Addr) &_dl_runtime_resolve;
index 23c2476917324c63697673e42a8c9fd1464f5ffb..2df5b7ee3683e1b78e6912c9865539f8fa9977c1 100644 (file)
@@ -70,7 +70,7 @@ _dl_runtime_resolve:
        cfi_endproc
        .size _dl_runtime_resolve, .-_dl_runtime_resolve
 
-#ifndef PROF
+#if !defined PROF && defined SHARED
        .globl _dl_runtime_profile
        .type _dl_runtime_profile, #function
        CFI_SECTIONS
index 4e6e70b3c90f4c32b68e6f388d0bc226ad2290db..993593de5d11e764825ba58137e80b47c21a6e6e 100644 (file)
@@ -195,7 +195,6 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
   end_jmprel = jmprel + l->l_info[DT_PLTRELSZ]->d_un.d_val;
 
   extern void _dl_runtime_resolve (void);
-  extern void _dl_runtime_profile (void);
 
   /* Linking lazily */
   if (lazy)
@@ -235,22 +234,9 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
              got[1] = (Elf32_Addr) l;
 
              /* This function will be called to perform the relocation. */
-             if (__builtin_expect (!profile, 1))
-               {
-                 /* If a static application called us, then _dl_runtime_resolve is not
-                    a function descriptor, but the *real* address of the function... */
-                 if((unsigned long) &_dl_runtime_resolve & 3)
-                   {
-                     got[-2] = (Elf32_Addr) ((struct fdesc *)
-                                 ((unsigned long) &_dl_runtime_resolve & ~3))->ip;
-                   }
-                 else
-                   {
-                     /* Static executable! */
-                     got[-2] = (Elf32_Addr) &_dl_runtime_resolve;
-                   }
-               }
-             else
+#ifdef SHARED
+             extern void _dl_runtime_profile (void);
+             if (__glibc_unlikely (profile))
                {
                  if (GLRO(dl_profile) != NULL
                      && _dl_name_match_p (GLRO(dl_profile), l))
@@ -272,6 +258,22 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
                      got[-2] = (Elf32_Addr) &_dl_runtime_profile;
                    }
                }
+             else
+#endif
+               {
+                 /* If a static application called us, then _dl_runtime_resolve is not
+                    a function descriptor, but the *real* address of the function... */
+                 if((unsigned long) &_dl_runtime_resolve & 3)
+                   {
+                     got[-2] = (Elf32_Addr) ((struct fdesc *)
+                                 ((unsigned long) &_dl_runtime_resolve & ~3))->ip;
+                   }
+                 else
+                   {
+                     /* Static executable! */
+                     got[-2] = (Elf32_Addr) &_dl_runtime_resolve;
+                   }
+               }
              /* Plunk in the gp of this function descriptor so we
                 can make the call to _dl_runtime_xxxxxx */
              got[-1] = ltp;
index 689c6e1a40a8da09abaeabb99425b7b6f8582395..9e904df3d222d80f4fb69e6caceca24eca9a7075 100644 (file)
@@ -156,6 +156,7 @@ _dl_runtime_resolve:
        cfi_endproc
        .size   _dl_runtime_resolve, . - _dl_runtime_resolve
 
+#ifdef SHARED
         .text
         .global _dl_runtime_profile
         .type _dl_runtime_profile,@function
@@ -359,3 +360,4 @@ L(cont):
         .PROCEND
        cfi_endproc
        .size   _dl_runtime_profile, . - _dl_runtime_profile
+#endif
index 18749f2ec2509d99f4e68d6c19ad21489b4970c6..07469e99b0bdf549320535447d4d59d507103e1c 100644 (file)
@@ -92,6 +92,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
         to intercept the calls to collect information.  In this case we
         don't store the address in the GOT so that all future calls also
         end in this function.  */
+#ifdef SHARED
       if (__glibc_unlikely (profile))
        {
          got[2] = (shstk_enabled
@@ -105,6 +106,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
            GL(dl_profile_map) = l;
        }
       else
+#endif
        /* This function will get called to fix up the GOT entry indicated by
           the offset on the stack, and then jump to the resolved address.  */
        got[2] = (shstk_enabled
index 2d55f373b4d5d3795e566df7f4ed3bb48c2b4a67..3604aabe876d96d00896931811615ba8ea4e5457 100644 (file)
@@ -70,7 +70,7 @@ _dl_runtime_resolve_shstk:
        cfi_endproc
        .size _dl_runtime_resolve_shstk, .-_dl_runtime_resolve_shstk
 
-#ifndef PROF
+#if !defined PROF && defined SHARED
 # The SHSTK compatible version.
        .globl _dl_runtime_profile_shstk
        .type _dl_runtime_profile_shstk, @function
index e1da3dadcb9f5697667e0f765ddf6eb6524cd908..3ef6b0ef4bab759f3b46255548898dfb08f2041a 100644 (file)
@@ -121,9 +121,8 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
       reserve[0] = (Elf64_Addr) l;
 
       /* This function will be called to perform the relocation.  */
-      if (!profile)
-       doit = (Elf64_Addr) ELF_PTR_TO_FDESC (&_dl_runtime_resolve)->ip;
-      else
+#ifdef SHARED
+      if (__glibc_unlikely (profile))
        {
          if (GLRO(dl_profile) != NULL
              && _dl_name_match_p (GLRO(dl_profile), l))
@@ -134,6 +133,11 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
            }
          doit = (Elf64_Addr) ELF_PTR_TO_FDESC (&_dl_runtime_profile)->ip;
        }
+      else
+#endif
+       {
+         doit = (Elf64_Addr) ELF_PTR_TO_FDESC (&_dl_runtime_resolve)->ip;
+       }
 
       reserve[1] = doit;
       reserve[2] = gp;
index 54b33c8c02c4f64793122c8b6623a5b305daab1f..10d8432c8f30501fd9c0e948b84805f2ac7a60b5 100644 (file)
@@ -188,7 +188,7 @@ END(_dl_runtime_resolve)
 #define PLTENTER_FRAME_SIZE (4*8 + 8*8 + 8*16 + 2*8 + 16)
 #define PLTEXIT_FRAME_SIZE (PLTENTER_FRAME_SIZE + 4*8 + 8*16)
 
-#ifndef PROF
+#if !defined PROF && defined SHARED
 ENTRY(_dl_runtime_profile)
        { .mii
          .prologue
index 57913cefaab761c15796e18fa99148877ab03878..0d17fd21e33cf3c87be82cae827f6a9b43ba8dba 100644 (file)
@@ -287,15 +287,16 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
         to intercept the calls to collect information.  In this case we
         don't store the address in the GOT so that all future calls also
         end in this function.  */
+#ifdef SHARED
       if (profile != 0)
        {
-#if !defined __loongarch_soft_float
+# if !defined __loongarch_soft_float
          if (SUPPORT_LASX)
            gotplt[0] = (ElfW(Addr)) &_dl_runtime_profile_lasx;
          else if (SUPPORT_LSX)
            gotplt[0] = (ElfW(Addr)) &_dl_runtime_profile_lsx;
          else
-#endif
+# endif
            gotplt[0] = (ElfW(Addr)) &_dl_runtime_profile;
 
          if (GLRO(dl_profile) != NULL
@@ -305,6 +306,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
            GL(dl_profile_map) = l;
        }
       else
+#endif
        {
          /* This function will get called to fix up the GOT entry
             indicated by the offset on the stack, and then jump to
index e298439d391cf5ab2b0fd0f690d811f2e3a74812..1da70aeb23a48334a47b2a61e603d04586a8806b 100644 (file)
@@ -126,6 +126,7 @@ ENTRY (_dl_runtime_resolve)
        jirl    zero, t1, 0
 END (_dl_runtime_resolve)
 
+#ifdef SHARED
 #include "dl-link.h"
 
 ENTRY (_dl_runtime_profile)
@@ -367,3 +368,4 @@ ENTRY (_dl_runtime_profile)
        jirl    zero, ra, 0
 
 END (_dl_runtime_profile)
+#endif /* SHARED */
index 5ee586b27ba36c24ad182e7f6071b93f6338593a..8d7e733e2acdd06107dff76f15e84c72271a4dd2 100644 (file)
@@ -75,7 +75,6 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
 {
   Elf32_Addr *got;
   extern void _dl_runtime_resolve (Elf32_Word);
-  extern void _dl_runtime_profile (Elf32_Word);
 
   if (l->l_info[DT_JMPREL] && lazy)
     {
@@ -93,6 +92,8 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
         to intercept the calls to collect information.  In this case we
         don't store the address in the GOT so that all future calls also
         end in this function.  */
+#ifdef SHARED
+      extern void _dl_runtime_profile (Elf32_Word);
       if (profile)
        {
          got[2] = (Elf32_Addr) &_dl_runtime_profile;
@@ -106,6 +107,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
            }
        }
       else
+#endif
        /* This function will get called to fix up the GOT entry indicated by
           the offset on the stack, and then jump to the resolved address.  */
        got[2] = (Elf32_Addr) &_dl_runtime_resolve;
index dba37414004437e4f00d8703d94754211d7e2d75..f1b4943868eea0e8af670cbd4cfe5502c0712ad4 100644 (file)
@@ -60,6 +60,7 @@ _dl_runtime_resolve:
        cfi_endproc
        .size _dl_runtime_resolve, . - _dl_runtime_resolve
 
+#ifdef SHARED
        .text
        .globl _dl_runtime_profile
        .type _dl_runtime_profile, @function
@@ -220,3 +221,4 @@ _dl_runtime_profile:
        rts
        cfi_endproc
        .size _dl_runtime_profile, . - _dl_runtime_profile
+#endif /* SHARED */
index ef84911edec9e0e724de81595b965ea1d2c57766..e6b603de94ae39e3d8ec43716c499f68534f0c78 100644 (file)
@@ -226,7 +226,7 @@ __elf_machine_runtime_setup (struct link_map *map, int lazy, int profile)
          Elf32_Word dlrr;
          Elf32_Word offset;
 
-#ifndef PROF
+#if !defined PROF && defined SHARED
          dlrr = (Elf32_Word) (profile
                               ? _dl_prof_resolve
                               : _dl_runtime_resolve);
index a4cad7583c041d7d460ae1da33149ccc2a3e31bc..1ff46d5f8a1fe2aa1aea183f547d88596a2eebd4 100644 (file)
@@ -188,15 +188,19 @@ elf_machine_runtime_setup (struct link_map *map, struct r_scope_elem *scope[],
       extern void _dl_runtime_resolve (void);
       extern void _dl_prof_resolve (void);
 
-      if (__glibc_likely (!profile))
-       dlrr = _dl_runtime_resolve;
-      else
+#ifdef SHARED
+      if (__glibc_unlikely (profile))
        {
          if (GLRO(dl_profile) != NULL
              &&_dl_name_match_p (GLRO(dl_profile), map))
            GL(dl_profile_map) = map;
          dlrr = _dl_prof_resolve;
        }
+      else
+#endif
+       {
+         dlrr = _dl_runtime_resolve;
+       }
       got = (Elf32_Addr *) map->l_info[DT_PPC(GOT)]->d_un.d_ptr;
       glink = got[1];
       got[1] = (Elf32_Addr) dlrr;
index 93b1673ebb93bf85c5513511534d5b02214ecbe4..be8de0e2dc2e4297158fd7c2c8736ae8b03f0e8e 100644 (file)
@@ -70,7 +70,7 @@ _dl_runtime_resolve:
        cfi_endproc
        .size    _dl_runtime_resolve,.-_dl_runtime_resolve
 
-#ifndef PROF
+#if !defined PROF && defined SHARED
        .align 2
        .globl _dl_prof_resolve
        .type _dl_prof_resolve,@function
index 449208e86f5f912039f5dba1eec5240cd3b5ce10..601c3cba9d88ee05cfb3a2f0cc43150851688e31 100644 (file)
@@ -362,13 +362,19 @@ elf_machine_runtime_setup (struct link_map *map, struct r_scope_elem *scope[],
          Elf64_Word offset;
          Elf64_Addr dlrr;
 
-         dlrr = (Elf64_Addr) (profile ? _dl_profile_resolve
-                                      : _dl_runtime_resolve);
-         if (profile && GLRO(dl_profile) != NULL
-             && _dl_name_match_p (GLRO(dl_profile), map))
-           /* This is the object we are looking for.  Say that we really
-              want profiling and the timers are started.  */
-           GL(dl_profile_map) = map;
+#ifdef SHARED
+         if (__glibc_unlikely (profile))
+           {
+             dlrr = (Elf64_Addr) _dl_profile_resolve;
+             if (profile && GLRO(dl_profile) != NULL
+                 && _dl_name_match_p (GLRO(dl_profile), map))
+               /* This is the object we are looking for.  Say that we really
+                  want profiling and the timers are started.  */
+               GL(dl_profile_map) = map;
+           }
+         else
+#endif
+           dlrr = (Elf64_Addr) _dl_runtime_resolve;
 
 #if _CALL_ELF != 2
          /* We need to stuff the address/TOC of _dl_runtime_resolve
index 1d04ec81096e537abb070671eb00472bb76ad502..b2fc2bb1332d3aa91269716e6cef34f2b7923bff 100644 (file)
@@ -195,7 +195,7 @@ END(_dl_runtime_resolve)
    and r11 contains the link_map (from PLT0+16).  The link_map becomes
    parm1 (r3) and the index (r0) needs to be converted to an offset
    (index * 24) in parm2 (r4).  */
-#ifndef PROF
+#if !defined PROF && defined SHARED
        .hidden _dl_profile_resolve
 ENTRY (_dl_profile_resolve, 4)
 /* Spill r30, r31 to preserve the link_map* and reloc_addr, in case we
index 100a3e05f632e407b4a66620feb134f2155ce627..b8bf2796c7d76914777503021cf70445fd3f0e41 100644 (file)
@@ -124,16 +124,17 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
         to intercept the calls to collect information.  In this case we
         don't store the address in the GOT so that all future calls also
         end in this function.  */
+#ifdef SHARED
       if (__glibc_unlikely (profile))
        {
-#if defined HAVE_S390_VX_ASM_SUPPORT
+# if defined HAVE_S390_VX_ASM_SUPPORT
          if (GLRO(dl_hwcap) & HWCAP_S390_VX)
            got[2] = (Elf32_Addr) &_dl_runtime_profile_vx;
          else
            got[2] = (Elf32_Addr) &_dl_runtime_profile;
-#else
+# else
          got[2] = (Elf32_Addr) &_dl_runtime_profile;
-#endif
+# endif
 
          if (GLRO(dl_profile) != NULL
              && _dl_name_match_p (GLRO(dl_profile), l))
@@ -142,6 +143,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
            GL(dl_profile_map) = l;
        }
       else
+#endif
        {
          /* This function will get called to fix up the GOT entry indicated by
             the offset on the stack, and then jump to the resolved address.  */
index 78fdca9d534184d1d31aefac41c0b6c270205d62..8093ab08d348effb707c96fef3e973e28a30a6ff 100644 (file)
@@ -148,7 +148,7 @@ _dl_runtime_resolve:
 #undef F0_OFF
 #undef F2_OFF
 
-#ifndef PROF
+#if !defined PROF && defined SHARED
 # define SIZEOF_STRUCT_LA_S390_32_REGS 168
 # define REGS_OFF -264
 # define R2_OFF -264
index 9fabb097500739631234e9cfd0c50a9224fbdc4a..82259dad649ce3d939ec3882ab4443ceab46019b 100644 (file)
@@ -111,16 +111,17 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
         to intercept the calls to collect information.  In this case we
         don't store the address in the GOT so that all future calls also
         end in this function.  */
+#ifdef SHARED
       if (__glibc_unlikely (profile))
        {
-#if defined HAVE_S390_VX_ASM_SUPPORT
+# if defined HAVE_S390_VX_ASM_SUPPORT
          if (GLRO(dl_hwcap) & HWCAP_S390_VX)
            got[2] = (Elf64_Addr) &_dl_runtime_profile_vx;
          else
            got[2] = (Elf64_Addr) &_dl_runtime_profile;
-#else
+# else
          got[2] = (Elf64_Addr) &_dl_runtime_profile;
-#endif
+# endif
 
          if (GLRO(dl_profile) != NULL
              && _dl_name_match_p (GLRO(dl_profile), l))
@@ -129,6 +130,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
            GL(dl_profile_map) = l;
        }
       else
+#endif
        {
          /* This function will get called to fix up the GOT entry indicated by
             the offset on the stack, and then jump to the resolved address.  */
index 3a7cfc5f927560594cdd1c141cdc2c4f7d838198..61188119e62015d8833688de58eabd92ac0c1a6a 100644 (file)
@@ -150,7 +150,7 @@ _dl_runtime_resolve:
 #undef F4_OFF
 #undef F6_OFF
 
-#ifndef PROF
+#if !defined PROF && defined SHARED
 # define SIZEOF_STRUCT_LA_S390_64_REGS 200
 # define REGS_OFF -360
 # define R2_OFF -360
index 0e4eac42c358f1771ab4db083a51f23756bfbbaa..e0480eae5a4128d61a933c279a7014c3dd7a636a 100644 (file)
@@ -101,6 +101,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
         to intercept the calls to collect information.  In this case we
         don't store the address in the GOT so that all future calls also
         end in this function.  */
+#ifdef SHARED
       if (profile)
        {
          got[2] = (Elf32_Addr) &_dl_runtime_profile;
@@ -110,6 +111,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
            GL(dl_profile_map) = l;
        }
       else
+#endif
        /* This function will get called to fix up the GOT entry indicated by
           the offset on the stack, and then jump to the resolved address.  */
        got[2] = (Elf32_Addr) &_dl_runtime_resolve;
index 5d703341ed29ce27e451abd2cdac2726164d3802..ecaae34db4934d5588543e2977a7e4add58e7ba5 100644 (file)
@@ -142,6 +142,7 @@ _dl_runtime_resolve:
        .size _dl_runtime_resolve, .-_dl_runtime_resolve
 
 
+#ifdef SHARED
        .globl _dl_runtime_profile
        .type _dl_runtime_profile,@function
        cfi_startproc
@@ -428,3 +429,4 @@ _dl_runtime_profile:
 8:     .long _dl_audit_pltexit
 #endif
        .size _dl_runtime_profile, .-_dl_runtime_profile
+#endif /* SHARED */
index 9b57ae1a93073864dbedb4f10f05ec3cfa3d6955..b10e541810d6f2bcb199ae80a7573cec218bc3d3 100644 (file)
@@ -116,7 +116,8 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
         bits of %g1 with an offset into the .rela.plt section and jump to
         the beginning of the PLT.  */
       plt = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]);
-      if (__builtin_expect(profile, 0))
+#ifdef SHARED
+      if (__glibc_unlikely (profile))
        {
          rfunc = (Elf32_Addr) &_dl_runtime_profile;
 
@@ -125,6 +126,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
            GL(dl_profile_map) = l;
        }
       else
+#endif
        {
          rfunc = (Elf32_Addr) &_dl_runtime_resolve;
        }
index 08ff31b474e0b45feca83a82275c022f802e7fa1..5e7d860ae413e30b23314a7ddda1b109d50585c9 100644 (file)
@@ -47,6 +47,7 @@ _dl_runtime_resolve:
 
        .size   _dl_runtime_resolve, .-_dl_runtime_resolve
 
+#ifdef SHARED
        /* For the profiling cases we pass in our stack frame
         * as the base of the La_sparc32_regs, so it looks
         * like:
@@ -185,3 +186,4 @@ _dl_runtime_profile:
        cfi_endproc
 
        .size   _dl_runtime_profile, .-_dl_runtime_profile
+#endif
index 2f04ac550e9760b1f1961c0e15e3e82ef8912d0c..98469e7604febc3977d37f39d8eea68a55fa29c3 100644 (file)
@@ -136,7 +136,8 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
       Elf64_Addr res0_addr, res1_addr;
       unsigned int *plt = (void *) D_PTR (l, l_info[DT_PLTGOT]);
 
-      if (__builtin_expect(profile, 0))
+#ifdef SHARED
+      if (__glibc_unlikely (profile))
        {
          res0_addr = (Elf64_Addr) &_dl_runtime_profile_0;
          res1_addr = (Elf64_Addr) &_dl_runtime_profile_1;
@@ -146,6 +147,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
            GL(dl_profile_map) = l;
        }
       else
+#endif
        {
          res0_addr = (Elf64_Addr) &_dl_runtime_resolve_0;
          res1_addr = (Elf64_Addr) &_dl_runtime_resolve_1;
index 444690a71e3c180bfe4b3345099ce65aee31134f..82b42681ddc8731a196437442f0dc9836bd7f091 100644 (file)
@@ -92,6 +92,7 @@ _dl_runtime_resolve_1:
 
        .size   _dl_runtime_resolve_1, .-_dl_runtime_resolve_1
 
+#ifdef SHARED
        /* For the profiling cases we pass in our stack frame
         * as the base of the La_sparc64_regs, so it looks
         * like:
@@ -323,3 +324,4 @@ _dl_runtime_profile_1:
        cfi_endproc
 
        .size   _dl_runtime_resolve_1, .-_dl_runtime_resolve_1
+#endif
index 9ea2a708378b780695bb267949a250b6e71a55d7..581a2f1a9e491de8cd2230540fd8d2d65c1c5694 100644 (file)
@@ -89,6 +89,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
 
       const struct cpu_features* cpu_features = __get_cpu_features ();
 
+#ifdef SHARED
       /* The got[2] entry contains the address of a function which gets
         called to get the address of a so far unresolved function and
         jump to it.  The profiling extension of the dynamic linker allows
@@ -111,6 +112,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
            GL(dl_profile_map) = l;
        }
       else
+#endif
        {
          /* This function will get called to fix up the GOT entry
             indicated by the offset on the stack, and then jump to
index a6b9a1826b86f0f97818783419f171c36f4b5556..3fd30d58fc9dcbfa57909087604024c56c6fd2bc 100644 (file)
 
 #define RESTORE_AVX
 
-#define VEC_SIZE               64
-#define VMOVA                  vmovdqa64
-#define VEC(i)                 zmm##i
-#define _dl_runtime_profile    _dl_runtime_profile_avx512
-# define SECTION(p)            p##.evex512
-#include "dl-trampoline.h"
-#undef _dl_runtime_profile
-#undef VEC
-#undef VMOVA
-#undef VEC_SIZE
-#undef SECTION
-
-#if MINIMUM_X86_ISA_LEVEL <= AVX_X86_ISA_LEVEL
-# define VEC_SIZE              32
-# define VMOVA                 vmovdqa
-# define VEC(i)                        ymm##i
-# define SECTION(p)            p##.avx
-# define _dl_runtime_profile   _dl_runtime_profile_avx
+#ifdef SHARED
+# define VEC_SIZE              64
+# define VMOVA                 vmovdqa64
+# define VEC(i)                        zmm##i
+# define _dl_runtime_profile   _dl_runtime_profile_avx512
+#  define SECTION(p)           p##.evex512
 # include "dl-trampoline.h"
 # undef _dl_runtime_profile
 # undef VEC
 # undef VMOVA
 # undef VEC_SIZE
 # undef SECTION
-#endif
 
-#if MINIMUM_X86_ISA_LEVEL < AVX_X86_ISA_LEVEL
+# if MINIMUM_X86_ISA_LEVEL <= AVX_X86_ISA_LEVEL
+#  define VEC_SIZE             32
+#  define VMOVA                        vmovdqa
+#  define VEC(i)                       ymm##i
+#  define SECTION(p)           p##.avx
+#  define _dl_runtime_profile  _dl_runtime_profile_avx
+#  include "dl-trampoline.h"
+#  undef _dl_runtime_profile
+#  undef VEC
+#  undef VMOVA
+#  undef VEC_SIZE
+#  undef SECTION
+# endif
+
+# if MINIMUM_X86_ISA_LEVEL < AVX_X86_ISA_LEVEL
 /* movaps/movups is 1-byte shorter.  */
-# define VEC_SIZE              16
-# define VMOVA                 movaps
-# define VEC(i)                        xmm##i
-# define _dl_runtime_profile   _dl_runtime_profile_sse
-# undef RESTORE_AVX
-# include "dl-trampoline.h"
-# undef _dl_runtime_profile
-# undef VEC
-# undef VMOVA
-# undef VEC_SIZE
+#  define VEC_SIZE             16
+#  define VMOVA                        movaps
+#  define VEC(i)                       xmm##i
+#  define _dl_runtime_profile  _dl_runtime_profile_sse
+#  undef RESTORE_AVX
+#  include "dl-trampoline.h"
+#  undef _dl_runtime_profile
+#  undef VEC
+#  undef VMOVA
+#  undef VEC_SIZE
+# endif
+#endif /* SHARED */
 
+#if MINIMUM_X86_ISA_LEVEL < AVX_X86_ISA_LEVEL
 # define USE_FXSAVE
 # define STATE_SAVE_ALIGNMENT  16
 # define _dl_runtime_resolve   _dl_runtime_resolve_fxsave