public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/98971] New: LTO removes __patchable_function_entries
@ 2021-02-04 21:37 gabriel at inconstante dot net.br
  2021-02-05  8:09 ` [Bug lto/98971] " marxin at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gabriel at inconstante dot net.br @ 2021-02-04 21:37 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-02-09  9:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-04 21:37 [Bug lto/98971] New: LTO removes __patchable_function_entries gabriel at inconstante dot net.br
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

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).