public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gabriel at inconstante dot net.br" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug lto/98971] New: LTO removes __patchable_function_entries
Date: Thu, 04 Feb 2021 21:37:20 +0000	[thread overview]
Message-ID: <bug-98971-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98971

            Bug ID: 98971
           Summary: LTO removes __patchable_function_entries
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabriel at inconstante dot net.br
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Building with -flto removes the effects of -fpatchable-function-entries, or at
least some of them.

For instance, building the following code:

$ cat libtesta.c
int
testa7(void)
{
  return 7;
}

with:

$ gcc libtesta.c -fPIC -fpatchable-function-entry=4,2 -flto -c -o libtesta.o
$ gcc libtesta.o -flto -shared -o libtesta.so

removes the nop padding usually generated with -fpatchable-function-entry, as
well as it removes the __patchable_function_entries section from the resulting
binaries. The intermediate libtesta.o already lacks both:

$ readelf --sections libtesta.o | grep __patchable
$ readelf --sections libtesta.so | grep __patchable
$ objdump -d libtesta.so | grep "<testa7>:" -C3
00000000000010f0 <frame_dummy>:
    10f0:       e9 7b ff ff ff          jmpq   1070 <register_tm_clones>

00000000000010f5 <testa7>:
    10f5:       55                      push   %rbp
    10f6:       48 89 e5                mov    %rsp,%rbp
    10f9:       b8 07 00 00 00          mov    $0x7,%eax

Without -flto, I get what I expected:

$ readelf --sections libtesta.o | grep __patchable
  [ 4] __patchable_[...] PROGBITS         0000000000000000  00000050
$ readelf --sections libtesta.so | grep __patchable
  [19] __patchable_[...] PROGBITS         0000000000004020  00003020
$ objdump -d libtesta.so | grep "<testa7>:" -C3
    10f5:       90                      nop
    10f6:       90                      nop

00000000000010f7 <testa7>:
    10f7:       90                      nop
    10f8:       90                      nop
    10f9:       55                      push   %rbp

Building with a single gcc command, such as:

$ gcc libtesta.c -fPIC -fpatchable-function-entry=4,2 -flto -shared -o
libtesta.so

also works as I expected, i.e.: the nops and the __patchable_function_entries
are kept.


Is this the intended behavior? Am I using it wrong? Or is this a bug?

Cheers

PS: Tested with the branch for gcc 10, with trunk, and with the compilers from
openSUSE and Debian.

             reply	other threads:[~2021-02-04 21:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04 21:37 gabriel at inconstante dot net.br [this message]
2021-02-05  8:09 ` [Bug lto/98971] " marxin at gcc dot gnu.org
2021-02-05 12:18 ` marxin at gcc dot gnu.org
2021-02-05 13:11 ` gagomes at suse dot de
2021-02-05 13:27 ` marxin at gcc dot gnu.org
2021-02-05 13:41 ` gagomes at suse dot de
2021-02-08 11:31 ` cvs-commit at gcc dot gnu.org
2021-02-08 11:32 ` marxin at gcc dot gnu.org
2021-02-09  9:02 ` marxin 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-98971-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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: 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).