From: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
Subject: [PATCH v3] Use __executable_start as the lowest address for profiling [BZ #28153]
Date: Sat, 31 Jul 2021 10:43:40 -0700 [thread overview]
Message-ID: <CAMe9rOo1ugRUxUTd03j45uqxuk4GMa1u5gLpkJ8X5g=DFSM7AQ@mail.gmail.com> (raw)
In-Reply-To: <87k0l6v26y.fsf@oldenburg.str.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1976 bytes --]
On Sat, Jul 31, 2021 at 10:11 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Sat, Jul 31, 2021 at 9:36 AM Florian Weimer <fweimer@redhat.com> wrote:
> >>
> >> * H. J. Lu via Libc-alpha:
> >>
> >> > diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S
> >> > index 417da8802b..e46e01ed0b 100644
> >> > --- a/sysdeps/aarch64/start.S
> >> > +++ b/sysdeps/aarch64/start.S
> >> > @@ -42,7 +42,7 @@
> >> > NULL
> >> > */
> >> >
> >> > - .text
> >> > + .section .text.unlikely,"ax",%progbits
> >> > ENTRY(_start)
> >> > /* Create an initial frame with 0 LR and FP */
> >> > cfi_undefined (x30)
> >>
> >> I don't think it's correct to place code that runs during every process
> >> start into .text.unlikely. Surely we can avoid that page fault.
> >>
> >> Can we fix the ENTRY_POINT assumption in profiling instead?
> >
> > We can do
> >
> > diff --git a/csu/gmon-start.c b/csu/gmon-start.c
> > index b3432885b3..83322fd586 100644
> > --- a/csu/gmon-start.c
> > +++ b/csu/gmon-start.c
> > @@ -48,7 +48,7 @@
> > #ifdef ENTRY_POINT_DECL
> > ENTRY_POINT_DECL(extern)
> > #else
> > -extern char ENTRY_POINT[];
> > +extern char entry_point[] asm (__SYMBOL_PREFIX "main");
> > #endif
> > extern char etext[];
> >
> > @@ -56,7 +56,7 @@ extern char etext[];
> > # ifdef ENTRY_POINT_DECL
> > # define TEXT_START ENTRY_POINT
> > # else
> > -# define TEXT_START &ENTRY_POINT
> > +# define TEXT_START &entry_point
> > # endif
> > #endif
> >
> > But this may only work with BFD linker which places .text.startup
> > section before .text section.
>
> Can we get the linker to emit a symbol at the start of the text section?
We already have __executable_start which is pretty close to what we
need. Like this.
> Like it does for orphan sections?
>
> Then we can use a weak symbol reference in gmon-start.c and use the new
> symbol if it is available.
>
> Thanks,
> Florian
>
--
H.J.
[-- Attachment #2: v3-0001-Use-__executable_start-as-the-lowest-address-for-.patch --]
[-- Type: application/x-patch, Size: 3003 bytes --]
next prev parent reply other threads:[~2021-07-31 17:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-31 15:13 [PATCH v2] Place ENTRY_POINT in .text.unlikely section [BZ #28153] H.J. Lu via Libc-alpha
2021-07-31 16:36 ` Florian Weimer via Libc-alpha
2021-07-31 17:06 ` H.J. Lu via Libc-alpha
2021-07-31 17:09 ` H.J. Lu via Libc-alpha
2021-07-31 17:11 ` Florian Weimer via Libc-alpha
2021-07-31 17:34 ` Andreas Schwab
2021-07-31 17:43 ` H.J. Lu via Libc-alpha [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-08-05 12:09 [PATCH v3] Use __executable_start as the lowest address for profiling " H.J. Lu via Libc-alpha
2021-08-06 0:16 ` Fangrui Song via Libc-alpha
2021-08-06 7:21 ` Fangrui Song via Libc-alpha
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
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMe9rOo1ugRUxUTd03j45uqxuk4GMa1u5gLpkJ8X5g=DFSM7AQ@mail.gmail.com' \
--to=libc-alpha@sourceware.org \
--cc=fweimer@redhat.com \
--cc=hjl.tools@gmail.com \
/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: link
Be 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).