public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "i at maskray dot me" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/100593] [ELF] -fno-pic: Use GOT to take address of an external default visibility function
Date: Mon, 17 May 2021 05:27:49 +0000	[thread overview]
Message-ID: <bug-100593-4-R4aSPZux1Q@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-100593-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Fangrui Song <i at maskray dot me> ---
(In reply to Alexander Monakov from comment #1)
> It is not necessary to change -fno-pic code generation to gain most of the
> -Bsymbolic benefit

It is necessary, otherwise the function address taken from the
-Bsymbolic/-Bsymbolic-functions/-Bsymbolic-global-functions shared object may
be different from the address taken from the -fno-pic code.

The ELF hack is called canonical PLT entry, similar to copy relocations.

> as you say, the most important point is to avoid jumping
> via PLT trampolines (or, with -fno-plt, GOT loads) for function calls, so
> the linker could do -Bsymbolic relaxation for sites where address doesn't
> matter (calls and jumps) while keeping a dynamic relocation for address
> loads? Under some new option of course, like -Bsymbolic-plt. Right?

There are two points: (1) R_*_JUMP_SLOT symbol lookup cost (2) whether call
sites get penalized by the PLT indirection.

-fno-pic code must use GOT (instead of an absolute relocation) for default
visibility external function access to be compatible with a
-Bsymbolic/-Bsymbolic-functions/-Bsymbolic-global-functions shared object.

  parent reply	other threads:[~2021-05-17  5:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14  0:44 [Bug c/100593] New: " i at maskray dot me
2021-05-17  4:57 ` [Bug middle-end/100593] " amonakov at gcc dot gnu.org
2021-05-17  5:27 ` i at maskray dot me [this message]
2021-05-17  6:13 ` amonakov at gcc dot gnu.org
2021-05-17  7:55 ` i at maskray dot me
2021-05-17 10:07 ` amonakov at gcc dot gnu.org
2021-05-17 18:38 ` i at maskray dot me
2021-05-18  9:16 ` amonakov at gcc dot gnu.org
2021-05-18 17:47 ` i at maskray dot me
2021-05-26 22:15 ` i at maskray dot me
2021-05-27  7:30 ` amonakov at gcc dot gnu.org
2021-06-04 18:05 ` i at maskray dot me
2021-06-06 15:01 ` hjl.tools at gmail dot com
2021-06-06 17:36 ` i at maskray dot me
2022-02-09 12:39 ` cvs-commit at gcc dot gnu.org
2022-04-29 19:39 ` ndesaulniers at google dot com
2023-01-04 18:54 ` pinskia 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-100593-4-R4aSPZux1Q@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).