mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-06 20:58:33 +01:00
dlopen: skip debugger notification for DSO loaded from sprof (bug 30258)
Avoid inconsistent state in the debugger interface.
This commit is contained in:
parent
d1417176a3
commit
ab5aa2ee3d
5 changed files with 105 additions and 0 deletions
11
elf/Makefile
11
elf/Makefile
|
@ -510,6 +510,7 @@ tests-container += \
|
||||||
|
|
||||||
test-srcs = \
|
test-srcs = \
|
||||||
tst-pathopt \
|
tst-pathopt \
|
||||||
|
tst-sprof-basic \
|
||||||
# tests-srcs
|
# tests-srcs
|
||||||
|
|
||||||
ifeq (yes,$(have-fpie))
|
ifeq (yes,$(have-fpie))
|
||||||
|
@ -861,6 +862,7 @@ modules-names += \
|
||||||
tst-sonamemove-linkmod1 \
|
tst-sonamemove-linkmod1 \
|
||||||
tst-sonamemove-runmod1 \
|
tst-sonamemove-runmod1 \
|
||||||
tst-sonamemove-runmod2 \
|
tst-sonamemove-runmod2 \
|
||||||
|
tst-sprof-mod \
|
||||||
tst-tls19mod1 \
|
tst-tls19mod1 \
|
||||||
tst-tls19mod2 \
|
tst-tls19mod2 \
|
||||||
tst-tls19mod3 \
|
tst-tls19mod3 \
|
||||||
|
@ -1116,6 +1118,7 @@ tests-special += \
|
||||||
$(objpfx)tst-rtld-help.out \
|
$(objpfx)tst-rtld-help.out \
|
||||||
$(objpfx)tst-rtld-load-self.out \
|
$(objpfx)tst-rtld-load-self.out \
|
||||||
$(objpfx)tst-rtld-preload.out \
|
$(objpfx)tst-rtld-preload.out \
|
||||||
|
$(objpfx)tst-sprof-basic.out \
|
||||||
# tests-special
|
# tests-special
|
||||||
endif
|
endif
|
||||||
tests-special += \
|
tests-special += \
|
||||||
|
@ -2986,3 +2989,11 @@ tst-audit-tlsdesc-dlopen-ENV = LD_AUDIT=$(objpfx)tst-auditmod-tlsdesc.so
|
||||||
$(objpfx)tst-dlmopen-twice.out: \
|
$(objpfx)tst-dlmopen-twice.out: \
|
||||||
$(objpfx)tst-dlmopen-twice-mod1.so \
|
$(objpfx)tst-dlmopen-twice-mod1.so \
|
||||||
$(objpfx)tst-dlmopen-twice-mod2.so
|
$(objpfx)tst-dlmopen-twice-mod2.so
|
||||||
|
|
||||||
|
LDFLAGS-tst-sprof-mod.so = -Wl,-soname,tst-sprof-mod.so
|
||||||
|
$(objpfx)tst-sprof-basic: $(objpfx)tst-sprof-mod.so
|
||||||
|
$(objpfx)tst-sprof-basic.out: tst-sprof-basic.sh $(objpfx)tst-sprof-basic
|
||||||
|
$(SHELL) $< $(common-objpfx) '$(test-wrapper-env)' \
|
||||||
|
'$(run-program-env)' > $@; \
|
||||||
|
$(evaluate-test)
|
||||||
|
generated += tst-sprof-mod.so.profile
|
||||||
|
|
|
@ -1483,6 +1483,10 @@ cannot enable executable stack as shared object requires");
|
||||||
/* Now that the object is fully initialized add it to the object list. */
|
/* Now that the object is fully initialized add it to the object list. */
|
||||||
_dl_add_to_namespace_list (l, nsid);
|
_dl_add_to_namespace_list (l, nsid);
|
||||||
|
|
||||||
|
/* Skip auditing and debugger notification when called from 'sprof'. */
|
||||||
|
if (mode & __RTLD_SPROF)
|
||||||
|
return l;
|
||||||
|
|
||||||
/* Signal that we are going to add new objects. */
|
/* Signal that we are going to add new objects. */
|
||||||
struct r_debug *r = _dl_debug_update (nsid);
|
struct r_debug *r = _dl_debug_update (nsid);
|
||||||
if (r->r_state == RT_CONSISTENT)
|
if (r->r_state == RT_CONSISTENT)
|
||||||
|
|
25
elf/tst-sprof-basic.c
Normal file
25
elf/tst-sprof-basic.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* Copyright (C) 2023 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with the GNU C Library; if not, see
|
||||||
|
<https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
void hello (void);
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
hello ();
|
||||||
|
return 0;
|
||||||
|
}
|
41
elf/tst-sprof-basic.sh
Executable file
41
elf/tst-sprof-basic.sh
Executable file
|
@ -0,0 +1,41 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Test basic functionality of sprof
|
||||||
|
# Copyright (C) 2023 Free Software Foundation, Inc.
|
||||||
|
# This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
# The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with the GNU C Library; if not, see
|
||||||
|
# <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
common_objpfx=$1
|
||||||
|
test_wrapper_env=$2
|
||||||
|
run_program_env=$3
|
||||||
|
|
||||||
|
sprof_mod=tst-sprof-mod.so
|
||||||
|
|
||||||
|
${test_wrapper_env} \
|
||||||
|
${run_program_env} \
|
||||||
|
LD_PROFILE=$sprof_mod \
|
||||||
|
LD_PROFILE_OUTPUT=${common_objpfx}elf \
|
||||||
|
LD_LIBRARY_PATH=${common_objpfx}.:${common_objpfx}elf \
|
||||||
|
${common_objpfx}elf/ld.so ${common_objpfx}elf/tst-sprof-basic
|
||||||
|
|
||||||
|
${test_wrapper_env} \
|
||||||
|
${run_program_env} \
|
||||||
|
LD_LIBRARY_PATH=${common_objpfx}.:${common_objpfx}elf \
|
||||||
|
${common_objpfx}elf/ld.so ${common_objpfx}elf/sprof -p $sprof_mod \
|
||||||
|
${common_objpfx}elf/${sprof_mod}.profile
|
||||||
|
|
||||||
|
exit $?
|
24
elf/tst-sprof-mod.c
Normal file
24
elf/tst-sprof-mod.c
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/* Copyright (C) 2023 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with the GNU C Library; if not, see
|
||||||
|
<https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
hello (void)
|
||||||
|
{
|
||||||
|
printf ("Hello World\n");
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue