public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "leo at yuriev dot ru" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug libc/29438] New: enabling gmon for arbitrary DSO Date: Tue, 02 Aug 2022 20:17:07 +0000 [thread overview] Message-ID: <bug-29438-131@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=29438 Bug ID: 29438 Summary: enabling gmon for arbitrary DSO Product: glibc Version: 2.38 Status: UNCONFIRMED Severity: normal Priority: P2 Component: libc Assignee: unassigned at sourceware dot org Reporter: leo at yuriev dot ru CC: drepper.fsp at gmail dot com Target Milestone: --- As a developer, I need the ability to activate/use gmon (gprof monitor) for my DSO (shared library). Yes, of course, I know that gmon is not intended for this. However, such restriction can be easily circumvented approximately as shown below. As a result, gmon.out will be created, which unfortunately cannot be processed correctly by gprof due to a problem similar to PIE in 2017 (Bug 21189, Bug 22284). The reason is that the fix made is only intended to work in the case of a PIE, but not a DSO. In particular due that the `load_address` is gathered strictly for executable only (https://sourceware.org/git/?p=glibc.git;a=blob;f=gmon/gmon.c;h=dee64803ada583d79ca9adc281beffce4300255f;hb=d165ca64980f90ccace088670652cc203d1b5411#l55). So I think this can be easily fixed if we take the `load_address` not from executable but of the first DSO, the text segment of which intersects with the range of addresses passed to `monstartup()`. Will such a patch be accepted if I prepare it, or will there be other ideas/suggestions? Leo, Regards. --- /* It is worth noting that the code below works for DSO * when `-pg` is not enabled in the main executable * but does not create problems if `-pg` is enabled. */ extern void _mcleanup (void); extern void monstartup(unsigned long, unsigned long); extern void __gmon_start__(void) __attribute__((__weak__)); extern void _init (void); extern void _fini (void); __attribute__((__constructor__, __no_instrument_function__, __no_profile_instrument_function__)) static void mydso_global_constructor(void) { #ifdef ENABLE_GPROF_FOR_THIS_DSO if (!&__gmon_start__) monstartup((u_long)&_init, (u_long)&_fini); #endif } __attribute__((__destructor__, __no_instrument_function__, __no_profile_instrument_function__)) void static mydso_global_destructor(void) { #ifdef ENABLE_GPROF_FOR_THIS_DSO if (!&__gmon_start__) _mcleanup(); #endif } -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2022-08-02 20:17 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-08-02 20:17 leo at yuriev dot ru [this message] 2022-08-02 20:18 ` [Bug libc/29438] " leo at yuriev dot ru 2022-08-03 15:30 ` leo at yuriev dot ru 2022-08-03 19:33 ` leo at yuriev dot ru 2022-10-21 13:39 ` nsz at gcc dot gnu.org 2023-01-30 12:32 ` leo at yuriev dot ru 2023-02-08 12:07 ` leo at yuriev dot ru 2023-02-22 22:24 ` cvs-commit at gcc dot gnu.org 2023-04-28 12:13 ` cvs-commit at gcc dot gnu.org 2023-04-28 14:35 ` cvs-commit at gcc dot gnu.org 2023-04-28 14:35 ` cvs-commit at gcc dot gnu.org 2023-04-28 17:23 ` cvs-commit at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-29438-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).