aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-11-06 17:25:46 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-11-21 16:15:42 -0300
commit55f41ef8de4a4d0c5762d78659e11202d3c765d4 (patch)
tree205676e94304e4a3a43e3a4eee4e027986593f09 /elf
parent4a133885a7c8ae7ebe34e36fcdb353f8e94c810f (diff)
downloadglibc-55f41ef8de4a4d0c5762d78659e11202d3c765d4.zip
glibc-55f41ef8de4a4d0c5762d78659e11202d3c765d4.tar.gz
glibc-55f41ef8de4a4d0c5762d78659e11202d3c765d4.tar.bz2
elf: Remove LD_PROFILE for static binaries
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>
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile10
-rw-r--r--elf/dl-load.c10
-rw-r--r--elf/dl-runtime.c12
-rw-r--r--elf/dl-support.c9
-rw-r--r--elf/libc-dl-profstub.c (renamed from elf/dl-profstub.c)0
5 files changed, 16 insertions, 25 deletions
diff --git a/elf/Makefile b/elf/Makefile
index 414fdbd..3f7f895 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -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 \
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 8d35115..25ea4f7 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -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. */
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
index 32a8bfc..fe7deda 100644
--- a/elf/dl-runtime.c
+++ b/elf/dl-runtime.c
@@ -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 */
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 44a54de..31a608d 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -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[] =
diff --git a/elf/dl-profstub.c b/elf/libc-dl-profstub.c
index 8fb8aaa..8fb8aaa 100644
--- a/elf/dl-profstub.c
+++ b/elf/libc-dl-profstub.c